Check them in autoconf

This commit is contained in:
Xinchen Hui 2016-08-11 19:57:30 +08:00
parent afd11643c3
commit 75017520c3
4 changed files with 144 additions and 12 deletions

View File

@ -24,7 +24,7 @@
#ifndef ZEND_MULTIPLY_H
#define ZEND_MULTIPLY_H
#if __has_builtin(__builtin_smull_overflow) && SIZEOF_LONG == SIZEOF_ZEND_LONG
#if PHP_HAVE_BUILTIN_SMULL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long __tmpvar; \
@ -34,7 +34,7 @@
else (lval) = __tmpvar; \
} while (0)
#elif __has_builtin(__builtin_smulll_overflow) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#elif PHP_HAVE_BUILTIN_SMULLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#define ZEND_SIGNED_MULTIPLY_LONG(a, b, lval, dval, usedval) do { \
long long __tmpvar; \

View File

@ -445,7 +445,7 @@ ZEND_API void zend_update_current_locale(void);
static zend_always_inline void fast_long_increment_function(zval *op1)
{
#if __has_builtin(__builtin_saddl_overflow) && SIZEOF_LONG == SIZEOF_ZEND_LONG
#if PHP_HAVE_BUILTIN_SADDL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
/* switch to double */
@ -453,7 +453,7 @@ static zend_always_inline void fast_long_increment_function(zval *op1)
} else {
Z_LVAL_P(op1) = lresult;
}
#elif __has_builtin(__builtin_saddll_overflow) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#elif PHP_HAVE_BUILTIN_SADDLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_saddll_overflow(Z_LVAL_P(op1), 1, &llresult))) {
/* switch to double */
@ -499,7 +499,7 @@ static zend_always_inline void fast_long_increment_function(zval *op1)
static zend_always_inline void fast_long_decrement_function(zval *op1)
{
#if __has_builtin(__builtin_ssubl_overflow) && SIZEOF_LONG == SIZEOF_ZEND_LONG
#if PHP_HAVE_BUILTIN_SSUBL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
/* switch to double */
@ -507,7 +507,7 @@ static zend_always_inline void fast_long_decrement_function(zval *op1)
} else {
Z_LVAL_P(op1) = lresult;
}
#elif __has_builtin(__builtin_ssubll_overflow) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#elif PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_ssubll_overflow(Z_LVAL_P(op1), 1, &llresult))) {
/* switch to double */
@ -553,16 +553,16 @@ static zend_always_inline void fast_long_decrement_function(zval *op1)
static zend_always_inline void fast_long_add_function(zval *result, zval *op1, zval *op2)
{
#if __has_builtin(__builtin_saddl_overflow) && SIZEOF_LONG == SIZEOF_ZEND_LONG
#if PHP_HAVE_BUILTIN_SADDL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, lresult);
}
#elif __has_builtin(__builtin_saddll_overflow) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#elif PHP_HAVE_BUILTIN_SADDL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &llresult))) {
if (UNEXPECTED(__builtin_saddll_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &llresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, llresult);
@ -653,16 +653,16 @@ static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *o
static zend_always_inline void fast_long_sub_function(zval *result, zval *op1, zval *op2)
{
#if __has_builtin(__builtin_ssubl_overflow) && SIZEOF_LONG == SIZEOF_ZEND_LONG
#if PHP_HAVE_BUILTIN_SSUBL_OVERFLOW && SIZEOF_LONG == SIZEOF_ZEND_LONG
long lresult;
if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, lresult);
}
#elif __has_builtin(__builtin_ssubll_overflow) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
#elif PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG
long long llresult;
if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &llresult))) {
if (UNEXPECTED(__builtin_ssubll_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &llresult))) {
ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
} else {
ZVAL_LONG(result, llresult);

View File

@ -3111,3 +3111,123 @@ AC_DEFUN([PHP_CHECK_BUILTIN_CTZLL], [
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_CTZLL], [$have_builtin_ctzll], [Whether the compiler supports __builtin_ctzll])
])
dnl PHP_CHECK_BUILTIN_SMULL_OVERFLOW
AC_DEFUN([PHP_CHECK_BUILTIN_SMULL_OVERFLOW], [
AC_MSG_CHECKING([for __builtin_smull_overflow])
AC_TRY_LINK(, [
long tmpvar;
return __builtin_smull_overflow(3, 7, &tmpvar);
], [
have_builtin_smull_overflow=1
AC_MSG_RESULT([yes])
], [
have_builtin_smull_overflow=0
AC_MSG_RESULT([no])
])
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULL_OVERFLOW],
[$have_builtin_smull_overflow], [Whether the compiler supports __builtin_smull_overflow])
])
dnl PHP_CHECK_BUILTIN_SMULLL_OVERFLOW
AC_DEFUN([PHP_CHECK_BUILTIN_SMULLL_OVERFLOW], [
AC_MSG_CHECKING([for __builtin_smulll_overflow])
AC_TRY_LINK(, [
long long tmpvar;
return __builtin_smulll_overflow(3, 7, &tmpvar);
], [
have_builtin_smulll_overflow=1
AC_MSG_RESULT([yes])
], [
have_builtin_smulll_overflow=0
AC_MSG_RESULT([no])
])
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SMULLL_OVERFLOW],
[$have_builtin_smulll_overflow], [Whether the compiler supports __builtin_smulll_overflow])
])
dnl PHP_CHECK_BUILTIN_SADDL_OVERFLOW
AC_DEFUN([PHP_CHECK_BUILTIN_SADDL_OVERFLOW], [
AC_MSG_CHECKING([for __builtin_saddl_overflow])
AC_TRY_LINK(, [
long tmpvar;
return __builtin_saddl_overflow(3, 7, &tmpvar);
], [
have_builtin_saddl_overflow=1
AC_MSG_RESULT([yes])
], [
have_builtin_saddl_overflow=0
AC_MSG_RESULT([no])
])
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDL_OVERFLOW],
[$have_builtin_saddl_overflow], [Whether the compiler supports __builtin_saddl_overflow])
])
dnl PHP_CHECK_BUILTIN_SADDLLL_OVERFLOW
AC_DEFUN([PHP_CHECK_BUILTIN_SADDLL_OVERFLOW], [
AC_MSG_CHECKING([for __builtin_saddll_overflow])
AC_TRY_LINK(, [
long long tmpvar;
return __builtin_saddll_overflow(3, 7, &tmpvar);
], [
have_builtin_saddll_overflow=1
AC_MSG_RESULT([yes])
], [
have_builtin_saddll_overflow=0
AC_MSG_RESULT([no])
])
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SADDLLL_OVERFLOW],
[$have_builtin_saddll_overflow], [Whether the compiler supports __builtin_saddll_overflow])
])
dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW
AC_DEFUN([PHP_CHECK_BUILTIN_SSUBL_OVERFLOW], [
AC_MSG_CHECKING([for __builtin_ssubl_overflow])
AC_TRY_LINK(, [
long tmpvar;
return __builtin_ssubl_overflow(3, 7, &tmpvar);
], [
have_builtin_ssubl_overflow=1
AC_MSG_RESULT([yes])
], [
have_builtin_ssubl_overflow=0
AC_MSG_RESULT([no])
])
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBL_OVERFLOW],
[$have_builtin_ssubl_overflow], [Whether the compiler supports __builtin_ssubl_overflow])
])
dnl PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW
AC_DEFUN([PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW], [
AC_MSG_CHECKING([for __builtin_ssubll_overflow])
AC_TRY_LINK(, [
long long tmpvar;
return __builtin_ssubll_overflow(3, 7, &tmpvar);
], [
have_builtin_ssubll_overflow=1
AC_MSG_RESULT([yes])
], [
have_builtin_ssubll_overflow=0
AC_MSG_RESULT([no])
])
AC_DEFINE_UNQUOTED([PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW],
[$have_builtin_ssubll_overflow], [Whether the compiler supports __builtin_ssubll_overflow])
])

View File

@ -583,6 +583,18 @@ dnl Check __builtin_ctzl
PHP_CHECK_BUILTIN_CTZL
dnl Check __builtin_ctzll
PHP_CHECK_BUILTIN_CTZLL
dnl Check __builtin_smull_overflow
PHP_CHECK_BUILTIN_SMULL_OVERFLOW
dnl Check __builtin_smulll_overflow
PHP_CHECK_BUILTIN_SMULLL_OVERFLOW
dnl Check __builtin_saddl_overflow
PHP_CHECK_BUILTIN_SADDL_OVERFLOW
dnl Check __builtin_saddll_overflow
PHP_CHECK_BUILTIN_SADDLL_OVERFLOW
dnl Check __builtin_ssubl_overflow
PHP_CHECK_BUILTIN_SSUBL_OVERFLOW
dnl Check __builtin_ssubll_overflow
PHP_CHECK_BUILTIN_SSUBLL_OVERFLOW
dnl Check for members of the stat structure
AC_STRUCT_ST_BLKSIZE