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

Unified Diff: third_party/tcmalloc/vendor/src/libc_override_osx.h

Issue 9316021: Update the tcmalloc vendor branch to r144 (gperftools 2.0). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Reuploading 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 side-by-side diff with in-line comments
Download patch
Index: third_party/tcmalloc/vendor/src/libc_override_osx.h
diff --git a/third_party/tcmalloc/vendor/src/libc_override_osx.h b/third_party/tcmalloc/vendor/src/libc_override_osx.h
index 0ccf9a31d2d392d96813b3eba6da0c0fc8eb30e8..78a0ef2f95974b4d02e75dceaa716f75592d1e0a 100644
--- a/third_party/tcmalloc/vendor/src/libc_override_osx.h
+++ b/third_party/tcmalloc/vendor/src/libc_override_osx.h
@@ -75,7 +75,7 @@
#ifdef HAVE_FEATURES_H
#include <features.h>
#endif
-#include <google/tcmalloc.h>
+#include <gperftools/tcmalloc.h>
#if !defined(__APPLE__)
# error libc_override_glibc-osx.h is for OS X distributions only.
@@ -84,6 +84,19 @@
#include <AvailabilityMacros.h>
#include <malloc/malloc.h>
+// from AvailabilityMacros.h
+#if defined(MAC_OS_X_VERSION_10_6) && \
+ MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
+extern "C" {
+ // This function is only available on 10.6 (and later) but the
+ // LibSystem headers do not use AvailabilityMacros.h to handle weak
+ // importing automatically. This prototype is a copy of the one in
+ // <malloc/malloc.h> with the WEAK_IMPORT_ATTRBIUTE added.
+ extern malloc_zone_t *malloc_default_purgeable_zone(void)
+ WEAK_IMPORT_ATTRIBUTE;
+}
+#endif
+
// We need to provide wrappers around all the libc functions.
namespace {
size_t mz_size(malloc_zone_t* zone, const void* ptr) {
@@ -235,8 +248,13 @@ static void ReplaceSystemAlloc() {
// doing tiny and small allocs. Sadly, it assumes that the default
// zone is the szone implementation from OS X and will crash if it
// isn't. By creating the zone now, this will be true and changing
- // the default zone won't cause a problem. (OS X 10.6 and higher.)
- malloc_default_purgeable_zone();
+ // the default zone won't cause a problem. This only needs to
+ // happen when actually running on OS X 10.6 and higher (note the
+ // ifdef above only checks if we were *compiled* with 10.6 or
+ // higher; at runtime we have to check if this symbol is defined.)
+ if (malloc_default_purgeable_zone) {
+ malloc_default_purgeable_zone();
+ }
#endif
// Register the tcmalloc zone. At this point, it will not be the
« 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