Avoid [-Wunknown-attributes] warnings like:
warning: unknown attribute '__alloc_size__' ignored
* lib/xalloc.h: Don't use the __alloc_size__ attribute
with clang, as support has been fully removed as of clang 3.5:
https://github.com/llvm-mirror/clang/commit/
c047507a
* lib/eealloc.h: Likewise.
* lib/pagealign_alloc.h: Likewise.
+2015-04-28 Pádraig Brady <P@draigBrady.com>
+
+ eealloc, pagealign_alloc, xalloc: avoid clang warnings
+ Avoid [-Wunknown-attributes] warnings like:
+ warning: unknown attribute '__alloc_size__' ignored
+ * lib/xalloc.h: Don't use the __alloc_size__ attribute
+ with clang, as support has been fully removed as of clang 3.5:
+ https://github.com/llvm-mirror/clang/commit/c047507a
+ * lib/eealloc.h: Likewise.
+ * lib/pagealign_alloc.h: Likewise.
+
2015-04-27 Paul Eggert <eggert@cs.ucla.edu>
tests: pacify GCC 5.1's stricter printf checking
# define EEALLOC_INLINE _GL_INLINE
#endif
+#if __GNUC__ >= 3
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define _GL_ATTRIBUTE_MALLOC
+#endif
+
+#if ! defined __clang__ && \
+ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
+#else
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
+#endif
+
#if MALLOC_0_IS_NONNULL
# define eemalloc malloc
#else
-# if __GNUC__ >= 3
EEALLOC_INLINE void *eemalloc (size_t n)
- __attribute__ ((__malloc__))
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- __attribute__ ((__alloc_size__ (1)))
-# endif
- ;
-# endif
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
EEALLOC_INLINE void *
eemalloc (size_t n)
{
#if REALLOC_0_IS_NONNULL
# define eerealloc realloc
#else
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
EEALLOC_INLINE void *eerealloc (void *p, size_t n)
- __attribute__ ((__alloc_size__ (2)));
-# endif
+ _GL_ATTRIBUTE_ALLOC_SIZE ((2));
EEALLOC_INLINE void *
eerealloc (void *p, size_t n)
{
# include <stddef.h>
+#if __GNUC__ >= 3
+# define _GL_ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+#else
+# define _GL_ATTRIBUTE_MALLOC
+#endif
+
+#if ! defined __clang__ && \
+ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
+#else
+# define _GL_ATTRIBUTE_ALLOC_SIZE(args)
+#endif
+
/* Allocate a block of memory of SIZE bytes, aligned on a system page
boundary.
If SIZE is not a multiple of the system page size, it will be rounded up
Return a pointer to the start of the memory block. Upon allocation failure,
return NULL and set errno. */
extern void *pagealign_alloc (size_t size)
-# if __GNUC__ >= 3
- __attribute__ ((__malloc__))
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- __attribute__ ((__alloc_size__ (1)))
-# endif
-# endif
- ;
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
/* Like pagealign_alloc, except it exits the program if the allocation
fails. */
extern void *pagealign_xalloc (size_t size)
-# if __GNUC__ >= 3
- __attribute__ ((__malloc__))
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
- __attribute__ ((__alloc_size__ (1)))
-# endif
-# endif
- ;
+ _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_ALLOC_SIZE ((1));
/* Free a memory block.
PTR must be a non-NULL pointer returned by pagealign_alloc or
# define _GL_ATTRIBUTE_MALLOC
#endif
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
+#if ! defined __clang__ && \
+ (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define _GL_ATTRIBUTE_ALLOC_SIZE(args) __attribute__ ((__alloc_size__ args))
#else
# define _GL_ATTRIBUTE_ALLOC_SIZE(args)