Skip to content

Commit 2d77746

Browse files
committed
Merge remote-tracking branch 'upstream/PHP-8.0' into PHP-8.1
2 parents 832e0ef + 1ce2b56 commit 2d77746

File tree

4 files changed

+2
-48
lines changed

4 files changed

+2
-48
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ PHP NEWS
44

55
- Core:
66
. Fixed --CGI-- support of run-tests.php. (cmb)
7+
. Fixed incorrect double to long casting in latest clang. (zeriyoshi)
78

89
- Date:
910
. Fixed bug GH-8730 (DateTime::diff miscalculation is same time zone of

Zend/Zend.m4

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -149,40 +149,6 @@ dnl Checks for library functions.
149149
AC_CHECK_FUNCS(getpid kill sigsetjmp)
150150
151151
ZEND_CHECK_FLOAT_PRECISION
152-
153-
dnl Test whether double cast to long preserves least significant bits.
154-
AC_MSG_CHECKING(whether double cast to long preserves least significant bits)
155-
156-
AC_RUN_IFELSE([AC_LANG_SOURCE([[
157-
#include <limits.h>
158-
#include <stdlib.h>
159-
160-
int main()
161-
{
162-
if (sizeof(long) == 4) {
163-
double d = (double) LONG_MIN * LONG_MIN + 2e9;
164-
165-
if ((long) d == 2e9 && (long) -d == -2e9) {
166-
return 0;
167-
}
168-
} else if (sizeof(long) == 8) {
169-
double correct = 18e18 - ((double) LONG_MIN * -2); /* Subtract ULONG_MAX + 1 */
170-
171-
if ((long) 18e18 == correct) { /* On 64-bit, only check between LONG_MAX and ULONG_MAX */
172-
return 0;
173-
}
174-
}
175-
return 1;
176-
}
177-
]])], [
178-
AC_DEFINE([ZEND_DVAL_TO_LVAL_CAST_OK], 1, [Define if double cast to long preserves least significant bits])
179-
AC_MSG_RESULT(yes)
180-
], [
181-
AC_MSG_RESULT(no)
182-
], [
183-
AC_MSG_RESULT(no)
184-
])
185-
186152
])
187153

188154
dnl

Zend/zend_operators.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3396,8 +3396,7 @@ ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const
33963396
}
33973397
/* }}} */
33983398

3399-
#ifndef ZEND_DVAL_TO_LVAL_CAST_OK
3400-
# if SIZEOF_ZEND_LONG == 4
3399+
#if SIZEOF_ZEND_LONG == 4
34013400
ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d) /* {{{ */
34023401
{
34033402
double two_pow_32 = pow(2., 32.),
@@ -3427,4 +3426,3 @@ ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d)
34273426
}
34283427
/* }}} */
34293428
#endif
3430-
#endif

Zend/zend_operators.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,6 @@ ZEND_API const char* ZEND_FASTCALL zend_memnrstr_ex(const char *haystack, const
9999
# define ZEND_DOUBLE_FITS_LONG(d) (!((d) >= (double)ZEND_LONG_MAX || (d) < (double)ZEND_LONG_MIN))
100100
#endif
101101

102-
#ifdef ZEND_DVAL_TO_LVAL_CAST_OK
103-
static zend_always_inline zend_long zend_dval_to_lval(double d)
104-
{
105-
if (EXPECTED(zend_finite(d)) && EXPECTED(!zend_isnan(d))) {
106-
return (zend_long)d;
107-
} else {
108-
return 0;
109-
}
110-
}
111-
#else
112102
ZEND_API zend_long ZEND_FASTCALL zend_dval_to_lval_slow(double d);
113103

114104
static zend_always_inline zend_long zend_dval_to_lval(double d)
@@ -120,7 +110,6 @@ static zend_always_inline zend_long zend_dval_to_lval(double d)
120110
}
121111
return (zend_long)d;
122112
}
123-
#endif
124113

125114
/* Used to convert a string float to integer during an (int) cast */
126115
static zend_always_inline zend_long zend_dval_to_lval_cap(double d)

0 commit comments

Comments
 (0)