diff --git a/Zend/zend_config.w32.h b/Zend/zend_config.w32.h index 47cdf6af8ce81..a44a8b9f70d24 100644 --- a/Zend/zend_config.w32.h +++ b/Zend/zend_config.w32.h @@ -36,6 +36,7 @@ #include #include +#include #include #define strcasecmp(s1, s2) _stricmp(s1, s2) diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index f8c901b149806..7ed441965ed5c 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -579,6 +579,22 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL } else { Z_LVAL_P(op1) = llresult; } +#elif defined(ZEND_WIN32) && SIZEOF_LONG == SIZEOF_ZEND_LONG + long lresult; + if (UNEXPECTED(FAILED(LongAdd(Z_LVAL_P(op1), 1, &lresult)))) { + /* switch to double */ + ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0); + } else { + Z_LVAL_P(op1) = lresult; + } +#elif defined(ZEND_WIN32) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG + long long llresult; + if (UNEXPECTED(FAILED(LongLongAdd(Z_LVAL_P(op1), 1, &llresult)))) { + /* switch to double */ + ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0); + } else { + Z_LVAL_P(op1) = llresult; + } #else if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MAX)) { /* switch to double */ @@ -642,6 +658,22 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL } else { Z_LVAL_P(op1) = llresult; } +#elif defined(ZEND_WIN32) && SIZEOF_LONG == SIZEOF_ZEND_LONG + long lresult; + if (UNEXPECTED(FAILED(LongSub(Z_LVAL_P(op1), 1, &lresult)))) { + /* switch to double */ + ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0); + } else { + Z_LVAL_P(op1) = lresult; + } +#elif defined(ZEND_WIN32) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG + long long llresult; + if (UNEXPECTED(FAILED(LongLongSub(Z_LVAL_P(op1), 1, &llresult)))) { + /* switch to double */ + ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0); + } else { + Z_LVAL_P(op1) = llresult; + } #else if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MIN)) { /* switch to double */ @@ -724,6 +756,20 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL } else { ZVAL_LONG(result, llresult); } +#elif defined(ZEND_WIN32) && SIZEOF_LONG == SIZEOF_ZEND_LONG + long lresult; + if (UNEXPECTED(FAILED(LongAdd(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 defined(ZEND_WIN32) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG + long long llresult; + if (UNEXPECTED(FAILED(LongLongAdd(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); + } #else /* * 'result' may alias with op1 or op2, so we need to @@ -812,6 +858,20 @@ overflow: ZEND_ATTRIBUTE_COLD_LABEL } else { ZVAL_LONG(result, llresult); } +#elif defined(ZEND_WIN32) && SIZEOF_LONG == SIZEOF_ZEND_LONG + long lresult; + if (UNEXPECTED(FAILED(LongSub(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 defined(ZEND_WIN32) && SIZEOF_LONG_LONG == SIZEOF_ZEND_LONG + long long llresult; + if (UNEXPECTED(FAILED(LongLongSub(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); + } #else ZVAL_LONG(result, Z_LVAL_P(op1) - Z_LVAL_P(op2)); diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h index db7b730ead40d..a62c152ffab3e 100644 --- a/ext/pdo_firebird/php_pdo_firebird_int.h +++ b/ext/pdo_firebird/php_pdo_firebird_int.h @@ -33,8 +33,6 @@ #define PDO_FB_DEF_TIME_FMT "%H:%M:%S" #define PDO_FB_DEF_TIMESTAMP_FMT PDO_FB_DEF_DATE_FMT " " PDO_FB_DEF_TIME_FMT -#define SHORT_MAX (1 << (8*sizeof(short)-1)) - #if SIZEOF_ZEND_LONG == 8 && !defined(PHP_WIN32) # define LL_LIT(lit) lit ## L #else diff --git a/win32/build/config.w32 b/win32/build/config.w32 index 70e50891964b0..d2f8a611180e3 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -370,6 +370,10 @@ if (VS_TOOLSET) { } } } else if (CLANG_TOOLSET) { + AC_DEFINE("PHP_HAVE_BUILTIN_SADDL_OVERFLOW", 1, "Define to 1 if the compiler supports '__builtin_saddl_overflow'."); + AC_DEFINE("PHP_HAVE_BUILTIN_SADDLL_OVERFLOW", 1, "Define to 1 if the compiler supports '__builtin_saddll_overflow'."); + AC_DEFINE("PHP_HAVE_BUILTIN_SSUBL_OVERFLOW", 1, "Define to 1 if the compiler supports '__builtin_ssubl_overflow'."); + AC_DEFINE("PHP_HAVE_BUILTIN_SSUBLL_OVERFLOW", 1, "Define to 1 if the compiler supports '__builtin_ssubll_overflow'."); if (PHP_UNCRITICAL_WARN_CHOKE != "no") { ADD_FLAG("CFLAGS", "-Wno-ignored-attributes -Wno-deprecated-declarations -Wno-missing-braces " + "-Wno-logical-op-parentheses -Wno-msvc-include -Wno-invalid-source-encoding -Wno-unknown-pragmas " + diff --git a/win32/build/confutils.js b/win32/build/confutils.js index 032e534bb0d19..314fd1f84508d 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3318,6 +3318,11 @@ function toolset_setup_common_cflags() var vc_ver = probe_binary(PATH_PROG('cl', null)); ADD_FLAG("CFLAGS"," -fms-compatibility -fms-compatibility-version=" + vc_ver + " -fms-extensions"); } + + if (!CLANG_TOOLSET) { + /* clang uses __builtin_*() instead */ + ADD_FLAG("CFLAGS", "/DENABLE_INTSAFE_SIGNED_FUNCTIONS"); + } } function toolset_setup_intrinsic_cflags()