aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2015-03-29 22:42:55 +0000
committerDmitry V. Levin <ldv@altlinux.org>2015-03-30 00:32:56 +0000
commitc84d0b8363aeec9f89641c180d97902836fb0b6f (patch)
treea3caa23ee3db4b5adfc5a7f1a7196c7cbb704f9f
parent3460dc486d333231998de0f19918204aacee9ae3 (diff)
downloadstrace-c84d0b8363aeec9f89641c180d97902836fb0b6f.tar.gz
Introduce macros for gcc attributes
Define macros for gcc attributes that are already in use or going to be used soon. * defs.h (GNUC_PREREQ, ATTRIBUTE_NORETURN, ATTRIBUTE_FORMAT, ATTRIBUTE_ALIGNED, ATTRIBUTE_PACKED, ATTRIBUTE_MALLOC, ATTRIBUTE_NOINLINE, ATTRIBUTE_ALLOC_SIZE): New macros.
-rw-r--r--defs.h42
1 files changed, 40 insertions, 2 deletions
diff --git a/defs.h b/defs.h
index 1d3d41d9..e1bf7a4d 100644
--- a/defs.h
+++ b/defs.h
@@ -67,8 +67,46 @@ const char *strerror(int);
extern char *stpcpy(char *dst, const char *src);
#endif
-#if !defined __GNUC__
-# define __attribute__(x) /*nothing*/
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define __attribute__(x) /* empty */
+# define GNUC_PREREQ(maj, min) 0
+#endif
+
+#if GNUC_PREREQ(2, 5)
+# define ATTRIBUTE_NORETURN __attribute__((__noreturn__))
+#else
+# define ATTRIBUTE_NORETURN /* empty */
+#endif
+
+#if GNUC_PREREQ(2, 7)
+# define ATTRIBUTE_FORMAT(args) __attribute__((__format__ args))
+# define ATTRIBUTE_ALIGNED(arg) __attribute__((__aligned__(arg)))
+# define ATTRIBUTE_PACKED __attribute__((__packed__))
+#else
+# define ATTRIBUTE_FORMAT(args) /* empty */
+# define ATTRIBUTE_ALIGNED(arg) /* empty */
+# define ATTRIBUTE_PACKED /* empty */
+#endif
+
+#if GNUC_PREREQ(3, 0)
+# define ATTRIBUTE_MALLOC __attribute__((__malloc__))
+#else
+# define ATTRIBUTE_MALLOC /* empty */
+#endif
+
+#if GNUC_PREREQ(3, 1)
+# define ATTRIBUTE_NOINLINE __attribute__((__noinline__))
+#else
+# define ATTRIBUTE_NOINLINE /* empty */
+#endif
+
+#if GNUC_PREREQ(4, 3)
+# define ATTRIBUTE_ALLOC_SIZE(args) __attribute__((__alloc_size__ args))
+#else
+# define ATTRIBUTE_ALLOC_SIZE(args) /* empty */
#endif
#ifndef offsetof