1 // Copyright 2023 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "build/build_config.h"
6 #include "partition_alloc/partition_alloc_base/compiler_specific.h"
7 #include "partition_alloc/partition_alloc_base/numerics/checked_math.h"
8 #include "partition_alloc/partition_alloc_buildflags.h"
9 #include "partition_alloc/shim/allocator_shim.h"
10 #include "partition_alloc/shim/checked_multiply_win.h"
11 
12 #if BUILDFLAG(USE_PARTITION_ALLOC_AS_MALLOC)
13 #include "partition_alloc/shim/allocator_shim_default_dispatch_to_partition_alloc.h"
14 #endif
15 
16 // No calls to malloc / new in this file. They would cause re-entrancy of
17 // the shim, which is hard to deal with. Keep this code as simple as possible
18 // and don't use any external C++ object here, not even //base ones. Even if
19 // they are safe to use today, in future they might be refactored.
20 
21 #include "partition_alloc/shim/allocator_shim_functions.h"
22 #include "partition_alloc/shim/allocator_shim_override_ucrt_symbols_win.h"
23 
24 // Cross-checks.
25 #if defined(COMPONENT_BUILD) || !BUILDFLAG(IS_WIN)
26 #error This code is only for Windows static build.
27 #endif
28 
29 #if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
30 #error The allocator shim should not be compiled when building for memory tools.
31 #endif
32 
33 #if (defined(__GNUC__) && defined(__EXCEPTIONS)) || \
34     (defined(_MSC_VER) && defined(_CPPUNWIND))
35 #error This code cannot be used when exceptions are turned on.
36 #endif
37