aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/i386
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-11-29 16:31:16 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-11-29 16:31:16 +0000
commitea3bc4e821e20e70b093c9a33e54f99c79e0d847 (patch)
tree822fa8b196e69580a4f4c9fb4eb63bd0ddbe6147 /sysdeps/i386
parent0712c9d861f4e861313a7f9fad06609bd1afb263 (diff)
downloadglibc-ea3bc4e821e20e70b093c9a33e54f99c79e0d847.zip
glibc-ea3bc4e821e20e70b093c9a33e54f99c79e0d847.tar.gz
glibc-ea3bc4e821e20e70b093c9a33e54f99c79e0d847.tar.bz2
Fix x86 sqrt rounding (bug 14032).
Diffstat (limited to 'sysdeps/i386')
-rw-r--r--sysdeps/i386/fpu/e_sqrt.S10
-rw-r--r--sysdeps/i386/fpu/w_sqrt.c8
2 files changed, 18 insertions, 0 deletions
diff --git a/sysdeps/i386/fpu/e_sqrt.S b/sysdeps/i386/fpu/e_sqrt.S
index 1054ba4..fba5833 100644
--- a/sysdeps/i386/fpu/e_sqrt.S
+++ b/sysdeps/i386/fpu/e_sqrt.S
@@ -7,7 +7,17 @@
ENTRY(__ieee754_sqrt)
fldl 4(%esp)
+ subl $8, %esp
+ cfi_adjust_cfa_offset (8)
+ fstcw 4(%esp)
+ movl $0xfeff, %edx
+ andl 4(%esp), %edx
+ movl %edx, (%esp)
+ fldcw (%esp)
fsqrt
+ fldcw 4(%esp)
+ addl $8, %esp
+ cfi_adjust_cfa_offset (-8)
ret
END (__ieee754_sqrt)
strong_alias (__ieee754_sqrt, __sqrt_finite)
diff --git a/sysdeps/i386/fpu/w_sqrt.c b/sysdeps/i386/fpu/w_sqrt.c
new file mode 100644
index 0000000..19b5074
--- /dev/null
+++ b/sysdeps/i386/fpu/w_sqrt.c
@@ -0,0 +1,8 @@
+/* The inline __ieee754_sqrt is not correctly rounding; it's OK for
+ most internal uses in glibc, but not for sqrt itself. */
+#define __ieee754_sqrt __avoid_ieee754_sqrt
+#include <math.h>
+#include <math_private.h>
+#undef __ieee754_sqrt
+extern double __ieee754_sqrt (double);
+#include <math/w_sqrt.c>