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 "build/build_config.h" | 7 #include "build/build_config.h" |
8 | 8 |
9 #if defined(OS_WIN) | |
10 #include "base/allocator/allocator_shim_win.h" | |
11 #endif | |
12 | |
9 #if defined(OS_LINUX) | 13 #if defined(OS_LINUX) |
10 #include <malloc.h> | 14 #include <malloc.h> |
11 #endif | 15 #endif |
12 | 16 |
13 namespace base { | 17 namespace base { |
14 namespace allocator { | 18 namespace allocator { |
15 | 19 |
16 // Defined in allocator_shim_win.cc . | |
17 // TODO(primiano): replace with an include once base can depend on allocator. | |
Primiano Tucci (use gerrit)
2016/03/29 18:46:07
thanks, forgot about this :)
Will Harris
2016/03/29 18:56:20
Acknowledged.
| |
18 #if defined(OS_WIN) && defined(ALLOCATOR_SHIM) | |
19 extern bool g_is_win_shim_layer_initialized; | |
20 #endif | |
21 | |
22 bool IsAllocatorInitialized() { | 20 bool IsAllocatorInitialized() { |
23 #if defined(OS_WIN) && defined(ALLOCATOR_SHIM) | 21 #if defined(OS_WIN) && defined(ALLOCATOR_SHIM) |
24 // Set by allocator_shim_win.cc when the shimmed _heap_init() is called. | 22 // Set by allocator_shim_win.cc when the shimmed _set_new_mode() is called. |
25 return g_is_win_shim_layer_initialized; | 23 return g_is_win_shim_layer_initialized; |
26 #elif defined(OS_LINUX) && defined(USE_TCMALLOC) | 24 #elif defined(OS_LINUX) && defined(USE_TCMALLOC) |
27 // From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h. | 25 // From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h. |
28 // TODO(primiano): replace with an include once base can depend on allocator. | 26 // TODO(primiano): replace with an include once base can depend on allocator. |
29 #define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42 | 27 #define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42 |
30 return (mallopt(TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC, 0) == | 28 return (mallopt(TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC, 0) == |
31 TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC); | 29 TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC); |
32 #else | 30 #else |
33 return true; | 31 return true; |
34 #endif | 32 #endif |
35 } | 33 } |
36 | 34 |
37 } // namespace allocator | 35 } // namespace allocator |
38 } // namespace base | 36 } // namespace base |
OLD | NEW |