OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/allocator/allocator_check.h" | 5 #include "base/allocator/allocator_check.h" |
6 | 6 |
| 7 #include "base/allocator/features.h" |
7 #include "build/build_config.h" | 8 #include "build/build_config.h" |
8 | 9 |
9 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
10 #include "base/allocator/allocator_shim_win.h" | 11 #include "base/allocator/winheap_stubs_win.h" |
11 #endif | 12 #endif |
12 | 13 |
13 #if defined(OS_LINUX) | 14 #if defined(OS_LINUX) |
14 #include <malloc.h> | 15 #include <malloc.h> |
15 #endif | 16 #endif |
16 | 17 |
17 #if defined(OS_MACOSX) | 18 #if defined(OS_MACOSX) |
18 #include "base/allocator/allocator_interception_mac.h" | 19 #include "base/allocator/allocator_interception_mac.h" |
19 #endif | 20 #endif |
20 | 21 |
21 namespace base { | 22 namespace base { |
22 namespace allocator { | 23 namespace allocator { |
23 | 24 |
24 bool IsAllocatorInitialized() { | 25 bool IsAllocatorInitialized() { |
25 #if defined(OS_WIN) && defined(ALLOCATOR_SHIM) | 26 #if defined(OS_WIN) && defined(USE_ALLOCATOR_SHIM) |
26 // Set by allocator_shim_win.cc when the shimmed _set_new_mode() is called. | 27 // Set by allocator_shim_override_ucrt_symbols_win.h when the |
| 28 // shimmed _set_new_mode() is called. |
27 return g_is_win_shim_layer_initialized; | 29 return g_is_win_shim_layer_initialized; |
28 #elif defined(OS_LINUX) && defined(USE_TCMALLOC) && \ | 30 #elif defined(OS_LINUX) && defined(USE_TCMALLOC) && \ |
29 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 31 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
30 // From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h. | 32 // From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h. |
31 // TODO(primiano): replace with an include once base can depend on allocator. | 33 // TODO(primiano): replace with an include once base can depend on allocator. |
32 #define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42 | 34 #define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42 |
33 return (mallopt(TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC, 0) == | 35 return (mallopt(TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC, 0) == |
34 TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC); | 36 TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC); |
35 #elif defined(OS_MACOSX) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) | 37 #elif defined(OS_MACOSX) && !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
36 // From allocator_interception_mac.mm. | 38 // From allocator_interception_mac.mm. |
37 return base::allocator::g_replaced_default_zone; | 39 return base::allocator::g_replaced_default_zone; |
38 #else | 40 #else |
39 return true; | 41 return true; |
40 #endif | 42 #endif |
41 } | 43 } |
42 | 44 |
43 } // namespace allocator | 45 } // namespace allocator |
44 } // namespace base | 46 } // namespace base |
OLD | NEW |