diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-18 21:55:38 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-18 21:55:38 +0000 |
commit | 67ec3c654baf4447d3e8dd85a0edccf3e49dcca2 (patch) | |
tree | 3dd45571b5127f18b51e15cd30792cf08f05d8e0 /base | |
parent | ee2a79e9ed2339cb9548c43ae471b05d6418f2a7 (diff) | |
download | chromium_src-67ec3c654baf4447d3e8dd85a0edccf3e49dcca2.zip chromium_src-67ec3c654baf4447d3e8dd85a0edccf3e49dcca2.tar.gz chromium_src-67ec3c654baf4447d3e8dd85a0edccf3e49dcca2.tar.bz2 |
Move APSL code into third_party.
BUG=none
TEST=unit tested
Review URL: http://codereview.chromium.org/3801013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/DEPS | 1 | ||||
-rw-r--r-- | base/process_util_mac.mm | 71 |
2 files changed, 9 insertions, 63 deletions
@@ -1,4 +1,5 @@ include_rules = [ + "+third_party/apple_apsl", "+third_party/libevent", "+third_party/dmg_fp", "+third_party/GTM", diff --git a/base/process_util_mac.mm b/base/process_util_mac.mm index 0865360..cae47bf 100644 --- a/base/process_util_mac.mm +++ b/base/process_util_mac.mm @@ -30,6 +30,8 @@ #include "base/sys_info.h" #include "base/sys_string_conversions.h" #include "base/time.h" +#include "third_party/apple_apsl/CFBase.h" +#include "third_party/apple_apsl/malloc.h" namespace base { @@ -370,32 +372,6 @@ bool g_oom_killer_enabled; // === C malloc/calloc/valloc/realloc/posix_memalign === -// The extended version of malloc_zone_t from the 10.6 SDK's <malloc/malloc.h>, -// included here to allow for compilation in 10.5. (10.5 has version 3 zone -// allocators, while 10.6 has version 6 allocators.) -struct ChromeMallocZone { - void* reserved1; - void* reserved2; - size_t (*size)(struct _malloc_zone_t* zone, const void* ptr); - void* (*malloc)(struct _malloc_zone_t* zone, size_t size); - void* (*calloc)(struct _malloc_zone_t* zone, size_t num_items, size_t size); - void* (*valloc)(struct _malloc_zone_t* zone, size_t size); - void (*free)(struct _malloc_zone_t* zone, void* ptr); - void* (*realloc)(struct _malloc_zone_t* zone, void* ptr, size_t size); - void (*destroy)(struct _malloc_zone_t* zone); - const char* zone_name; - unsigned (*batch_malloc)(struct _malloc_zone_t* zone, size_t size, - void** results, unsigned num_requested); - void (*batch_free)(struct _malloc_zone_t* zone, void** to_be_freed, - unsigned num_to_be_freed); - struct malloc_introspection_t* introspect; - unsigned version; - void* (*memalign)(struct _malloc_zone_t* zone, size_t alignment, - size_t size); // version >= 5 - void (*free_definite_size)(struct _malloc_zone_t* zone, void* ptr, - size_t size); // version >= 6 -}; - typedef void* (*malloc_type)(struct _malloc_zone_t* zone, size_t size); typedef void* (*calloc_type)(struct _malloc_zone_t* zone, @@ -526,37 +502,6 @@ void oom_killer_new() { // === Core Foundation CFAllocators === -// This is the real structure of a CFAllocatorRef behind the scenes. See -// http://opensource.apple.com/source/CF/CF-476.19/CFBase.c (10.5.8) and -// http://opensource.apple.com/source/CF/CF-550/CFBase.c (10.6) for details. -struct ChromeCFRuntimeBase { - uintptr_t _cfisa; - uint8_t _cfinfo[4]; -#if __LP64__ - uint32_t _rc; -#endif -}; - -struct ChromeCFAllocator { - ChromeCFRuntimeBase cf_runtime_base; - size_t (*size)(struct _malloc_zone_t* zone, const void* ptr); - void* (*malloc)(struct _malloc_zone_t* zone, size_t size); - void* (*calloc)(struct _malloc_zone_t* zone, size_t num_items, size_t size); - void* (*valloc)(struct _malloc_zone_t* zone, size_t size); - void (*free)(struct _malloc_zone_t* zone, void* ptr); - void* (*realloc)(struct _malloc_zone_t* zone, void* ptr, size_t size); - void (*destroy)(struct _malloc_zone_t* zone); - const char* zone_name; - unsigned (*batch_malloc)(struct _malloc_zone_t* zone, size_t size, - void** results, unsigned num_requested); - void (*batch_free)(struct _malloc_zone_t* zone, void** to_be_freed, - unsigned num_to_be_freed); - struct malloc_introspection_t* introspect; - void* reserved5; - - void* allocator; - CFAllocatorContext context; -}; typedef ChromeCFAllocator* ChromeCFAllocatorRef; CFAllocatorAllocateCallBack g_old_cfallocator_system_default; @@ -773,24 +718,24 @@ void EnableTerminationOnOutOfMemory() { if (cf_allocator_internals_known) { ChromeCFAllocatorRef allocator = const_cast<ChromeCFAllocatorRef>( reinterpret_cast<const ChromeCFAllocator*>(kCFAllocatorSystemDefault)); - g_old_cfallocator_system_default = allocator->context.allocate; + g_old_cfallocator_system_default = allocator->_context.allocate; CHECK(g_old_cfallocator_system_default) << "Failed to get kCFAllocatorSystemDefault allocation function."; - allocator->context.allocate = oom_killer_cfallocator_system_default; + allocator->_context.allocate = oom_killer_cfallocator_system_default; allocator = const_cast<ChromeCFAllocatorRef>( reinterpret_cast<const ChromeCFAllocator*>(kCFAllocatorMalloc)); - g_old_cfallocator_malloc = allocator->context.allocate; + g_old_cfallocator_malloc = allocator->_context.allocate; CHECK(g_old_cfallocator_malloc) << "Failed to get kCFAllocatorMalloc allocation function."; - allocator->context.allocate = oom_killer_cfallocator_malloc; + allocator->_context.allocate = oom_killer_cfallocator_malloc; allocator = const_cast<ChromeCFAllocatorRef>( reinterpret_cast<const ChromeCFAllocator*>(kCFAllocatorMallocZone)); - g_old_cfallocator_malloc_zone = allocator->context.allocate; + g_old_cfallocator_malloc_zone = allocator->_context.allocate; CHECK(g_old_cfallocator_malloc_zone) << "Failed to get kCFAllocatorMallocZone allocation function."; - allocator->context.allocate = oom_killer_cfallocator_malloc_zone; + allocator->_context.allocate = oom_killer_cfallocator_malloc_zone; } else { NSLog(@"Internals of CFAllocator not known; out-of-memory failures via " "CFAllocator will not result in termination. http://crbug.com/45650"); |