OLD | NEW |
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 // Its purpose is to SHIM_ALIAS_SYMBOL the Libc symbols for malloc/new to the | 5 // Its purpose is to preempt the Libc symbols for malloc/new so they call the |
6 // shim layer entry points. | 6 // shim layer entry points. |
7 | 7 |
8 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ | 8 #ifdef BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ |
9 #error This header is meant to be included only once by allocator_shim.cc | 9 #error This header is meant to be included only once by allocator_shim.cc |
10 #endif | 10 #endif |
11 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ | 11 #define BASE_ALLOCATOR_ALLOCATOR_SHIM_OVERRIDE_LIBC_SYMBOLS_H_ |
12 | 12 |
13 #include <malloc.h> | 13 #include <malloc.h> |
14 | 14 |
15 #include "base/allocator/allocator_shim_internals.h" | 15 #include "base/allocator/allocator_shim_internals.h" |
16 | 16 |
17 extern "C" { | 17 extern "C" { |
18 | 18 |
19 SHIM_ALWAYS_EXPORT void* malloc(size_t size) __THROW | 19 SHIM_ALWAYS_EXPORT void* malloc(size_t size) __THROW { |
20 SHIM_ALIAS_SYMBOL(ShimMalloc); | 20 return ShimMalloc(size, nullptr); |
| 21 } |
21 | 22 |
22 SHIM_ALWAYS_EXPORT void free(void* ptr) __THROW | 23 SHIM_ALWAYS_EXPORT void free(void* ptr) __THROW { |
23 SHIM_ALIAS_SYMBOL(ShimFree); | 24 ShimFree(ptr, nullptr); |
| 25 } |
24 | 26 |
25 SHIM_ALWAYS_EXPORT void* realloc(void* ptr, size_t size) __THROW | 27 SHIM_ALWAYS_EXPORT void* realloc(void* ptr, size_t size) __THROW { |
26 SHIM_ALIAS_SYMBOL(ShimRealloc); | 28 return ShimRealloc(ptr, size, nullptr); |
| 29 } |
27 | 30 |
28 SHIM_ALWAYS_EXPORT void* calloc(size_t n, size_t size) __THROW | 31 SHIM_ALWAYS_EXPORT void* calloc(size_t n, size_t size) __THROW { |
29 SHIM_ALIAS_SYMBOL(ShimCalloc); | 32 return ShimCalloc(n, size, nullptr); |
| 33 } |
30 | 34 |
31 SHIM_ALWAYS_EXPORT void cfree(void* ptr) __THROW | 35 SHIM_ALWAYS_EXPORT void cfree(void* ptr) __THROW { |
32 SHIM_ALIAS_SYMBOL(ShimFree); | 36 ShimFree(ptr, nullptr); |
| 37 } |
33 | 38 |
34 SHIM_ALWAYS_EXPORT void* memalign(size_t align, size_t s) __THROW | 39 SHIM_ALWAYS_EXPORT void* memalign(size_t align, size_t s) __THROW { |
35 SHIM_ALIAS_SYMBOL(ShimMemalign); | 40 return ShimMemalign(align, s, nullptr); |
| 41 } |
36 | 42 |
37 SHIM_ALWAYS_EXPORT void* valloc(size_t size) __THROW | 43 SHIM_ALWAYS_EXPORT void* valloc(size_t size) __THROW { |
38 SHIM_ALIAS_SYMBOL(ShimValloc); | 44 return ShimValloc(size, nullptr); |
| 45 } |
39 | 46 |
40 SHIM_ALWAYS_EXPORT void* pvalloc(size_t size) __THROW | 47 SHIM_ALWAYS_EXPORT void* pvalloc(size_t size) __THROW { |
41 SHIM_ALIAS_SYMBOL(ShimPvalloc); | 48 return ShimPvalloc(size); |
| 49 } |
42 | 50 |
43 SHIM_ALWAYS_EXPORT int posix_memalign(void** r, size_t a, size_t s) __THROW | 51 SHIM_ALWAYS_EXPORT int posix_memalign(void** r, size_t a, size_t s) __THROW { |
44 SHIM_ALIAS_SYMBOL(ShimPosixMemalign); | 52 return ShimPosixMemalign(r, a, s); |
| 53 } |
45 | 54 |
46 // The default dispatch translation unit has to define also the following | 55 // The default dispatch translation unit has to define also the following |
47 // symbols (unless they are ultimately routed to the system symbols): | 56 // symbols (unless they are ultimately routed to the system symbols): |
48 // void malloc_stats(void); | 57 // void malloc_stats(void); |
49 // int mallopt(int, int); | 58 // int mallopt(int, int); |
50 // struct mallinfo mallinfo(void); | 59 // struct mallinfo mallinfo(void); |
51 // size_t malloc_size(void*); | 60 // size_t malloc_size(void*); |
52 // size_t malloc_usable_size(const void*); | 61 // size_t malloc_usable_size(const void*); |
53 | 62 |
54 } // extern "C" | 63 } // extern "C" |
OLD | NEW |