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

Side by Side Diff: base/allocator/allocator_shim_override_cpp_symbols.h

Issue 2658723007: Hook up allocator shim on mac. (Closed)
Patch Set: Rebase. Created 3 years, 10 months 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_ 5 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_
6 #error This header is meant to be included only once by allocator_shim.cc 6 #error This header is meant to be included only once by allocator_shim.cc
7 #endif 7 #endif
8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_ 8 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_CPP_SYMBOLS_H_
9 9
10 // Alias the default new/delete C++ symbols to the shim entry points. 10 // Alias the default new/delete C++ symbols to the shim entry points.
11 // This file is strongly inspired by tcmalloc's libc_override_redefine.h. 11 // This file is strongly inspired by tcmalloc's libc_override_redefine.h.
12 12
13 #include <new> 13 #include <new>
14 14
15 #include "base/allocator/allocator_shim_internals.h" 15 #include "base/allocator/allocator_shim_internals.h"
16 16
17 #if defined(OS_MACOSX)
Primiano Tucci (use gerrit) 2017/01/28 05:10:02 just checking: do we actually need these? IIRC the
erikchen 2017/01/31 02:21:22 We don't, the implementation of libc++.dylib forwa
18
19 SHIM_ALWAYS_EXPORT void* operator new(size_t size) {
20 return ShimCppNew(size);
21 }
22
23 SHIM_ALWAYS_EXPORT void operator delete(void* ptr)__THROW {
24 return ShimCppDelete(ptr);
25 }
26
27 SHIM_ALWAYS_EXPORT void* operator new[](size_t size) {
28 return ShimCppNew(size);
29 }
30
31 SHIM_ALWAYS_EXPORT void operator delete[](void* ptr) __THROW {
32 return ShimCppDelete(ptr);
33 }
34
35 SHIM_ALWAYS_EXPORT void* operator new(size_t size,
36 const std::nothrow_t&) __THROW {
37 return ShimCppNew(size);
38 }
39
40 SHIM_ALWAYS_EXPORT void* operator new[](size_t size,
41 const std::nothrow_t&) __THROW {
42 return ShimCppNew(size);
43 }
44
45 SHIM_ALWAYS_EXPORT void operator delete(void* ptr,
46 const std::nothrow_t&)__THROW {
47 ShimCppDelete(ptr);
48 }
49
50 SHIM_ALWAYS_EXPORT void operator delete[](void* ptr,
51 const std::nothrow_t&) __THROW {
52 ShimCppDelete(ptr);
53 }
54
55 #else // !OS_MACOSX
56
17 SHIM_ALWAYS_EXPORT void* operator new(size_t size) 57 SHIM_ALWAYS_EXPORT void* operator new(size_t size)
18 SHIM_ALIAS_SYMBOL(ShimCppNew); 58 SHIM_ALIAS_SYMBOL(ShimCppNew);
19 59
20 SHIM_ALWAYS_EXPORT void operator delete(void* p) __THROW 60 SHIM_ALWAYS_EXPORT void operator delete(void* p) __THROW
21 SHIM_ALIAS_SYMBOL(ShimCppDelete); 61 SHIM_ALIAS_SYMBOL(ShimCppDelete);
22 62
23 SHIM_ALWAYS_EXPORT void* operator new[](size_t size) 63 SHIM_ALWAYS_EXPORT void* operator new[](size_t size)
24 SHIM_ALIAS_SYMBOL(ShimCppNew); 64 SHIM_ALIAS_SYMBOL(ShimCppNew);
25 65
26 SHIM_ALWAYS_EXPORT void operator delete[](void* p) __THROW 66 SHIM_ALWAYS_EXPORT void operator delete[](void* p) __THROW
27 SHIM_ALIAS_SYMBOL(ShimCppDelete); 67 SHIM_ALIAS_SYMBOL(ShimCppDelete);
28 68
29 SHIM_ALWAYS_EXPORT void* operator new(size_t size, 69 SHIM_ALWAYS_EXPORT void* operator new(size_t size,
30 const std::nothrow_t&) __THROW 70 const std::nothrow_t&) __THROW
31 SHIM_ALIAS_SYMBOL(ShimCppNew); 71 SHIM_ALIAS_SYMBOL(ShimCppNew);
32 72
33 SHIM_ALWAYS_EXPORT void* operator new[](size_t size, 73 SHIM_ALWAYS_EXPORT void* operator new[](size_t size,
34 const std::nothrow_t&) __THROW 74 const std::nothrow_t&) __THROW
35 SHIM_ALIAS_SYMBOL(ShimCppNew); 75 SHIM_ALIAS_SYMBOL(ShimCppNew);
36 76
37 SHIM_ALWAYS_EXPORT void operator delete(void* p, const std::nothrow_t&) __THROW 77 SHIM_ALWAYS_EXPORT void operator delete(void* p, const std::nothrow_t&) __THROW
38 SHIM_ALIAS_SYMBOL(ShimCppDelete); 78 SHIM_ALIAS_SYMBOL(ShimCppDelete);
39 79
40 SHIM_ALWAYS_EXPORT void operator delete[](void* p, 80 SHIM_ALWAYS_EXPORT void operator delete[](void* p,
41 const std::nothrow_t&) __THROW 81 const std::nothrow_t&) __THROW
42 SHIM_ALIAS_SYMBOL(ShimCppDelete); 82 SHIM_ALIAS_SYMBOL(ShimCppDelete);
83
84 #endif // OS_MACOSX
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698