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> |
11 #include <malloc/malloc.h> | 11 #include <malloc/malloc.h> |
12 #import <objc/runtime.h> | 12 #import <objc/runtime.h> |
| 13 #include <stddef.h> |
13 | 14 |
14 #include <new> | 15 #include <new> |
15 | 16 |
16 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
17 #include "base/logging.h" | 18 #include "base/logging.h" |
18 #include "base/mac/mac_util.h" | 19 #include "base/mac/mac_util.h" |
19 #include "base/mac/mach_logging.h" | 20 #include "base/mac/mach_logging.h" |
20 #include "base/scoped_clear_errno.h" | 21 #include "base/scoped_clear_errno.h" |
| 22 #include "build/build_config.h" |
21 #include "third_party/apple_apsl/CFBase.h" | 23 #include "third_party/apple_apsl/CFBase.h" |
22 #include "third_party/apple_apsl/malloc.h" | 24 #include "third_party/apple_apsl/malloc.h" |
23 | 25 |
24 namespace base { | 26 namespace base { |
25 | 27 |
26 void EnableTerminationOnHeapCorruption() { | 28 void EnableTerminationOnHeapCorruption() { |
27 #if !ARCH_CPU_64_BITS | 29 #if !ARCH_CPU_64_BITS |
28 DLOG(WARNING) << "EnableTerminationOnHeapCorruption only works on 64-bit"; | 30 DLOG(WARNING) << "EnableTerminationOnHeapCorruption only works on 64-bit"; |
29 #endif | 31 #endif |
30 } | 32 } |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 @selector(allocWithZone:)); | 555 @selector(allocWithZone:)); |
554 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( | 556 g_old_allocWithZone = reinterpret_cast<allocWithZone_t>( |
555 method_getImplementation(orig_method)); | 557 method_getImplementation(orig_method)); |
556 CHECK(g_old_allocWithZone) | 558 CHECK(g_old_allocWithZone) |
557 << "Failed to get allocWithZone allocation function."; | 559 << "Failed to get allocWithZone allocation function."; |
558 method_setImplementation(orig_method, | 560 method_setImplementation(orig_method, |
559 reinterpret_cast<IMP>(oom_killer_allocWithZone)); | 561 reinterpret_cast<IMP>(oom_killer_allocWithZone)); |
560 } | 562 } |
561 | 563 |
562 } // namespace base | 564 } // namespace base |
OLD | NEW |