From 82c318224be1b9c166dc4096bff56bee5008ed2c Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Tue, 31 Jul 2018 21:35:15 +0200 Subject: [PATCH] tlsf: fix for llvm The `__GNUC__` is also available in `clang` as is just used to provide the major version of a GNU-C compatible compiler [[1]]. So I check for `tlsf` if the `alloc_size()` is available by using the combination of macros as proposed here: https://stackoverflow.com/a/43205345/395687 [1]: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html --- pkg/tlsf/contrib/tlsf-malloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/tlsf/contrib/tlsf-malloc.c b/pkg/tlsf/contrib/tlsf-malloc.c index 809e237221..117b560717 100644 --- a/pkg/tlsf/contrib/tlsf-malloc.c +++ b/pkg/tlsf/contrib/tlsf-malloc.c @@ -31,7 +31,9 @@ static tlsf_t gheap = NULL; /* TODO: Add defines for other compilers */ -#ifdef __GNUC__ +#if defined(__GNUC__) && !defined(__clang__) /* Clang supports __GNUC__ but + * not the alloc_size() + * attribute */ #define ATTR_MALLOC __attribute__((malloc, alloc_size(1))) #define ATTR_CALLOC __attribute__((malloc, alloc_size(1,2)))