Skip to content

Commit 22e579e

Browse files
committed
avoid attribute warnigns
1 parent 94d6585 commit 22e579e

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

src/tbb/src/tbbmalloc/proxy.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@
1414
limitations under the License.
1515
*/
1616

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+
1727
#if __linux__ && !__ANDROID__
1828
// include <bits/c++config.h> indirectly so that <cstdlib> is not included
1929
#include <cstddef>
@@ -146,7 +156,7 @@ static inline void initPageSize()
146156
1) detection that the proxy library is loaded
147157
2) check that dlsym("malloc") found something different from our replacement malloc
148158
*/
149-
extern "C" void *__TBB_malloc_proxy(size_t) __attribute__ ((alias ("malloc")));
159+
extern "C" void *__TBB_malloc_proxy(size_t) TBB_ALIAS(malloc);
150160

151161
static void *orig_msize;
152162

@@ -285,19 +295,19 @@ struct mallinfo mallinfo() __THROW
285295
// Android doesn't have malloc_usable_size, provide it to be compatible
286296
// with Linux, in addition overload dlmalloc_usable_size() that presented
287297
// 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);
289299
#else // __ANDROID__
290300
// 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);
292302
// Those non-standard functions are exported by GLIBC, and might be used
293303
// in conjunction with standard malloc/free, so we must ovberload them.
294304
// Bionic doesn't have them. Not removing from the linker scripts,
295305
// 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);
301311

302312
// call original __libc_* to support naive replacement of free via __libc_free etc
303313
void __libc_free(void *ptr)

0 commit comments

Comments
 (0)