[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] eealloc, pagealign_alloc, xalloc: avoid clang warnings
From: |
Pádraig Brady |
Subject: |
[PATCH] eealloc, pagealign_alloc, xalloc: avoid clang warnings |
Date: |
Tue, 28 Apr 2015 22:54:38 +0100 |
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.
---
ChangeLog | 11 +++++++++++
lib/eealloc.h | 25 +++++++++++++++----------
lib/pagealign_alloc.h | 29 +++++++++++++++--------------
lib/xalloc.h | 3 ++-
4 files changed, 43 insertions(+), 25 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fcc6383..6d9ba2c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2015-04-28 Pádraig Brady <address@hidden>
+
+ 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 <address@hidden>
tests: pacify GCC 5.1's stricter printf checking
diff --git a/lib/eealloc.h b/lib/eealloc.h
index ab2faa0..1029014 100644
--- a/lib/eealloc.h
+++ b/lib/eealloc.h
@@ -39,17 +39,24 @@ _GL_INLINE_HEADER_BEGIN
# 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)
{
@@ -63,10 +70,8 @@ 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)
{
diff --git a/lib/pagealign_alloc.h b/lib/pagealign_alloc.h
index 1fbbf08..acdadc4 100644
--- a/lib/pagealign_alloc.h
+++ b/lib/pagealign_alloc.h
@@ -20,6 +20,19 @@
# 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
@@ -27,24 +40,12 @@
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
diff --git a/lib/xalloc.h b/lib/xalloc.h
index 68f847a..81ef680 100644
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -41,7 +41,8 @@ extern "C" {
# 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)
--
2.3.4
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] eealloc, pagealign_alloc, xalloc: avoid clang warnings,
Pádraig Brady <=