]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix nearbyint scheduling of arithmetic past fesetenv (bug 15490).
authorJoseph Myers <joseph@codesourcery.com>
Sun, 19 May 2013 18:40:25 +0000 (18:40 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Sun, 19 May 2013 18:40:25 +0000 (18:40 +0000)
ChangeLog
NEWS
sysdeps/ieee754/dbl-64/s_nearbyint.c
sysdeps/ieee754/flt-32/s_nearbyintf.c
sysdeps/ieee754/ldbl-128/s_nearbyintl.c
sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c
sysdeps/ieee754/ldbl-96/s_nearbyintl.c

index 5967380a0957b7391ae3eac783caa3b3fa34f3e2..a2323faff481fa27e31aa34e11267a09e4103c8f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2013-05-19  Joseph Myers  <joseph@codesourcery.com>
 
+       [BZ #15490]
+       * sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Use
+       math_force_eval before restoring floating-point envrionment.
+       * sysdeps/ieee754/flt-32/s_nearbyintf.c (__nearbyintf): Likewise.
+       * sysdeps/ieee754/ldbl-128/s_nearbyintl.c (__nearbyintl):
+       Likewise.
+       * sysdeps/ieee754/ldbl-128ibm/s_nearbyintl.c: Include
+       <math_private.h>.
+       (__nearbyintl): Use math_force_eval before restoring
+       floating-point environment.
+       * sysdeps/ieee754/ldbl-96/s_nearbyintl.c (__nearbyintl): Likewise.
+
        * math/gen-libm-test.pl (special_functions): Remove.
        (parse_args): Don't handle TEST_extra.  Handle functions with no
        return value.
diff --git a/NEWS b/NEWS
index a2bac22686565ddf137b39df41d7aeb7d3a6fd05..230b304b9aad01e3402454798f5bc20a5ceb68e0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -18,7 +18,7 @@ Version 2.18
   15305, 15307, 15309, 15327, 15330, 15335, 15336, 15337, 15342, 15346,
   15359, 15361, 15366, 15380, 15394, 15395, 15405, 15406, 15409, 15416,
   15418, 15419, 15423, 15424, 15426, 15429, 15442, 15448, 15480, 15485,
-  15488.
+  15488, 15490.
 
 * CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
   #15078).
index eb40c298bb06dc2ac18359e602ea0a041137677b..5017f471d24eed151a8dfff8d3784039381bddf0 100644 (file)
@@ -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;
 }
index 48debadde3cae21c23b6ff9c226cbf59babc403f..5aebefafcfb38c1e581bc6beb50a2d946e24d966 100644 (file)
@@ -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;
 }
index d2afc10a5a08145471d4c00b3e23856b7dd8fbc9..2017c04207d34622887a2981a296c3683e88b628 100644 (file)
@@ -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;
 }
index b654bf586fdaf5274b4caadc5b64beb2d209534b..bfcd11044dfaf9af1eaaae3469a2b9edffbb7c06 100644 (file)
@@ -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);
     }
 
index ed9836c879f5b5ebbef8520b42b2a5284cfdc895..c1d77f0c02fe9615372efc45e6788538d646e145 100644 (file)
@@ -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;
 }