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

Side by Side Diff: third_party/tcmalloc/chromium/src/libc_override.h

Issue 1678893002: allocator: add use_experimental_allocator_shim build flag (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 4 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
« no previous file with comments | « third_party/tcmalloc/README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, Google Inc. 1 // Copyright (c) 2011, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #define TCMALLOC_LIBC_OVERRIDE_INL_H_ 52 #define TCMALLOC_LIBC_OVERRIDE_INL_H_
53 53
54 #include <config.h> 54 #include <config.h>
55 #ifdef HAVE_FEATURES_H 55 #ifdef HAVE_FEATURES_H
56 #include <features.h> // for __GLIBC__ 56 #include <features.h> // for __GLIBC__
57 #endif 57 #endif
58 #include <gperftools/tcmalloc.h> 58 #include <gperftools/tcmalloc.h>
59 59
60 static void ReplaceSystemAlloc(); // defined in the .h files below 60 static void ReplaceSystemAlloc(); // defined in the .h files below
61 61
62 #if defined(TCMALLOC_DONT_REPLACE_SYSTEM_ALLOC)
63 // TCMALLOC_DONT_REPLACE_SYSTEM_ALLOC has the following semantic:
64 // - tcmalloc with all its tc_* (tc_malloc, tc_free) symbols is being built
65 // and linked as usual.
66 // - the default system allocator symbols (malloc, free, operator new) are NOT
67 // overridden. The embedded must take care of routing them to tc_* symbols.
68 // This no-op #if block effectively prevents the inclusion of the
69 // libc_override_* headers below.
70 static void ReplaceSystemAlloc() {}
Nico 2016/02/09 20:14:23 Which files include this? Defining static function
Primiano Tucci (use gerrit) 2016/02/09 20:34:23 So I think that the deal is that this header is a
71
62 // For windows, there are two ways to get tcmalloc. If we're 72 // For windows, there are two ways to get tcmalloc. If we're
63 // patching, then src/windows/patch_function.cc will do the necessary 73 // patching, then src/windows/patch_function.cc will do the necessary
64 // overriding here. Otherwise, we doing the 'redefine' trick, where 74 // overriding here. Otherwise, we doing the 'redefine' trick, where
65 // we remove malloc/new/etc from mscvcrt.dll, and just need to define 75 // we remove malloc/new/etc from mscvcrt.dll, and just need to define
66 // them now. 76 // them now.
67 #if defined(_WIN32) && defined(WIN32_DO_PATCHING) 77 #elif defined(_WIN32) && defined(WIN32_DO_PATCHING)
68 void PatchWindowsFunctions(); // in src/windows/patch_function.cc 78 void PatchWindowsFunctions(); // in src/windows/patch_function.cc
69 static void ReplaceSystemAlloc() { PatchWindowsFunctions(); } 79 static void ReplaceSystemAlloc() { PatchWindowsFunctions(); }
70 80
71 #elif defined(_WIN32) && !defined(WIN32_DO_PATCHING) 81 #elif defined(_WIN32) && !defined(WIN32_DO_PATCHING)
72 // "libc_override_redefine.h" is included in the original gperftools. But, 82 // "libc_override_redefine.h" is included in the original gperftools. But,
73 // we define allocator functions in Chromium's base/allocator/allocator_shim.cc 83 // we define allocator functions in Chromium's base/allocator/allocator_shim.cc
74 // on Windows. We don't include libc_override_redefine.h here. 84 // on Windows. We don't include libc_override_redefine.h here.
75 // ReplaceSystemAlloc() is defined here instead. 85 // ReplaceSystemAlloc() is defined here instead.
76 static void ReplaceSystemAlloc() { } 86 static void ReplaceSystemAlloc() { }
77 87
78 #elif defined(__APPLE__) 88 #elif defined(__APPLE__)
79 #include "libc_override_osx.h" 89 #include "libc_override_osx.h"
80 90
81 #elif defined(__GLIBC__) 91 #elif defined(__GLIBC__)
82 #include "libc_override_glibc.h" 92 #include "libc_override_glibc.h"
83 93
84 // Not all gcc systems necessarily support weak symbols, but all the 94 // Not all gcc systems necessarily support weak symbols, but all the
85 // ones I know of do, so for now just assume they all do. 95 // ones I know of do, so for now just assume they all do.
86 #elif defined(__GNUC__) 96 #elif defined(__GNUC__)
87 #include "libc_override_gcc_and_weak.h" 97 #include "libc_override_gcc_and_weak.h"
88 98
89 #else 99 #else
90 #error Need to add support for your libc/OS here 100 #error Need to add support for your libc/OS here
91 101
92 #endif 102 #endif
93 103
94 #endif // TCMALLOC_LIBC_OVERRIDE_INL_H_ 104 #endif // TCMALLOC_LIBC_OVERRIDE_INL_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698