summaryrefslogtreecommitdiffstats
path: root/include/c.h
diff options
context:
space:
mode:
authorKarel Zak2011-02-07 17:29:47 +0100
committerKarel Zak2011-02-07 17:29:47 +0100
commit40084d0d5c5031580907d61e2df81b5b21af6c68 (patch)
treede96970d47e2bab2691361b596509b152c3f4450 /include/c.h
parentfsck: include c.h, fallback for PATH_MAX (diff)
downloadkernel-qcow2-util-linux-40084d0d5c5031580907d61e2df81b5b21af6c68.tar.gz
kernel-qcow2-util-linux-40084d0d5c5031580907d61e2df81b5b21af6c68.tar.xz
kernel-qcow2-util-linux-40084d0d5c5031580907d61e2df81b5b21af6c68.zip
include: [c.h] add fallback for alloc_size attributes
Reported-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/c.h')
-rw-r--r--include/c.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/include/c.h b/include/c.h
index 02c29e960..f50a338c9 100644
--- a/include/c.h
+++ b/include/c.h
@@ -10,6 +10,15 @@
/*
* Compiler specific stuff
*/
+#ifndef __GNUC_PREREQ
+# if defined __GNUC__ && defined __GNUC_MINOR__
+# define __GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+# else
+# define __GNUC_PREREQ(maj, min) 0
+# endif
+#endif
+
#ifdef __GNUC__
/* &a[0] degrades to a pointer: a different type from an array */
@@ -24,6 +33,24 @@
# define ignore_result(x) ((void) (x))
#endif /* !__GNUC__ */
+/*
+ * Function attributes
+ */
+#ifndef __ul_alloc_size
+# if __GNUC_PREREQ (3, 0)
+# define __ul_alloc_size(s) __attribute__((alloc_size(s)))
+# else
+# define __ul_alloc_size(s)
+# endif
+#endif
+
+#ifndef __ul_calloc_size
+# if __GNUC_PREREQ (3, 0)
+# define __ul_calloc_size(n, s) __attribute__((alloc_size(n, s)))
+# else
+# define __ul_calloc_size(n, s)
+# endif
+#endif
/* Force a compilation error if condition is true, but also produce a
* result (of value 0 and type size_t), so the expression can be used