Fix nearbyint scheduling of arithmetic past fesetenv (bug 15490).

This commit is contained in:
Joseph Myers 2013-05-19 18:40:25 +00:00
parent db62a90753
commit 3e69426875
7 changed files with 26 additions and 1 deletions

View File

@ -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.

2
NEWS
View File

@ -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).

View 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;
}

View 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;
}

View 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;
}

View 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);
}

View 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;
}