aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2013-04-04 17:35:12 +0200
committerThomas Schwinge <thomas@codesourcery.com>2013-04-05 22:34:52 +0200
commita1cbf437a53b24f2ff1f6af42028b607f6aa279d (patch)
tree3f62ac9a6413af55697ed6b154b400b518359406
parent8b43a0c9f26d5cf067119e47df9973515535673f (diff)
downloadglibc-a1cbf437a53b24f2ff1f6af42028b607f6aa279d.tar
glibc-a1cbf437a53b24f2ff1f6af42028b607f6aa279d.tar.gz
glibc-a1cbf437a53b24f2ff1f6af42028b607f6aa279d.tar.bz2
glibc-a1cbf437a53b24f2ff1f6af42028b607f6aa279d.zip
[BZ #14686, #15336] Fix standard compliance. Don't use hard-coded qNaN values.
-rw-r--r--ChangeLog7
-rw-r--r--NEWS8
-rw-r--r--math/libm-test.inc25
-rw-r--r--sysdeps/ieee754/dbl-64/e_remainder.c14
-rw-r--r--sysdeps/ieee754/dbl-64/urem.h8
5 files changed, 46 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index f0abe722a7..a4a3779caa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2013-04-05 Thomas Schwinge <thomas@codesourcery.com>
+ [BZ #14686, #15336]
+ * sysdeps/ieee754/dbl-64/urem.h (nNAN, NAN): Remove definitions.
+ * sysdeps/ieee754/dbl-64/e_remainder.c (__ieee754_remainder):
+ Instead, use input NaN values or generate a qNaN by arithmetic
+ operation. Also fix bugs to comply with the standard.
+ * math/libm-test.inc (remainder_test): Add more tests.
+
[BZ #15335, #15342]
* sysdeps/ieee754/dbl-64/upow.h (NaNQ): Remove definitions.
* sysdeps/ieee754/dbl-64/e_pow.c (__ieee754_pow): Instead, use
diff --git a/NEWS b/NEWS
index 3a39baf0fc..b85b67d280 100644
--- a/NEWS
+++ b/NEWS
@@ -10,10 +10,10 @@ Version 2.18
* The following bugs are resolved with this release:
10357, 11120, 11561, 12723, 13550, 13889, 13951, 14142, 14176, 14200,
- 14317, 14327, 14478, 14496, 14812, 14920, 14964, 14981, 14982, 14985,
- 14994, 14996, 15003, 15006, 15020, 15023, 15036, 15054, 15055, 15062,
- 15078, 15160, 15214, 15232, 15234, 15283, 15285, 15287, 15304, 15305,
- 15307, 15327, 15330, 15335, 15337, 15342.
+ 14317, 14327, 14478, 14496, 14686, 14812, 14920, 14964, 14981, 14982,
+ 14985, 14994, 14996, 15003, 15006, 15020, 15023, 15036, 15054, 15055,
+ 15062, 15078, 15160, 15214, 15232, 15234, 15283, 15285, 15287, 15304,
+ 15305, 15307, 15327, 15330, 15335, 15336, 15337, 15342.
* CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla
#15078).
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 08c80fad42..92fa6a201a 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -11103,12 +11103,30 @@ remainder_test (void)
TEST_ff_f (remainder, 1, minus_zero, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(1, -0) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
+ TEST_ff_f (remainder, plus_infty, minus_zero, qnan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(INF, -0) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, plus_infty, 0, qnan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(INF, 0) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, plus_infty, 1, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
+ TEST_ff_f (remainder, plus_infty, 2, qnan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(INF, 2) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, minus_infty, minus_zero, qnan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(-INF, -0) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, minus_infty, 0, qnan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(-INF, 0) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, minus_infty, 1, qnan_value, INVALID_EXCEPTION);
check_int ("errno for remainder(-INF, 1) = EDOM ", errno, EDOM, 0, 0, 0);
errno = 0;
+ TEST_ff_f (remainder, minus_infty, 2, qnan_value, INVALID_EXCEPTION);
+ check_int ("errno for remainder(-INF, 2) = EDOM ", errno, EDOM, 0, 0, 0);
+ errno = 0;
TEST_ff_f (remainder, qnan_value, qnan_value, qnan_value);
check_int ("errno for remainder(qNAN, qNAN) unchanged", errno, 0, 0, 0, 0);
errno = 0;
@@ -11118,6 +11136,13 @@ remainder_test (void)
TEST_ff_f (remainder, qnan_value, 0, qnan_value);
check_int ("errno for remainder(qNaN, 0) unchanged", errno, 0, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, 7.0, plus_infty, 7.0);
+ check_int ("errno for remainder(7.0, INF) unchanged", errno, 0, 0, 0, 0);
+ errno = 0;
+ TEST_ff_f (remainder, 7.0, minus_infty, 7.0);
+ check_int ("errno for remainder(7.0, -INF) unchanged", errno, 0, 0, 0, 0);
+
TEST_ff_f (remainder, 1.625, 1.0, -0.375);
TEST_ff_f (remainder, -1.625, 1.0, 0.375);
TEST_ff_f (remainder, 1.625, -1.0, -0.375);
diff --git a/sysdeps/ieee754/dbl-64/e_remainder.c b/sysdeps/ieee754/dbl-64/e_remainder.c
index c4db9316c7..39ca0c2d0e 100644
--- a/sysdeps/ieee754/dbl-64/e_remainder.c
+++ b/sysdeps/ieee754/dbl-64/e_remainder.c
@@ -111,12 +111,14 @@ double __ieee754_remainder(double x, double y)
else return (z>0)?z-y:z+y;
}
else { /* if x is too big */
- if (kx == 0x7ff00000 && u.i[LOW_HALF] == 0 && y == 1.0)
- return x / x;
- if (kx>=0x7ff00000||(ky==0&&t.i[LOW_HALF]==0)||ky>0x7ff00000||
- (ky==0x7ff00000&&t.i[LOW_HALF]!=0))
- return (u.i[HIGH_HALF]&0x80000000)?nNAN.x:NAN.x;
- else return x;
+ if (ky==0 && t.i[LOW_HALF] == 0) /* y = 0 */
+ return (x * y) / (x * y);
+ else if (kx >= 0x7ff00000 /* x not finite */
+ || (ky>0x7ff00000 /* y is NaN */
+ || (ky == 0x7ff00000 && t.i[LOW_HALF] != 0)))
+ return (x * y) / (x * y);
+ else
+ return x;
}
}
}
diff --git a/sysdeps/ieee754/dbl-64/urem.h b/sysdeps/ieee754/dbl-64/urem.h
index c4daa5d1ac..b576691ced 100644
--- a/sysdeps/ieee754/dbl-64/urem.h
+++ b/sysdeps/ieee754/dbl-64/urem.h
@@ -32,18 +32,14 @@ static const mynumber big = {{0x43380000, 0}}, /* 6755399441055744 */
t128 = {{0x47f00000, 0}}, /* 2^ 128 */
tm128 = {{0x37f00000, 0}}, /* 2^-128 */
ZERO = {{0, 0}}, /* 0.0 */
- nZERO = {{0x80000000, 0}}, /* -0.0 */
- NAN = {{0x7ff80000, 0}}, /* NaN */
- nNAN = {{0xfff80000, 0}}; /* -NaN */
+ nZERO = {{0x80000000, 0}}; /* -0.0 */
#else
#ifdef LITTLE_ENDI
static const mynumber big = {{0, 0x43380000}}, /* 6755399441055744 */
t128 = {{0, 0x47f00000}}, /* 2^ 128 */
tm128 = {{0, 0x37f00000}}, /* 2^-128 */
ZERO = {{0, 0}}, /* 0.0 */
- nZERO = {{0, 0x80000000}}, /* -0.0 */
- NAN = {{0, 0x7ff80000}}, /* NaN */
- nNAN = {{0, 0xfff80000}}; /* -NaN */
+ nZERO = {{0, 0x80000000}}; /* -0.0 */
#endif
#endif