summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2010-11-12 09:54:49 +0100
committerLudovic Courtès <ludo@gnu.org>2010-11-19 13:34:43 +0100
commit553d4bf8ea4ca1f844e9f2dd7edcc2ce4ee9fe62 (patch)
tree82cbf406118b869931ed1e4cb92f598793d33b60
parentc9b16ceef7fe382aef3c4d236bdc83901d55d18d (diff)
downloadguile-553d4bf8ea4ca1f844e9f2dd7edcc2ce4ee9fe62.tar.gz
Add `SCM_GNUC_PREREQ'.
* libguile/__scm.h (SCM_GNUC_PREREQ): New macro. Use it in this file in lieu of hand-written GCC version tests.
-rw-r--r--libguile/__scm.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/libguile/__scm.h b/libguile/__scm.h
index 12d1e8afc..efdab6d67 100644
--- a/libguile/__scm.h
+++ b/libguile/__scm.h
@@ -62,6 +62,15 @@
* additional information to the developers.
*/
+/* Return true (non-zero) if GCC version MAJ.MIN or later is being used
+ * (macro taken from glibc.) */
+#if defined __GNUC__ && defined __GNUC_MINOR__
+# define SCM_GNUC_PREREQ(maj, min) \
+ ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
+#else
+# define SCM_GNUC_PREREQ(maj, min) 0
+#endif
+
/* The macro SCM_NORETURN indicates that a function will never return.
* Examples:
* 1) int foo (char arg) SCM_NORETURN;
@@ -89,7 +98,7 @@
/* The SCM_EXPECT macros provide branch prediction hints to the compiler. To
* use only in places where the result of the expression under "normal"
* circumstances is known. */
-#if defined(__GNUC__) && (__GNUC__ >= 3)
+#if SCM_GNUC_PREREQ (3, 0)
# define SCM_EXPECT __builtin_expect
#else
# define SCM_EXPECT(_expr, _value) (_expr)
@@ -108,8 +117,7 @@
* or variables. Defining `SCM_BUILDING_DEPRECATED_CODE' allows deprecated
* functions to be implemented in terms of deprecated functions, and allows
* deprecated functions to be referred to by `scm_c_define_gsubr ()'. */
-#if !defined (SCM_BUILDING_DEPRECATED_CODE) \
- && defined (__GNUC__) && (__GNUC__ >= 3)
+#if !defined (SCM_BUILDING_DEPRECATED_CODE) && SCM_GNUC_PREREQ (3, 0)
# define SCM_DEPRECATED SCM_API __attribute__ ((__deprecated__))
#else
# define SCM_DEPRECATED SCM_API
@@ -129,7 +137,7 @@
/* The SCM_MALLOC macro can be used in function declarations to tell the
* compiler that a function may be treated as if any non-NULL pointer it returns
* cannot alias any other pointer valid when the function returns. */
-#if defined (__GNUC__) && (__GNUC__ >= 3)
+#if SCM_GNUC_PREREQ (3, 0)
# define SCM_MALLOC __attribute__ ((__malloc__))
#else
# define SCM_MALLOC