aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2013-12-04 14:39:37 +0000
committerJoseph Myers <joseph@codesourcery.com>2013-12-04 14:39:37 +0000
commit699ff83712b5796ac50ed332d9dad55d38450e81 (patch)
tree8e2470bbcf5d1d18813aa9d063771b083c8667af /sysdeps
parent5b118558f9fb0620508d51c34c2cb5ba4f1f01c2 (diff)
downloadglibc-699ff83712b5796ac50ed332d9dad55d38450e81.zip
glibc-699ff83712b5796ac50ed332d9dad55d38450e81.tar.gz
glibc-699ff83712b5796ac50ed332d9dad55d38450e81.tar.bz2
Fix Bessel function error handling (bug 6807, bug 15901).
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/i386/fpu/libm-test-ulps3
-rw-r--r--sysdeps/ieee754/k_standard.c16
-rw-r--r--sysdeps/ieee754/ldbl-128/e_jnl.c2
-rw-r--r--sysdeps/ieee754/ldbl-128ibm/e_jnl.c2
-rw-r--r--sysdeps/ieee754/ldbl-96/e_jnl.c3
-rw-r--r--sysdeps/x86_64/fpu/libm-test-ulps5
6 files changed, 21 insertions, 10 deletions
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 4ed02a2..cf7c5e8 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -7563,6 +7563,9 @@ float: 2
ifloat: 2
# yn
+Test "yn (-10, 1.0)":
+float: 2
+ifloat: 2
Test "yn (0, 0.125)":
ildouble: 1
ldouble: 1
diff --git a/sysdeps/ieee754/k_standard.c b/sysdeps/ieee754/k_standard.c
index 4a0d82d..5399c66 100644
--- a/sysdeps/ieee754/k_standard.c
+++ b/sysdeps/ieee754/k_standard.c
@@ -248,7 +248,7 @@ __kernel_standard(double x, double y, int type)
else
exc.retval = -HUGE_VAL;
if (_LIB_VERSION == _POSIX_)
- __set_errno (EDOM);
+ __set_errno (ERANGE);
else if (!matherr(&exc)) {
if (_LIB_VERSION == _SVID_) {
(void) WRITE2("y0: DOMAIN error\n", 17);
@@ -265,7 +265,7 @@ __kernel_standard(double x, double y, int type)
if (_LIB_VERSION == _SVID_)
exc.retval = -HUGE;
else
- exc.retval = -HUGE_VAL;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
__set_errno (EDOM);
else if (!matherr(&exc)) {
@@ -286,7 +286,7 @@ __kernel_standard(double x, double y, int type)
else
exc.retval = -HUGE_VAL;
if (_LIB_VERSION == _POSIX_)
- __set_errno (EDOM);
+ __set_errno (ERANGE);
else if (!matherr(&exc)) {
if (_LIB_VERSION == _SVID_) {
(void) WRITE2("y1: DOMAIN error\n", 17);
@@ -303,7 +303,7 @@ __kernel_standard(double x, double y, int type)
if (_LIB_VERSION == _SVID_)
exc.retval = -HUGE;
else
- exc.retval = -HUGE_VAL;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
__set_errno (EDOM);
else if (!matherr(&exc)) {
@@ -322,9 +322,11 @@ __kernel_standard(double x, double y, int type)
if (_LIB_VERSION == _SVID_)
exc.retval = -HUGE;
else
- exc.retval = -HUGE_VAL;
+ exc.retval = ((x < 0 && ((int) x & 1) != 0)
+ ? HUGE_VAL
+ : -HUGE_VAL);
if (_LIB_VERSION == _POSIX_)
- __set_errno (EDOM);
+ __set_errno (ERANGE);
else if (!matherr(&exc)) {
if (_LIB_VERSION == _SVID_) {
(void) WRITE2("yn: DOMAIN error\n", 17);
@@ -341,7 +343,7 @@ __kernel_standard(double x, double y, int type)
if (_LIB_VERSION == _SVID_)
exc.retval = -HUGE;
else
- exc.retval = -HUGE_VAL;
+ exc.retval = NAN;
if (_LIB_VERSION == _POSIX_)
__set_errno (EDOM);
else if (!matherr(&exc)) {
diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c b/sysdeps/ieee754/ldbl-128/e_jnl.c
index 70d5672..c2a4923 100644
--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128/e_jnl.c
@@ -316,7 +316,7 @@ __ieee754_ynl (int n, long double x)
if (x <= 0.0L)
{
if (x == 0.0L)
- return -HUGE_VALL + x;
+ return ((n < 0 && (n & 1) != 0) ? 1.0L : -1.0L) / 0.0L;
if (se & 0x80000000)
return zero / (zero * x);
}
diff --git a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
index 817977d..6761a0d 100644
--- a/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-128ibm/e_jnl.c
@@ -316,7 +316,7 @@ __ieee754_ynl (int n, long double x)
if (x <= 0.0L)
{
if (x == 0.0L)
- return -HUGE_VALL + x;
+ return ((n < 0 && (n & 1) != 0) ? 1.0L : -1.0L) / 0.0L;
if (se & 0x80000000)
return zero / (zero * x);
}
diff --git a/sysdeps/ieee754/ldbl-96/e_jnl.c b/sysdeps/ieee754/ldbl-96/e_jnl.c
index 58a9107..fa8e27e 100644
--- a/sysdeps/ieee754/ldbl-96/e_jnl.c
+++ b/sysdeps/ieee754/ldbl-96/e_jnl.c
@@ -302,7 +302,8 @@ __ieee754_ynl (int n, long double x)
if (__builtin_expect ((ix == 0x7fff) && ((i0 & 0x7fffffff) != 0), 0))
return x + x;
if (__builtin_expect ((ix | i0 | i1) == 0, 0))
- return -HUGE_VALL + x; /* -inf and overflow exception. */
+ /* -inf or inf and divide-by-zero exception. */
+ return ((n < 0 && (n & 1) != 0) ? 1.0L : -1.0L) / 0.0L;
if (__builtin_expect (se & 0x8000, 0))
return zero / (zero * x);
sign = 1;
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index e785148..b3b40ef 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -8615,6 +8615,11 @@ idouble: 1
ifloat: 2
# yn
+Test "yn (-10, 1.0)":
+double: 1
+float: 2
+idouble: 1
+ifloat: 2
Test "yn (0, 0.125)":
ildouble: 1
ldouble: 1