do not use __builtin_expect with GCC < 2.96
authorStefan Behnel <scoder@users.berlios.de>
Mon, 3 Sep 2007 14:17:12 +0000 (16:17 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Mon, 3 Sep 2007 14:17:12 +0000 (16:17 +0200)
Cython/Compiler/Nodes.py

index 12d440a7f3586c158014f9450a3069a3ba91094d..e43f10cf079297b96dc0f2a86c7ef9d94229990a 100644 (file)
@@ -2647,8 +2647,15 @@ if Options.gcc_branch_hints:
     branch_prediction_macros = \
     """
 #ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 || \
+              (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
 #define likely(x)   __builtin_expect(!!(x), 1)
 #define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
 #else /* __GNUC__ */
 #define likely(x)   (x)
 #define unlikely(x) (x)