about summary refs log tree commit diff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-05-19 18:40:25 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-05-19 18:40:25 +0000
commit3e694268750d51acc6a68b0ee7ded25a52902c20 (patch)
treedea529a863349fc82263de39b239742a00845031 /sysdeps/ieee754
parentdb62a9075305963281572cb990d1c766948bae7b (diff)
downloadglibc-3e694268750d51acc6a68b0ee7ded25a52902c20.tar.gz
glibc-3e694268750d51acc6a68b0ee7ded25a52902c20.tar.xz
glibc-3e694268750d51acc6a68b0ee7ded25a52902c20.zip
Fix nearbyint scheduling of arithmetic past fesetenv (bug 15490).
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/dbl-64/s_nearbyint.c2
-rw-r--r--sysdeps/ieee754/flt-32/s_nearbyintf.c2
-rw-r--r--sysdeps/ieee754/ldbl-128/s_nearbyintl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c5
-rw-r--r--sysdeps/ieee754/ldbl-96/s_nearbyintl.c2
5 files changed, 13 insertions, 0 deletions
diff --git a/sysdeps/ieee754/dbl-64/s_nearbyint.c b/sysdeps/ieee754/dbl-64/s_nearbyint.c
index eb40c298bb..5017f471d2 100644
--- a/sysdeps/ieee754/dbl-64/s_nearbyint.c
+++ b/sysdeps/ieee754/dbl-64/s_nearbyint.c
@@ -47,6 +47,7 @@ double __nearbyint(double x)
 		libc_feholdexcept (&env);
 	        w = TWO52[sx]+x;
 	        t =  w-TWO52[sx];
+		math_force_eval (t);
 		libc_fesetenv (&env);
 		GET_HIGH_WORD(i0,t);
 		SET_HIGH_WORD(t,(i0&0x7fffffff)|(sx<<31));
@@ -59,6 +60,7 @@ double __nearbyint(double x)
 	libc_feholdexcept (&env);
 	w = TWO52[sx]+x;
 	t = w-TWO52[sx];
+	math_force_eval (t);
 	libc_fesetenv (&env);
 	return t;
 }
diff --git a/sysdeps/ieee754/flt-32/s_nearbyintf.c b/sysdeps/ieee754/flt-32/s_nearbyintf.c
index 48debadde3..5aebefafcf 100644
--- a/sysdeps/ieee754/flt-32/s_nearbyintf.c
+++ b/sysdeps/ieee754/flt-32/s_nearbyintf.c
@@ -39,6 +39,7 @@ __nearbyintf(float x)
 		libc_feholdexceptf (&env);
 		w = TWO23[sx]+x;
 		t =  w-TWO23[sx];
+		math_force_eval (t);
 		libc_fesetenvf (&env);
 		GET_FLOAT_WORD(i0,t);
 		SET_FLOAT_WORD(t,(i0&0x7fffffff)|(sx<<31));
@@ -51,6 +52,7 @@ __nearbyintf(float x)
 	libc_feholdexceptf (&env);
 	w = TWO23[sx]+x;
 	t = w-TWO23[sx];
+	math_force_eval (t);
 	libc_fesetenvf (&env);
 	return t;
 }
diff --git a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
index d2afc10a5a..2017c04207 100644
--- a/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128/s_nearbyintl.c
@@ -47,6 +47,7 @@ long double __nearbyintl(long double x)
 		feholdexcept (&env);
 	        w = TWO112[sx]+x;
 	        t = w-TWO112[sx];
+		math_force_eval (t);
 	        fesetenv (&env);
 		GET_LDOUBLE_MSW64(i0,t);
 		SET_LDOUBLE_MSW64(t,(i0&0x7fffffffffffffffLL)|(sx<<63));
@@ -59,6 +60,7 @@ long double __nearbyintl(long double x)
 	feholdexcept (&env);
 	w = TWO112[sx]+x;
 	t = w-TWO112[sx];
+	math_force_eval (t);
 	fesetenv (&env);
 	return t;
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
index b654bf586f..bfcd11044d 100644
--- a/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
@@ -21,6 +21,7 @@
    when it's coded in C.  */
 
 #include <math.h>
+#include <math_private.h>
 #include <fenv.h>
 #include <math_ldbl_opt.h>
 #include <float.h>
@@ -53,6 +54,8 @@ __nearbyintl (long double x)
 	}
       u.dd[0] = high;
       u.dd[1] = 0.0;
+      math_force_eval (u.dd[0]);
+      math_force_eval (u.dd[1]);
       fesetenv (&env);
     }
   else if (fabs (u.dd[1]) < TWO52 && u.dd[1] != 0.0)
@@ -109,6 +112,8 @@ __nearbyintl (long double x)
 	}
       u.dd[0] = high + low;
       u.dd[1] = high - u.dd[0] + low;
+      math_force_eval (u.dd[0]);
+      math_force_eval (u.dd[1]);
       fesetenv (&env);
     }
 
diff --git a/sysdeps/ieee754/ldbl-96/s_nearbyintl.c b/sysdeps/ieee754/ldbl-96/s_nearbyintl.c
index ed9836c879..c1d77f0c02 100644
--- a/sysdeps/ieee754/ldbl-96/s_nearbyintl.c
+++ b/sysdeps/ieee754/ldbl-96/s_nearbyintl.c
@@ -54,6 +54,7 @@ long double __nearbyintl(long double x)
 		feholdexcept (&env);
 	        w = TWO63[sx]+x;
 	        t = w-TWO63[sx];
+		math_force_eval (t);
 		fesetenv (&env);
 		GET_LDOUBLE_EXP(i0,t);
 		SET_LDOUBLE_EXP(t,(i0&0x7fff)|(sx<<15));
@@ -80,6 +81,7 @@ long double __nearbyintl(long double x)
 	feholdexcept (&env);
 	w = TWO63[sx]+x;
 	t = w-TWO63[sx];
+	math_force_eval (t);
 	fesetenv (&env);
 	return t;
 }