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

Side by Side Diff: third_party/tcmalloc/vendor/src/libc_override_osx.h

Issue 9701040: Revert 126715 - Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // punt and don't implement our own posix_memalign. Apps that really 68 // punt and don't implement our own posix_memalign. Apps that really
69 // care can use tc_posix_memalign directly. 69 // care can use tc_posix_memalign directly.
70 70
71 #ifndef TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_ 71 #ifndef TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_
72 #define TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_ 72 #define TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_
73 73
74 #include <config.h> 74 #include <config.h>
75 #ifdef HAVE_FEATURES_H 75 #ifdef HAVE_FEATURES_H
76 #include <features.h> 76 #include <features.h>
77 #endif 77 #endif
78 #include <gperftools/tcmalloc.h> 78 #include <google/tcmalloc.h>
79 79
80 #if !defined(__APPLE__) 80 #if !defined(__APPLE__)
81 # error libc_override_glibc-osx.h is for OS X distributions only. 81 # error libc_override_glibc-osx.h is for OS X distributions only.
82 #endif 82 #endif
83 83
84 #include <AvailabilityMacros.h> 84 #include <AvailabilityMacros.h>
85 #include <malloc/malloc.h> 85 #include <malloc/malloc.h>
86 86
87 // from AvailabilityMacros.h
88 #if defined(MAC_OS_X_VERSION_10_6) && \
89 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
90 extern "C" {
91 // This function is only available on 10.6 (and later) but the
92 // LibSystem headers do not use AvailabilityMacros.h to handle weak
93 // importing automatically. This prototype is a copy of the one in
94 // <malloc/malloc.h> with the WEAK_IMPORT_ATTRBIUTE added.
95 extern malloc_zone_t *malloc_default_purgeable_zone(void)
96 WEAK_IMPORT_ATTRIBUTE;
97 }
98 #endif
99
100 // We need to provide wrappers around all the libc functions. 87 // We need to provide wrappers around all the libc functions.
101 namespace { 88 namespace {
102 size_t mz_size(malloc_zone_t* zone, const void* ptr) { 89 size_t mz_size(malloc_zone_t* zone, const void* ptr) {
103 if (MallocExtension::instance()->GetOwnership(ptr) != MallocExtension::kOwned) 90 if (MallocExtension::instance()->GetOwnership(ptr) != MallocExtension::kOwned)
104 return 0; // malloc_zone semantics: return 0 if we don't own the memory 91 return 0; // malloc_zone semantics: return 0 if we don't own the memory
105 92
106 // TODO(csilvers): change this method to take a const void*, one day. 93 // TODO(csilvers): change this method to take a const void*, one day.
107 return MallocExtension::instance()->GetAllocatedSize(const_cast<void*>(ptr)); 94 return MallocExtension::instance()->GetAllocatedSize(const_cast<void*>(ptr));
108 } 95 }
109 96
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 tcmalloc_zone.version = 6; 228 tcmalloc_zone.version = 6;
242 tcmalloc_zone.free_definite_size = NULL; 229 tcmalloc_zone.free_definite_size = NULL;
243 tcmalloc_zone.memalign = &mz_memalign; 230 tcmalloc_zone.memalign = &mz_memalign;
244 tcmalloc_introspection.zone_locked = &mi_zone_locked; 231 tcmalloc_introspection.zone_locked = &mi_zone_locked;
245 232
246 // Request the default purgable zone to force its creation. The 233 // Request the default purgable zone to force its creation. The
247 // current default zone is registered with the purgable zone for 234 // current default zone is registered with the purgable zone for
248 // doing tiny and small allocs. Sadly, it assumes that the default 235 // doing tiny and small allocs. Sadly, it assumes that the default
249 // zone is the szone implementation from OS X and will crash if it 236 // zone is the szone implementation from OS X and will crash if it
250 // isn't. By creating the zone now, this will be true and changing 237 // isn't. By creating the zone now, this will be true and changing
251 // the default zone won't cause a problem. This only needs to 238 // the default zone won't cause a problem. (OS X 10.6 and higher.)
252 // happen when actually running on OS X 10.6 and higher (note the 239 malloc_default_purgeable_zone();
253 // ifdef above only checks if we were *compiled* with 10.6 or
254 // higher; at runtime we have to check if this symbol is defined.)
255 if (malloc_default_purgeable_zone) {
256 malloc_default_purgeable_zone();
257 }
258 #endif 240 #endif
259 241
260 // Register the tcmalloc zone. At this point, it will not be the 242 // Register the tcmalloc zone. At this point, it will not be the
261 // default zone. 243 // default zone.
262 malloc_zone_register(&tcmalloc_zone); 244 malloc_zone_register(&tcmalloc_zone);
263 245
264 // Unregister and reregister the default zone. Unregistering swaps 246 // Unregister and reregister the default zone. Unregistering swaps
265 // the specified zone with the last one registered which for the 247 // the specified zone with the last one registered which for the
266 // default zone makes the more recently registered zone the default 248 // default zone makes the more recently registered zone the default
267 // zone. The default zone is then re-registered to ensure that 249 // zone. The default zone is then re-registered to ensure that
268 // allocations made from it earlier will be handled correctly. 250 // allocations made from it earlier will be handled correctly.
269 // Things are not guaranteed to work that way, but it's how they work now. 251 // Things are not guaranteed to work that way, but it's how they work now.
270 malloc_zone_t *default_zone = malloc_default_zone(); 252 malloc_zone_t *default_zone = malloc_default_zone();
271 malloc_zone_unregister(default_zone); 253 malloc_zone_unregister(default_zone);
272 malloc_zone_register(default_zone); 254 malloc_zone_register(default_zone);
273 } 255 }
274 256
275 #endif // TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_ 257 #endif // TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/vendor/src/libc_override_glibc.h ('k') | third_party/tcmalloc/vendor/src/malloc_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698