Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: base/allocator/allocator_check.cc

Issue 2676093003: mac: Hook up allocator shim during app startup. (Closed)
Patch Set: Comments from primiano. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/allocator_shim_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
18 #if defined(OS_MACOSX)
19 #include "base/allocator/allocator_shim.h"
20 #endif
21
17 namespace base { 22 namespace base {
18 namespace allocator { 23 namespace allocator {
19 24
20 bool IsAllocatorInitialized() { 25 bool IsAllocatorInitialized() {
21 #if defined(OS_WIN) && defined(ALLOCATOR_SHIM) 26 #if defined(OS_WIN) && defined(ALLOCATOR_SHIM)
22 // Set by allocator_shim_win.cc when the shimmed _set_new_mode() is called. 27 // Set by allocator_shim_win.cc when the shimmed _set_new_mode() is called.
23 return g_is_win_shim_layer_initialized; 28 return g_is_win_shim_layer_initialized;
24 #elif defined(OS_LINUX) && defined(USE_TCMALLOC) && \ 29 #elif defined(OS_LINUX) && defined(USE_TCMALLOC) && \
25 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR) 30 !defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
26 // From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h. 31 // From third_party/tcmalloc/chromium/src/gperftools/tcmalloc.h.
27 // TODO(primiano): replace with an include once base can depend on allocator. 32 // TODO(primiano): replace with an include once base can depend on allocator.
28 #define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42 33 #define TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC 0xbeef42
29 return (mallopt(TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC, 0) == 34 return (mallopt(TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC, 0) ==
30 TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC); 35 TC_MALLOPT_IS_OVERRIDDEN_BY_TCMALLOC);
36 #elif defined(OS_MACOSX) && BUILDFLAG(USE_EXPERIMENTAL_ALLOCATOR_SHIM)
Primiano Tucci (use gerrit) 2017/02/07 11:58:08 I think this should really be: #elif defined(OS_MA
erikchen 2017/02/09 23:49:04 Done.
37 return g_is_mac_shim_layer_initialized;
31 #else 38 #else
32 return true; 39 return true;
33 #endif 40 #endif
34 } 41 }
35 42
36 } // namespace allocator 43 } // namespace allocator
37 } // namespace base 44 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/allocator/allocator_interception_mac.mm » ('j') | base/allocator/allocator_interception_mac.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698