Skip to content

Commit b8f3811

Browse files
committed
Fix #79595: zend_init_fpu() alters FPU precision
On startup, PHP deliberately changes the floating point control word to enforce binary64 format for the calculations for best consistency across platforms. However, this is unnessary when compiling under `__SSE__`, because in this case the x87 instructions are not used. Therefore, we can skip the modification, which has the benefit that system libraries are free to work in the mode of their liking.
1 parent 4f47ba9 commit b8f3811

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Zend/zend_float.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
ZEND_API void zend_init_fpu(void) /* {{{ */
2424
{
25-
#if XPFPA_HAVE_CW
25+
#if XPFPA_HAVE_CW && !defined(__SSE__)
2626
XPFPA_DECLARE
2727

2828
if (!EG(saved_fpu_cw_ptr)) {
@@ -38,7 +38,7 @@ ZEND_API void zend_init_fpu(void) /* {{{ */
3838

3939
ZEND_API void zend_shutdown_fpu(void) /* {{{ */
4040
{
41-
#if XPFPA_HAVE_CW
41+
#if XPFPA_HAVE_CW && !defined(__SSE__)
4242
if (EG(saved_fpu_cw_ptr)) {
4343
XPFPA_RESTORE_CW(EG(saved_fpu_cw_ptr));
4444
}
@@ -49,8 +49,10 @@ ZEND_API void zend_shutdown_fpu(void) /* {{{ */
4949

5050
ZEND_API void zend_ensure_fpu_mode(void) /* {{{ */
5151
{
52+
#ifndef __SSE__
5253
XPFPA_DECLARE
5354

5455
XPFPA_SWITCH_DOUBLE();
56+
#endif
5557
}
5658
/* }}} */

0 commit comments

Comments
 (0)