Commit 064ebe57 authored by Alexey Kopytov's avatar Alexey Kopytov

Addendum to the backport patch for WL#2934:

Unlike other platforms --mfpmath=sse is the default 
gcc mode on Mac OS X Intel. So it is unnecessary
to switch FPU to double precision mode (in fact,
it even breaks some math library functions).
parent 79c8b38a
...@@ -191,6 +191,18 @@ typedef fp_except fp_except_t; ...@@ -191,6 +191,18 @@ typedef fp_except fp_except_t;
/* for IRIX to use set_fpc_csr() */ /* for IRIX to use set_fpc_csr() */
#include <sys/fpu.h> #include <sys/fpu.h>
#endif #endif
#if defined(__i386__) && !defined(HAVE_FPU_CONTROL_H)
# define fpu_control_t unsigned int
# define _FPU_EXTENDED 0x300
# define _FPU_DOUBLE 0x200
# ifdef __GNUC__
# define _FPU_GETCW(cw) __asm__ __volatile__("fnstcw %0" : "=m" (*&cw))
# define _FPU_SETCW(cw) __asm__ __volatile__("fldcw %0" : : "m" (*&cw))
# else
# define _FPU_GETCW(cw) (cw= 0)
# define _FPU_SETCW(cw)
# endif
#endif
inline void setup_fpu() inline void setup_fpu()
{ {
...@@ -214,27 +226,17 @@ inline void setup_fpu() ...@@ -214,27 +226,17 @@ inline void setup_fpu()
#endif /* HAVE_FESETROUND */ #endif /* HAVE_FESETROUND */
/* /*
x86 (32-bit) requires FPU precision to be explicitly set to 64 bit for x86 (32-bit) requires FPU precision to be explicitly set to 64 bit
portable results of floating point operations (double precision) for portable results of floating point operations.
However, there is no need to do so if compiler is using SSE2 for floating
point, double values will be stored and processed in 64 bits anyway.
*/ */
#if defined(__i386__) #if defined(__i386__) && !defined(__SSE2_MATH__)
#if defined(_WIN32) #if defined(_WIN32)
#if !defined(_WIN64) #if !defined(_WIN64)
_control87(_PC_53, MCW_PC); _control87(_PC_53, MCW_PC);
#endif /* !_WIN64 */ #endif /* !_WIN64 */
#else /* !_WIN32 */ #else /* !_WIN32 */
#if !defined(HAVE_FPU_CONTROL_H)
#define fpu_control_t unsigned int
#define _FPU_EXTENDED 0x300
#define _FPU_DOUBLE 0x200
#if defined(__GNUC__)
#define _FPU_GETCW(cw) __asm__ __volatile__("fnstcw %0" : "=m" (*&cw))
#define _FPU_SETCW(cw) __asm__ __volatile__("fldcw %0" : : "m" (*&cw))
#else /* !__GNUC__ */
#define _FPU_GETCW(cw) (cw= 0)
#define _FPU_SETCW(cw)
#endif /* __GNUC__ */
#endif /* !HAVE_FPU_CONTROL_H */
fpu_control_t cw; fpu_control_t cw;
_FPU_GETCW(cw); _FPU_GETCW(cw);
cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE; cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment