com php-src: Move check for __builtin_expect to confi gure: Zend/zend_portability.h acinclude.m4 conf igure.in
| From: | Stanislav Malyshev | Date: | Sun, 22 Mar 2015 16:31:14 +0000 |
| Subject: | com php-src: Move check for __builtin_expect to confi gure: Zend/zend_portability.h acinclude.m4 conf igure.in | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85797@lists.php.net to get a copy of this message | ||
Commit: 017f89e871a8411765b82cecd09c355377f3a8df
Author: Levi Morrison <levim@php.net> Fri, 20 Mar 2015 11:58:58 -0600
Parents: a50e9d87f265f911f9c76ca0e998588be0bd6eac
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=017f89e871a8411765b82cecd09c355377f3a8df
Log:
Move check for __builtin_expect to configure
This allows __builtin_expect to be used more accurately
Changed paths:
M Zend/zend_portability.h
M acinclude.m4
M configure.in
Diff:
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 5c8a21e..0743141 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -257,9 +257,9 @@ char *alloca();
# endif
#endif /* ZEND_DEBUG */
-#if (defined (__GNUC__) && __GNUC__ > 2 ) && !defined(DARWIN) &&
!defined(__hpux) && !defined(_AIX)
-# define EXPECTED(condition) __builtin_expect(!(!(condition)), 1)
-# define UNEXPECTED(condition) __builtin_expect(!(!(condition)), 0)
+#if PHP_HAVE_BUILTIN_EXPECT
+# define EXPECTED(condition) __builtin_expect(!!(condition), 1)
+# define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
#else
# define EXPECTED(condition) (condition)
# define UNEXPECTED(condition) (condition)
diff --git a/acinclude.m4 b/acinclude.m4
index b2220c3..478ea31 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -3031,3 +3031,21 @@ AC_DEFUN([PHP_CHECK_STDINT_TYPES], [
])
AC_DEFINE([PHP_HAVE_STDINT_TYPES], [1], [Checked for stdint types])
])
+
+dnl PHP_CHECK_BUILTIN_EXPECT
+AC_DEFUN([PHP_CHECK_BUILTIN_EXPECT], [
+ AC_MSG_CHECKING([for __builtin_expect])
+
+ AC_TRY_LINK(, [
+ return __builtin_expect(1,1) ? 1 : 0;
+ ], [
+ have_builtin_expect=1
+ AC_MSG_RESULT([yes])
+ ], [
+ have_builtin_expect=0
+ AC_MSG_RESULT([no])
+ ])
+
+ AC_DEFINE([PHP_HAVE_BUILTIN_EXPECT], [$have_builtin_expect], [Whether the compiler supports
__builtin_expect])
+
+])
diff --git a/configure.in b/configure.in
index 06db0a7...8f9844d 100644
--- a/configure.in
+++ b/configure.in
@@ -575,6 +575,9 @@ PHP_CHECK_SIZEOF(ptrdiff_t, 8)
dnl Check stdint types (must be after header check)
PHP_CHECK_STDINT_TYPES
+dnl Check __builtin_expect
+PHP_CHECK_BUILTIN_EXPECT
+
dnl Check for members of the stat structure
AC_STRUCT_ST_BLKSIZE
dnl AC_STRUCT_ST_BLOCKS will screw QNX because fileblocks.o does not exists