Arthur de Jong

Open Source / Free Software developer

summaryrefslogtreecommitdiffstats
path: root/compat/attrs.h
diff options
context:
space:
mode:
authorArthur de Jong <arthur@arthurdejong.org>2008-03-30 16:31:46 +0200
committerArthur de Jong <arthur@arthurdejong.org>2008-03-30 16:31:46 +0200
commit799dd39d431189aaf0f836866c6c3c28dee75bf4 (patch)
tree7e29bee9f95b1b8410da824ba56d42754ea43c08 /compat/attrs.h
parentf3d160df2da80a7e49b46594061755b8ffc47276 (diff)
make test for compiler versions simpler and per used attribute
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@647 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'compat/attrs.h')
-rw-r--r--compat/attrs.h44
1 files changed, 27 insertions, 17 deletions
diff --git a/compat/attrs.h b/compat/attrs.h
index b91cc11..492f45c 100644
--- a/compat/attrs.h
+++ b/compat/attrs.h
@@ -28,46 +28,56 @@
/* These are macros to use some gcc-specific flags in case the're available
and otherwise define them to empty strings. This allows us to give
- the compiler some extra information. */
-
-#if GCC_VERSION(3,0) /* gcc >= 3.0 */
+ the compiler some extra information.
+ See http://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html
+ for a list of attributes supported by gcc */
/* this is used to flag function parameters that are not used in the function
body. */
+#if GCC_VERSION(3,0)
#define UNUSED(x) x __attribute__((__unused__))
+#else
+#define UNUSED(x) x
+#endif
/* this is used to add extra format checking to the function calls as if this
was a printf()-like function */
+#if GCC_VERSION(3,0)
#define LIKE_PRINTF(format_idx,arg_idx) \
__attribute__((__format__(__printf__,format_idx,arg_idx)))
+#else
+#define LIKE_PRINTF(format_idx,arg_idx) /* no attribute */
+#endif
/* indicates that the function is "pure": it's result is purely based on
the parameters and has no side effects or used static data */
+#if GCC_VERSION(3,0)
#define PURE __attribute__((__pure__))
+#else
+#define PURE /* no attribute */
+#endif
/* the function returns a new data structure that has been freshly
allocated */
+#if GCC_VERSION(3,0)
#define LIKE_MALLOC __attribute__((__malloc__))
-
-#else /* not gcc >= 3.0 */
-
-#define UNUSED(x) x
-#define LIKE_PRINTF(format_idx,arg_idx) /* no attribute */
-#define PURE /* no attribute */
+#else
#define LIKE_MALLOC /* no attribute */
-
-#endif /* not gcc >= 3.0 */
-
-#if GCC_VERSION(3,4) /* gcc >= 3.4 */
+#endif
/* the function's return value should be used by the caller */
+#if GCC_VERSION(3,4)
#define MUST_USE __attribute__((__warn_unused_result__))
-
-#else /* not gcc >= 3.4 */
-
+#else
#define MUST_USE /* no attribute */
+#endif
-#endif /* not gcc >= 3.4 */
+/* the function's return value should be used by the caller */
+#if GCC_VERSION(2,5)
+#define NORETURN __attribute__((__noreturn__))
+#else
+#define NORETURN /* no attribute */
+#endif
/* define __STRING if it's not yet defined */
#ifndef __STRING