Skip to content

Fix #79595: zend_init_fpu() alters FPU precision #5621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Zend/zend_float.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ END_EXTERN_C()
Implementation notes:

x86_64:
- Since all x86_64 compilers use SSE by default, it is probably unnecessary
to use these macros there. We define them anyway since we are too lazy
to differentiate the architecture. Also, the compiler option -mfpmath=i387
justifies this decision.
- Since all x86_64 compilers use SSE by default, we do not define these
macros there. We ignore the compiler option -mfpmath=i387, because there is
no reason to use it on x86_64.

General:
- It would be nice if one could detect whether SSE if used for math via some
Expand All @@ -67,17 +66,15 @@ END_EXTERN_C()

MS Visual C:
- Since MSVC users typically don't use autoconf or CMake, we will detect
MSVC via compile time define. Floating point precision change isn't
supported on 64 bit platforms, so it's NOP. See
http://msdn.microsoft.com/en-us/library/c9676k6h(v=vs.110).aspx
MSVC via compile time define.
*/

/* MSVC detection (MSVC people usually don't use autoconf) */
#if defined(_MSC_VER) && !defined(_WIN64)
# define HAVE__CONTROLFP_S
#endif /* _MSC_VER */

#ifdef HAVE__CONTROLFP_S
#if defined(HAVE__CONTROLFP_S) && !defined(__x86_64__)

/* float.h defines _controlfp_s */
# include <float.h>
Expand Down Expand Up @@ -141,7 +138,7 @@ END_EXTERN_C()
return _xpfpa_result; \
} while (0)

#elif defined(HAVE__CONTROLFP)
#elif defined(HAVE__CONTROLFP) && !defined(__x86_64__)

/* float.h defines _controlfp */
# include <float.h>
Expand Down Expand Up @@ -200,7 +197,7 @@ END_EXTERN_C()
return _xpfpa_result; \
} while (0)

#elif defined(HAVE__FPU_SETCW) /* glibc systems */
#elif defined(HAVE__FPU_SETCW) && !defined(__x86_64__) /* glibc systems */

/* fpu_control.h defines _FPU_[GS]ETCW */
# include <fpu_control.h>
Expand Down Expand Up @@ -259,7 +256,7 @@ END_EXTERN_C()
return _xpfpa_result; \
} while (0)

#elif defined(HAVE_FPSETPREC) /* FreeBSD */
#elif defined(HAVE_FPSETPREC) && !defined(__x86_64__) /* FreeBSD */

/* fpu_control.h defines _FPU_[GS]ETCW */
# include <machine/ieeefp.h>
Expand Down Expand Up @@ -315,7 +312,7 @@ END_EXTERN_C()
return _xpfpa_result; \
} while (0)

#elif defined(HAVE_FPU_INLINE_ASM_X86)
#elif defined(HAVE_FPU_INLINE_ASM_X86) && !defined(__x86_64__)

/*
Custom x86 inline assembler implementation.
Expand Down