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

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

Issue 1523403003: Lock tcmalloc structures in a pthread_atfork hook. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo. Created 5 years 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 (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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 #endif 77 #endif
78 #include <gperftools/tcmalloc.h> 78 #include <gperftools/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 namespace tcmalloc {
88 void CentralCacheLockAll();
89 void CentralCacheUnlockAll();
90 }
91
87 // from AvailabilityMacros.h 92 // from AvailabilityMacros.h
88 #if defined(MAC_OS_X_VERSION_10_6) && \ 93 #if defined(MAC_OS_X_VERSION_10_6) && \
89 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 94 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
90 extern "C" { 95 extern "C" {
91 // This function is only available on 10.6 (and later) but the 96 // This function is only available on 10.6 (and later) but the
92 // LibSystem headers do not use AvailabilityMacros.h to handle weak 97 // LibSystem headers do not use AvailabilityMacros.h to handle weak
93 // importing automatically. This prototype is a copy of the one in 98 // importing automatically. This prototype is a copy of the one in
94 // <malloc/malloc.h> with the WEAK_IMPORT_ATTRBIUTE added. 99 // <malloc/malloc.h> with the WEAK_IMPORT_ATTRBIUTE added.
95 extern malloc_zone_t *malloc_default_purgeable_zone(void) 100 extern malloc_zone_t *malloc_default_purgeable_zone(void)
96 WEAK_IMPORT_ATTRIBUTE; 101 WEAK_IMPORT_ATTRIBUTE;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 MallocExtension::instance()->GetStats(buffer, bufsize); 166 MallocExtension::instance()->GetStats(buffer, bufsize);
162 fprintf(stdout, "%s", buffer); 167 fprintf(stdout, "%s", buffer);
163 delete[] buffer; 168 delete[] buffer;
164 } 169 }
165 170
166 void mi_log(malloc_zone_t *zone, void *address) { 171 void mi_log(malloc_zone_t *zone, void *address) {
167 // I don't think we support anything like this 172 // I don't think we support anything like this
168 } 173 }
169 174
170 void mi_force_lock(malloc_zone_t *zone) { 175 void mi_force_lock(malloc_zone_t *zone) {
171 // Hopefully unneeded by us! 176 tcmalloc::CentralCacheLockAll();
172 } 177 }
173 178
174 void mi_force_unlock(malloc_zone_t *zone) { 179 void mi_force_unlock(malloc_zone_t *zone) {
175 // Hopefully unneeded by us! 180 tcmalloc::CentralCacheUnlockAll();
176 } 181 }
177 182
178 void mi_statistics(malloc_zone_t *zone, malloc_statistics_t *stats) { 183 void mi_statistics(malloc_zone_t *zone, malloc_statistics_t *stats) {
179 // TODO(csilvers): figure out how to fill these out 184 // TODO(csilvers): figure out how to fill these out
180 stats->blocks_in_use = 0; 185 stats->blocks_in_use = 0;
181 stats->size_in_use = 0; 186 stats->size_in_use = 0;
182 stats->max_size_in_use = 0; 187 stats->max_size_in_use = 0;
183 stats->size_allocated = 0; 188 stats->size_allocated = 0;
184 } 189 }
185 190
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 // default zone makes the more recently registered zone the default 271 // default zone makes the more recently registered zone the default
267 // zone. The default zone is then re-registered to ensure that 272 // zone. The default zone is then re-registered to ensure that
268 // allocations made from it earlier will be handled correctly. 273 // 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. 274 // Things are not guaranteed to work that way, but it's how they work now.
270 malloc_zone_t *default_zone = malloc_default_zone(); 275 malloc_zone_t *default_zone = malloc_default_zone();
271 malloc_zone_unregister(default_zone); 276 malloc_zone_unregister(default_zone);
272 malloc_zone_register(default_zone); 277 malloc_zone_register(default_zone);
273 } 278 }
274 279
275 #endif // TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_ 280 #endif // TCMALLOC_LIBC_OVERRIDE_OSX_INL_H_
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/central_freelist.h ('k') | third_party/tcmalloc/chromium/src/static_vars.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698