diff options
author | Christoph M. Becker <cmbecker69@gmx.de> | 2020-05-20 13:23:17 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2020-05-22 15:46:13 +0200 |
commit | 88dfc475c5937822399843e8aed9b98a36a01813 (patch) | |
tree | 5e5a8938085d21002956571d7edb778bd1941856 | |
parent | da801ba5e3553f4c217d2528b36a5977ee9a90ed (diff) | |
download | php-git-88dfc475c5937822399843e8aed9b98a36a01813.tar.gz |
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.
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | Zend/zend_float.c | 7 |
2 files changed, 6 insertions, 2 deletions
@@ -8,6 +8,7 @@ PHP NEWS . Fixed bug #79489 (.user.ini does not inherit). (cmb) . Fixed bug #79600 (Regression in 7.4.6 when yielding an array based generator). (Nikita) + . Fixed bug #79595 (zend_init_fpu() alters FPU precision). (cmb, Nikita) - FFI: . Fixed bug #79571 (FFI: var_dumping unions may segfault). (cmb) diff --git a/Zend/zend_float.c b/Zend/zend_float.c index 90af0c4a5f..2d7e6529a5 100644 --- a/Zend/zend_float.c +++ b/Zend/zend_float.c @@ -22,7 +22,8 @@ ZEND_API void zend_init_fpu(void) /* {{{ */ { -#if XPFPA_HAVE_CW +/* under __SSE__ the FPCW is irrelevant; no need to change it */ +#if XPFPA_HAVE_CW && !defined(__SSE__) XPFPA_DECLARE if (!EG(saved_fpu_cw_ptr)) { @@ -38,7 +39,7 @@ ZEND_API void zend_init_fpu(void) /* {{{ */ ZEND_API void zend_shutdown_fpu(void) /* {{{ */ { -#if XPFPA_HAVE_CW +#if XPFPA_HAVE_CW && !defined(__SSE__) if (EG(saved_fpu_cw_ptr)) { XPFPA_RESTORE_CW(EG(saved_fpu_cw_ptr)); } @@ -49,8 +50,10 @@ ZEND_API void zend_shutdown_fpu(void) /* {{{ */ ZEND_API void zend_ensure_fpu_mode(void) /* {{{ */ { +#ifndef __SSE__ XPFPA_DECLARE XPFPA_SWITCH_DOUBLE(); +#endif } /* }}} */ |