OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/process/memory.h" | 5 #include "base/process/memory.h" |
6 | 6 |
7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <mach/mach.h> | 9 #include <mach/mach.h> |
10 #include <mach/mach_vm.h> | 10 #include <mach/mach_vm.h> |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 | 245 |
246 #if !defined(ADDRESS_SANITIZER) | 246 #if !defined(ADDRESS_SANITIZER) |
247 | 247 |
248 // === Core Foundation CFAllocators === | 248 // === Core Foundation CFAllocators === |
249 | 249 |
250 bool CanGetContextForCFAllocator() { | 250 bool CanGetContextForCFAllocator() { |
251 return !base::mac::IsOSLaterThanElCapitan_DontCallThis(); | 251 return !base::mac::IsOSLaterThanElCapitan_DontCallThis(); |
252 } | 252 } |
253 | 253 |
254 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { | 254 CFAllocatorContext* ContextForCFAllocator(CFAllocatorRef allocator) { |
255 if (base::mac::IsOSLion() || base::mac::IsOSMountainLion() || | 255 if (base::mac::IsOSMountainLion() || |
256 base::mac::IsOSMavericks() || base::mac::IsOSYosemite() || | 256 base::mac::IsOSMavericks() || base::mac::IsOSYosemite() || |
257 base::mac::IsOSElCapitan()) { | 257 base::mac::IsOSElCapitan()) { |
258 ChromeCFAllocatorLions* our_allocator = | 258 ChromeCFAllocatorLions* our_allocator = |
259 const_cast<ChromeCFAllocatorLions*>( | 259 const_cast<ChromeCFAllocatorLions*>( |
260 reinterpret_cast<const ChromeCFAllocatorLions*>(allocator)); | 260 reinterpret_cast<const ChromeCFAllocatorLions*>(allocator)); |
261 return &our_allocator->_context; | 261 return &our_allocator->_context; |
262 } else { | 262 } else { |
263 return NULL; | 263 return NULL; |
264 } | 264 } |
265 } | 265 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 @selector(allocWithZone:)); | 548 @selector(allocWithZone:)); |
549 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( | 549 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( |
550 method_getImplementation(orig_method)); | 550 method_getImplementation(orig_method)); |
551 CHECK(g_old_allocWithZone) | 551 CHECK(g_old_allocWithZone) |
552 << "Failed to get allocWithZone allocation function."; | 552 << "Failed to get allocWithZone allocation function."; |
553 method_setImplementation(orig_method, | 553 method_setImplementation(orig_method, |
554 reinterpret_cast<IMP>(oom_killer_allocWithZone)); | 554 reinterpret_cast<IMP>(oom_killer_allocWithZone)); |
555 } | 555 } |
556 | 556 |
557 } // namespace base | 557 } // namespace base |
OLD | NEW |