From 7c32232fa187a24520b957edeeb829fe8ab1a5be Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 18 Oct 2015 01:42:14 +0200 Subject: feature-test macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/malloc.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/malloc.h b/include/malloc.h index c2a340b..9ef95a0 100644 --- a/include/malloc.h +++ b/include/malloc.h @@ -21,7 +21,11 @@ #include #ifndef _STDLIB_H -# warning "Do not directly include , include instead." +# if defined(__PORTABLE) +# error "Do not directly include , include instead." +# else +# warning "Do not directly include , include instead." +# endif #endif @@ -145,7 +149,7 @@ void cfree(void*, ...) #endif -#if !defined(__PORTABLE) +#if defined(__GNU_SOURCE) || defined(__SLIBC_SOURCE) /** * Variant of `malloc` that returns an address with a * specified alignment. @@ -176,6 +180,7 @@ void* memalign(size_t, size_t) __GCC_ONLY(__attribute__((__malloc__, __warn_unused_result__))); #endif +#if (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600) /** * `posix_memalign(p, b, n)` is equivalent to * `(*p = memalign(b, n), *p ? 0 : errno)`, except @@ -195,8 +200,9 @@ void* memalign(size_t, size_t) */ int posix_memalign(void**, size_t, size_t) __GCC_ONLY(__attribute__((__nonnull__))); +#endif -#if !defined(__PORTABLE) +#if defined(_BSD_SOURCE) || defined(_XOPEN_SOURCE_EXTENDED) || defined(__SLIBC_SOURCE) /** * `valloc(n)` is equivalent to `memalign(sysconf(_SC_PAGESIZE), n)`. * -- cgit v1.2.3-70-g09d2