summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-06-02 13:54:40 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2010-06-02 13:54:40 +0400
commit40d4c07cd0b03eff55b0eef1c05fbee975bacc0b (patch)
tree4244efc8bee152cbcde5fddf50073ad10e02b784 /sql
parent6bd49855192c08306b8a6be3f6d19004de9da63c (diff)
parentf3a83073972b510ffee922aac37434946ae0e0bc (diff)
downloadmariadb-git-40d4c07cd0b03eff55b0eef1c05fbee975bacc0b.tar.gz
Automerge.
Diffstat (limited to 'sql')
-rw-r--r--sql/mysqld.cc36
1 files changed, 35 insertions, 1 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 3664f46995f..3ffc1a21e9c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -183,6 +183,21 @@ typedef fp_except fp_except_t;
/* for IRIX to use set_fpc_csr() */
#include <sys/fpu.h>
#endif
+#ifdef HAVE_FPU_CONTROL_H
+#include <fpu_control.h>
+#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()
{
@@ -204,7 +219,26 @@ inline void setup_fpu()
/* Set FPU rounding mode to "round-to-nearest" */
fesetround(FE_TONEAREST);
#endif /* HAVE_FESETROUND */
-
+
+ /*
+ x86 (32-bit) requires FPU precision to be explicitly set to 64 bit
+ (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__) && !defined(__SSE2_MATH__)
+#if defined(_WIN32)
+#if !defined(_WIN64)
+ _control87(_PC_53, MCW_PC);
+#endif /* !_WIN64 */
+#else /* !_WIN32 */
+ fpu_control_t cw;
+ _FPU_GETCW(cw);
+ cw= (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;
+ _FPU_SETCW(cw);
+#endif /* _WIN32 && */
+#endif /* __i386__ */
+
#if defined(__sgi) && defined(HAVE_SYS_FPU_H)
/* Enable denormalized DOUBLE values support for IRIX */
union fpc_csr n;