Index: third_party/tcmalloc/chromium/src/tcmalloc.cc.diff |
diff --git a/third_party/tcmalloc/chromium/src/tcmalloc.cc.diff b/third_party/tcmalloc/chromium/src/tcmalloc.cc.diff |
new file mode 100644 |
index 0000000000000000000000000000000000000000..b6d0be9890bb31f07e1cfd692d38cc2aeb1af129 |
--- /dev/null |
+++ b/third_party/tcmalloc/chromium/src/tcmalloc.cc.diff |
@@ -0,0 +1,79 @@ |
+*** tcmalloc.cc 2011-05-20 06:37:12.709479000 +0900 |
+--- tcmalloc.cc 2011-10-14 15:06:18.703743455 +0900 |
+*************** |
+*** 287,292 **** |
+ // them. In that case, we don't want to do this overriding here. |
+ #if !defined(WIN32_DO_PATCHING) |
+ |
+ #if defined(__GNUC__) && !defined(__MACH__) |
+ // Potentially faster variants that use the gcc alias extension. |
+ // FreeBSD does support aliases, but apparently not correctly. :-( |
+--- 300,309 ---- |
+ // them. In that case, we don't want to do this overriding here. |
+ #if !defined(WIN32_DO_PATCHING) |
+ |
++ // TODO(mbelshe): Turn off TCMalloc's symbols for libc. We do that |
++ // elsewhere. |
++ #ifndef _WIN32 |
++ |
+ #if defined(__GNUC__) && !defined(__MACH__) |
+ // Potentially faster variants that use the gcc alias extension. |
+ // FreeBSD does support aliases, but apparently not correctly. :-( |
+*************** |
+*** 397,402 **** |
+ } // extern "C" |
+ #endif // ifdef __GLIBC__ |
+ |
+ #undef ALIAS |
+ |
+ #endif // #ifndef(WIN32_DO_PATCHING) |
+--- 414,448 ---- |
+ } // extern "C" |
+ #endif // ifdef __GLIBC__ |
+ |
++ #if defined(__GLIBC__) && defined(HAVE_MALLOC_H) |
++ // If we're using glibc, then override glibc malloc hooks to make sure that even |
++ // if calls fall through to ptmalloc (due to dlopen() with RTLD_DEEPBIND or what |
++ // not), ptmalloc will use TCMalloc. |
++ |
++ static void* tc_ptmalloc_malloc_hook(size_t size, const void* caller) { |
++ return tc_malloc(size); |
++ } |
++ |
++ void* (*__MALLOC_HOOK_VOLATILE __malloc_hook)( |
++ size_t size, const void* caller) = tc_ptmalloc_malloc_hook; |
++ |
++ static void* tc_ptmalloc_realloc_hook( |
++ void* ptr, size_t size, const void* caller) { |
++ return tc_realloc(ptr, size); |
++ } |
++ |
++ void* (*__MALLOC_HOOK_VOLATILE __realloc_hook)( |
++ void* ptr, size_t size, const void* caller) = tc_ptmalloc_realloc_hook; |
++ |
++ static void tc_ptmalloc_free_hook(void* ptr, const void* caller) { |
++ tc_free(ptr); |
++ } |
++ |
++ void (*__MALLOC_HOOK_VOLATILE __free_hook)(void* ptr, const void* caller) = tc_ptmalloc_free_hook; |
++ |
++ #endif |
++ |
++ #endif // #ifndef _WIN32 |
+ #undef ALIAS |
+ |
+ #endif // #ifndef(WIN32_DO_PATCHING) |
+*************** |
+*** 1729,1734 **** |
+ MallocHook::InvokeNewHook(result, size); |
+ return result; |
+ } |
+! void *(*__memalign_hook)(size_t, size_t, const void *) = MemalignOverride; |
+! |
+ #endif // TCMALLOC_USING_DEBUGALLOCATION |
+--- 1800,1804 ---- |
+ MallocHook::InvokeNewHook(result, size); |
+ return result; |
+ } |
+! void *(*__MALLOC_HOOK_VOLATILE __memalign_hook)(size_t, size_t, const void *) = MemalignOverride; |
+ #endif // TCMALLOC_USING_DEBUGALLOCATION |