aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-05-14 12:37:24 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-05-14 12:37:24 +0000
commit01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b (patch)
tree91adc1f6c05cc5dbfb6b3b55b7500fa9dae9fd0e
parent913d03c864ea2547e97f8d2d30fc71a008d4d103 (diff)
downloadglibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.tar
glibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.tar.gz
glibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.tar.bz2
glibc-01dbacd22a8d5e0053f8d0cf13a80286b6cfe79b.zip
Fix cacos (+Inf + finite*i) in round-downward mode (bug 16928).
According to C99/C11 Annex G, cacos applied to a value with real part +Inf and finite imaginary part should produce a result with real part +0. glibc wrongly produces a result with real part -0 in FE_DOWNWARD mode. This patch fixes this by checking for zero results in the relevant case of non-finite arguments (where there should never be a result with -0 real part), and converts the tests of cacos to ALL_RM_TEST. Tested x86_64 and x86 and ulps updated accordingly. [BZ #16928] * math/s_cacos.c (__cacos): Ensure zero real part of result from non-finite arguments is +0. * math/s_cacosf.c (__cacosf): Likewise. * math/s_cacosl.c (__cacosl): Likewise. * math/libm-test.inc (cacos_test): Use ALL_RM_TEST. * sysdeps/i386/fpu/libm-test-ulps: Update. * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
-rw-r--r--ChangeLog9
-rw-r--r--NEWS2
-rw-r--r--math/libm-test.inc4
-rw-r--r--math/s_cacos.c2
-rw-r--r--math/s_cacosf.c2
-rw-r--r--math/s_cacosl.c2
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps48
-rw-r--r--sysdeps/x86_64/fpu/libm-test-ulps48
8 files changed, 113 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index a4376290ad..37ca8c03be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2014-05-14 Joseph Myers <joseph@codesourcery.com>
+ [BZ #16928]
+ * math/s_cacos.c (__cacos): Ensure zero real part of result from
+ non-finite arguments is +0.
+ * math/s_cacosf.c (__cacosf): Likewise.
+ * math/s_cacosl.c (__cacosl): Likewise.
+ * math/libm-test.inc (cacos_test): Use ALL_RM_TEST.
+ * sysdeps/i386/fpu/libm-test-ulps: Update.
+ * sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
+
[BZ #16927]
* sysdeps/i386/fpu/e_acosh.S (__ieee754_acosh): Use fabs on x-1
value.
diff --git a/NEWS b/NEWS
index 974d2c80a9..de9e8a280e 100644
--- a/NEWS
+++ b/NEWS
@@ -17,7 +17,7 @@ Version 2.20
16713, 16714, 16731, 16739, 16740, 16743, 16754, 16758, 16759, 16760,
16770, 16786, 16789, 16791, 16799, 16800, 16815, 16823, 16824, 16831,
16838, 16854, 16876, 16877, 16885, 16888, 16890, 16912, 16916, 16922,
- 16927, 16932.
+ 16927, 16928, 16932.
* The minimum Linux kernel version that this version of the GNU C Library
can be used with is 2.6.32.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index b4177e8f8e..de7bc8ad94 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -2615,9 +2615,7 @@ static const struct test_c_c_data cacos_test_data[] =
static void
cacos_test (void)
{
- START (cacos, 0);
- RUN_TEST_LOOP_c_c (cacos, cacos_test_data, );
- END_COMPLEX;
+ ALL_RM_TEST (cacos, 0, cacos_test_data, RUN_TEST_LOOP_c_c, END_COMPLEX);
}
static const struct test_c_c_data cacosh_test_data[] =
diff --git a/math/s_cacos.c b/math/s_cacos.c
index d0aaba4e6a..2c22817d4d 100644
--- a/math/s_cacos.c
+++ b/math/s_cacos.c
@@ -34,6 +34,8 @@ __cacos (__complex__ double x)
y = __casin (x);
__real__ res = (double) M_PI_2 - __real__ y;
+ if (__real__ res == 0.0)
+ __real__ res = 0.0;
__imag__ res = -__imag__ y;
}
else
diff --git a/math/s_cacosf.c b/math/s_cacosf.c
index 9eaeeec53d..1c9d8b9186 100644
--- a/math/s_cacosf.c
+++ b/math/s_cacosf.c
@@ -34,6 +34,8 @@ __cacosf (__complex__ float x)
y = __casinf (x);
__real__ res = (float) M_PI_2 - __real__ y;
+ if (__real__ res == 0.0f)
+ __real__ res = 0.0f;
__imag__ res = -__imag__ y;
}
else
diff --git a/math/s_cacosl.c b/math/s_cacosl.c
index b9d34930d6..8688d3cd36 100644
--- a/math/s_cacosl.c
+++ b/math/s_cacosl.c
@@ -34,6 +34,8 @@ __cacosl (__complex__ long double x)
y = __casinl (x);
__real__ res = M_PI_2l - __real__ y;
+ if (__real__ res == 0.0L)
+ __real__ res = 0.0L;
__imag__ res = -__imag__ y;
}
else
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index ccef44ac63..946cad489b 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -173,6 +173,54 @@ ifloat: 1
ildouble: 2
ldouble: 2
+Function: Real part of "cacos_downward":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos_downward":
+double: 3
+float: 3
+idouble: 3
+ifloat: 3
+ildouble: 5
+ldouble: 5
+
+Function: Real part of "cacos_towardzero":
+double: 2
+float: 1
+idouble: 2
+ifloat: 1
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos_towardzero":
+double: 3
+float: 3
+idouble: 3
+ifloat: 3
+ildouble: 5
+ldouble: 5
+
+Function: Real part of "cacos_upward":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos_upward":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 5
+ldouble: 5
+
Function: Real part of "cacosh":
double: 1
float: 1
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index ad8ae9ce5c..d47287696c 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -199,6 +199,54 @@ ifloat: 2
ildouble: 2
ldouble: 2
+Function: Real part of "cacos_downward":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos_downward":
+double: 5
+float: 3
+idouble: 5
+ifloat: 3
+ildouble: 5
+ldouble: 5
+
+Function: Real part of "cacos_towardzero":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos_towardzero":
+double: 5
+float: 3
+idouble: 5
+ifloat: 3
+ildouble: 5
+ldouble: 5
+
+Function: Real part of "cacos_upward":
+double: 2
+float: 2
+idouble: 2
+ifloat: 2
+ildouble: 2
+ldouble: 2
+
+Function: Imaginary part of "cacos_upward":
+double: 4
+float: 4
+idouble: 4
+ifloat: 4
+ildouble: 5
+ldouble: 5
+
Function: Real part of "cacosh":
double: 1
float: 2