]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
[BZ #22244] Fix yn(n,0) without SVID wrapper
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Tue, 3 Oct 2017 17:12:42 +0000 (18:12 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 4 Oct 2017 09:15:12 +0000 (10:15 +0100)
Without SVID compat wrapper yn(n,0) and ynf(n,0) does not raise
the divide-by-zero excpetion and it may return inf with the wrong
sign for n < 0.

[BZ #22244]
* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_yn): Fix x == 0 case.
* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_ynf): Likewise.

ChangeLog
sysdeps/ieee754/dbl-64/e_jn.c
sysdeps/ieee754/flt-32/e_jnf.c

index 616150949990e5928030590be3a3740f20b8f78f..55295ba48e50704cc57b5b1b172b1c59cef7199e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-04  Szabolcs Nagy  <szabolcs.nagy@arm.com>
+
+       [BZ #22244]
+       * sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_yn): Fix x == 0 case.
+       * sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_ynf): Likewise.
+
 2017-10-04  Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
        [BZ #22243]
index 3ac91df2b0795855c1f7f38d8812fdd6fb00c561..a244df0e0ac4fd19aa50faadbd4089120fea160a 100644 (file)
@@ -268,11 +268,6 @@ __ieee754_yn (int n, double x)
   /* if Y(n,NaN) is NaN */
   if (__glibc_unlikely ((ix | ((uint32_t) (lx | -lx)) >> 31) > 0x7ff00000))
     return x + x;
-  if (__glibc_unlikely ((ix | lx) == 0))
-    return -HUGE_VAL + x;
-  /* -inf and overflow exception.  */;
-  if (__glibc_unlikely (hx < 0))
-    return zero / (zero * x);
   sign = 1;
   if (n < 0)
     {
@@ -281,6 +276,11 @@ __ieee754_yn (int n, double x)
     }
   if (n == 0)
     return (__ieee754_y0 (x));
+  if (__glibc_unlikely ((ix | lx) == 0))
+    return -sign / zero;
+  /* -inf and overflow exception.  */;
+  if (__glibc_unlikely (hx < 0))
+    return zero / (zero * x);
   {
     SET_RESTORE_ROUND (FE_TONEAREST);
     if (n == 1)
index 82b9ba3300d9be503d542a8f8de2a6a8eef7b739..4b78ecea6c23d385f4857adf543171b928dc9428 100644 (file)
@@ -194,15 +194,15 @@ __ieee754_ynf(int n, float x)
        ix = 0x7fffffff&hx;
     /* if Y(n,NaN) is NaN */
        if(__builtin_expect(ix>0x7f800000, 0)) return x+x;
-       if(__builtin_expect(ix==0, 0))
-               return -HUGE_VALF+x;  /* -inf and overflow exception.  */
-       if(__builtin_expect(hx<0, 0)) return zero/(zero*x);
        sign = 1;
        if(n<0){
                n = -n;
                sign = 1 - ((n&1)<<1);
        }
        if(n==0) return(__ieee754_y0f(x));
+       if(__builtin_expect(ix==0, 0))
+               return -sign/zero;
+       if(__builtin_expect(hx<0, 0)) return zero/(zero*x);
        SET_RESTORE_ROUNDF (FE_TONEAREST);
        if(n==1) {
            ret = sign*__ieee754_y1f(x);