|
14 | 14 | limitations under the License.
|
15 | 15 | */
|
16 | 16 |
|
| 17 | +#ifdef __GNUC__ |
| 18 | +# if __GNUC__ >= 12 |
| 19 | +# define TBB_ALIAS(x) __attribute__((alias(#x), copy(x))) |
| 20 | +# endif |
| 21 | +#endif |
| 22 | + |
| 23 | +#ifndef TBB_ALIAS |
| 24 | +# define TBB_ALIAS(x) __attribute__((alias(#x))) |
| 25 | +#endif |
| 26 | + |
17 | 27 | #if __linux__ && !__ANDROID__
|
18 | 28 | // include <bits/c++config.h> indirectly so that <cstdlib> is not included
|
19 | 29 | #include <cstddef>
|
@@ -146,7 +156,7 @@ static inline void initPageSize()
|
146 | 156 | 1) detection that the proxy library is loaded
|
147 | 157 | 2) check that dlsym("malloc") found something different from our replacement malloc
|
148 | 158 | */
|
149 |
| -extern "C" void *__TBB_malloc_proxy(size_t) __attribute__ ((alias ("malloc"))); |
| 159 | +extern "C" void *__TBB_malloc_proxy(size_t) TBB_ALIAS(malloc); |
150 | 160 |
|
151 | 161 | static void *orig_msize;
|
152 | 162 |
|
@@ -285,19 +295,19 @@ struct mallinfo mallinfo() __THROW
|
285 | 295 | // Android doesn't have malloc_usable_size, provide it to be compatible
|
286 | 296 | // with Linux, in addition overload dlmalloc_usable_size() that presented
|
287 | 297 | // under Android.
|
288 |
| -size_t dlmalloc_usable_size(const void *ptr) __attribute__ ((alias ("malloc_usable_size"))); |
| 298 | +size_t dlmalloc_usable_size(const void *ptr) TBB_ALIAS(malloc_usable_size); |
289 | 299 | #else // __ANDROID__
|
290 | 300 | // C11 function, supported starting GLIBC 2.16
|
291 |
| -void *aligned_alloc(size_t alignment, size_t size) __attribute__ ((alias ("memalign"))); |
| 301 | +void *aligned_alloc(size_t alignment, size_t size) TBB_ALIAS(memalign); |
292 | 302 | // Those non-standard functions are exported by GLIBC, and might be used
|
293 | 303 | // in conjunction with standard malloc/free, so we must ovberload them.
|
294 | 304 | // Bionic doesn't have them. Not removing from the linker scripts,
|
295 | 305 | // as absent entry points are ignored by the linker.
|
296 |
| -void *__libc_malloc(size_t size) __attribute__ ((alias ("malloc"))); |
297 |
| -void *__libc_calloc(size_t num, size_t size) __attribute__ ((alias ("calloc"))); |
298 |
| -void *__libc_memalign(size_t alignment, size_t size) __attribute__ ((alias ("memalign"))); |
299 |
| -void *__libc_pvalloc(size_t size) __attribute__ ((alias ("pvalloc"))); |
300 |
| -void *__libc_valloc(size_t size) __attribute__ ((alias ("valloc"))); |
| 306 | +void *__libc_malloc(size_t size) TBB_ALIAS(malloc); |
| 307 | +void *__libc_calloc(size_t num, size_t size) TBB_ALIAS(calloc); |
| 308 | +void *__libc_memalign(size_t alignment, size_t size) TBB_ALIAS(memalign); |
| 309 | +void *__libc_pvalloc(size_t size) TBB_ALIAS(pvalloc); |
| 310 | +void *__libc_valloc(size_t size) TBB_ALIAS(valloc); |
301 | 311 |
|
302 | 312 | // call original __libc_* to support naive replacement of free via __libc_free etc
|
303 | 313 | void __libc_free(void *ptr)
|
|
0 commit comments