]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fixed to check whether __builtin_expect is supported before using it.
authorTom Hughes <tom@compton.nu>
Mon, 19 Dec 2005 12:40:13 +0000 (12:40 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 19 Dec 2005 12:40:13 +0000 (12:40 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5372

configure.in
memcheck/mc_main.c

index dceba7b3c64cf7653ccc442bdd5f2dd3b1d743cc..68025957895262d03c6415f3cd1b0897ee92f8a9 100644 (file)
@@ -451,6 +451,23 @@ if test x$declaration_after_statement = xyes; then
   CFLAGS="$CFLAGS -Wdeclaration-after-statement"
 fi
 
+# does this compiler support __builtin_expect?
+AC_MSG_CHECKING([if gcc supports __builtin_expect])
+AC_TRY_LINK(, [
+return __builtin_expect(1, 1) ? 1 : 0
+],
+[
+ac_have_builtin_expect=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_builtin_expect=no
+AC_MSG_RESULT([no])
+])
+if test x$ac_have_builtin_expect = xyes ; then
+  AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define to 1 if gcc supports __builtin_expect.])
+fi
+
 
 # Check for TLS support in the compiler and linker
 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
index 91ea81d861db74348cdf4067183cfb200adb20dc..2e14d86cf500f4416c3d70a88860090e564c9894 100644 (file)
 #include "memcheck.h"   /* for client requests */
 
 
+#ifdef HAVE_BUILTIN_EXPECT
 #define EXPECTED_TAKEN(cond)     __builtin_expect((cond),1)
 #define EXPECTED_NOT_TAKEN(cond) __builtin_expect((cond),0)
+#else
+#define EXPECTED_TAKEN(cond)     (cond)
+#define EXPECTED_NOT_TAKEN(cond) (cond)
+#endif
 
 /* Define to debug the mem audit system.  Set to:
       0  no debugging, fast cases are used