OSDN Git Service

* build fix
authorfche <fche>
Mon, 5 Mar 2001 19:50:30 +0000 (19:50 +0000)
committerfche <fche>
Mon, 5 Mar 2001 19:50:30 +0000 (19:50 +0000)
2001-03-05  Frank Ch. Eigler  <fche@redhat.com>

        On advice from Momchil Velikov <velco@fadata.bg>:
* configure.in: Test for compiler support of __builtin_expect.
* sidconfig.h: Define LIKELY/UNLIKEY depending on this test.
* configure, sidconfutil.in: Regenerated.

sid/include/ChangeLog
sid/include/configure
sid/include/configure.in
sid/include/sidconfig.h
sid/include/sidconfutil.in

index 46d5288..0fd1a9a 100644 (file)
@@ -1,3 +1,10 @@
+2001-03-05  Frank Ch. Eigler  <fche@redhat.com>
+
+        On advice from Momchil Velikov <velco@fadata.bg>:
+       * configure.in: Test for compiler support of __builtin_expect.
+       * sidconfig.h: Define LIKELY/UNLIKEY depending on this test.
+       * configure, sidconfutil.in: Regenerated.
+
 2001-03-01  Frank Ch. Eigler  <fche@redhat.com>
 
        * sidconfig.h (LIKELY, UNLIKELY): New conditional cover macros
index f8e4e92..8df72f1 100755 (executable)
@@ -1273,8 +1273,44 @@ EOF
 fi
 echo "$ac_t""$sid_cv_cctype_std" 1>&6
                
+echo $ac_n "checking whether __builtin_expect is supported""... $ac_c" 1>&6
+echo "configure:1278: checking whether __builtin_expect is supported" >&5
+if eval "test \"`echo '$''{'sid_cv_builtin_expect'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 1283 "configure"
+#include "confdefs.h"
 
+int main() {
 
+  if (__builtin_expect (2, 2))
+    return 0; 
+  else
+    return 1;
+
+; return 0; }
+EOF
+if { (eval echo configure:1295: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+  rm -rf conftest*
+  sid_cv_builtin_expect="yes"
+else
+  echo "configure: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  sid_cv_builtin_expect="no"
+fi
+rm -f conftest*
+fi
+
+if test "${sid_cv_builtin_expect}" = "yes"; then
+       cat >> confdefs.h <<\EOF
+#define HAVE_BUILTIN_EXPECT 1
+EOF
+
+fi
+echo "$ac_t""$sid_cv_builtin_expect" 1>&6
+               
 
 trap '' 1 2 15
 cat > confcache <<\EOF
index 6cac6fb..ebb725f 100644 (file)
@@ -45,8 +45,19 @@ if test "${sid_cv_cctype_std}" = "yes"; then
 fi
 AC_MSG_RESULT([$sid_cv_cctype_std])
                
-
-
+AC_MSG_CHECKING([whether __builtin_expect is supported])
+AC_CACHE_VAL(sid_cv_builtin_expect,
+       AC_TRY_COMPILE([],[
+  if (__builtin_expect (2, 2))
+    return 0; 
+  else
+    return 1;
+],[sid_cv_builtin_expect="yes"],[sid_cv_builtin_expect="no"]))
+if test "${sid_cv_builtin_expect}" = "yes"; then
+       AC_DEFINE(HAVE_BUILTIN_EXPECT, 1, [Define if compiler supports __builtin_expect])
+fi
+AC_MSG_RESULT([$sid_cv_builtin_expect])
+               
 
 dnl Outputs
 AC_OUTPUT(Makefile)
index ea292bc..0c02e77 100644 (file)
@@ -11,9 +11,7 @@
 #undef VERSION
 #include <sidconfutil.h>
 
-// Globally useful macros
-
-#ifdef __GNUC__
+#if HAVE_BUILTIN_EXPECT
 #define LIKELY(expression) (__builtin_expect(!!(expression), 1))
 #define UNLIKELY(expression) (__builtin_expect(!!(expression), 0))
 #else
index 42dcc08..49fc9bb 100644 (file)
@@ -30,3 +30,6 @@
 /* Define if std:: prefix works for <cctype> functions */
 #undef STD_CCTYPE
 
+/* Define if compiler supports __builtin_expect */
+#undef HAVE_BUILTIN_EXPECT
+