]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix ldbl-128ibm ceill, rintl etc. for sNaN arguments (bug 20156).
authorJoseph Myers <joseph@codesourcery.com>
Fri, 27 May 2016 13:59:24 +0000 (13:59 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Fri, 27 May 2016 13:59:24 +0000 (13:59 +0000)
The ldbl-128ibm implementations of ceill, floorl, roundl, truncl,
rintl and nearbyintl wrongly return an sNaN when given an sNaN
argument.  This patch fixes them to add such an argument to itself to
turn it into a quiet NaN.  (The code structure means this "else" case
applies to any argument which is zero or not finite; it's OK to do
this in all such cases.)

Tested for powerpc.

[BZ #20156]
* sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Add high part
to itself when zero or not finite.
* sysdeps/ieee754/ldbl-128ibm/s_floorl.c (__floorl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_rintl.c (__rintl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_roundl.c (__roundl): Likewise.
* sysdeps/ieee754/ldbl-128ibm/s_truncl.c (__truncl): Likewise.

ChangeLog
sysdeps/ieee754/ldbl-128ibm/s_ceill.c
sysdeps/ieee754/ldbl-128ibm/s_floorl.c
sysdeps/ieee754/ldbl-128ibm/s_rintl.c
sysdeps/ieee754/ldbl-128ibm/s_roundl.c
sysdeps/ieee754/ldbl-128ibm/s_truncl.c

index 2516304de3916ce11ab0a48e1990aaad2ad40260..1cf86d741961e0637c119c1cdb34513e617728db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2016-05-27  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #20156]
+       * sysdeps/ieee754/ldbl-128ibm/s_ceill.c (__ceill): Add high part
+       to itself when zero or not finite.
+       * sysdeps/ieee754/ldbl-128ibm/s_floorl.c (__floorl): Likewise.
+       * sysdeps/ieee754/ldbl-128ibm/s_rintl.c (__rintl): Likewise.
+       * sysdeps/ieee754/ldbl-128ibm/s_roundl.c (__roundl): Likewise.
+       * sysdeps/ieee754/ldbl-128ibm/s_truncl.c (__truncl): Likewise.
+
 2016-05-26  Joseph Myers  <joseph@codesourcery.com>
 
        [BZ #20153]
index 635fddc633202b174bdc1a5974d8d84abc6e6628..71f56233f9972229ab0a7a99e1def5d4dd316f1d 100644 (file)
@@ -52,6 +52,9 @@ __ceill (long double x)
          ldbl_canonicalize_int (&xh, &xl);
        }
     }
+  else
+    /* Quiet signaling NaN arguments.  */
+    xh += xh;
 
   return ldbl_pack (xh, xl);
 }
index a1469646b04f5ebc44d292742597dab7383ef743..61ac568c60ac5564f45a75fa64f20457d2742dc5 100644 (file)
@@ -52,6 +52,9 @@ __floorl (long double x)
          ldbl_canonicalize_int (&xh, &xl);
        }
     }
+  else
+    /* Quiet signaling NaN arguments.  */
+    xh += xh;
 
   return ldbl_pack (xh, xl);
 }
index e4af01c9a0fe7dc271db9103d408691d2f346289..f7ff673cebd5de31da1b4b5580126df5f1fbde9f 100644 (file)
@@ -119,6 +119,9 @@ __rintl (long double x)
       fesetround (save_round);
 #endif
     }
+  else
+    /* Quiet signaling NaN arguments.  */
+    xh += xh;
 
   return ldbl_pack (xh, xl);
 }
index b01510fef3bc7e4c0327c1e3aec9a0b550e3ab78..2d75eb0ca8166a8feadbe1a9ec80410ef105dc79 100644 (file)
@@ -77,6 +77,9 @@ __roundl (long double x)
          ldbl_canonicalize_int (&xh, &xl);
        }
     }
+  else
+    /* Quiet signaling NaN arguments.  */
+    xh += xh;
 
   return ldbl_pack (xh, xl);
 }
index b7d4bb59567cbcea389355925134be73e74c8963..a2c60a89f422479097e52fc8280706224dbdfc4f 100644 (file)
@@ -52,6 +52,9 @@ __truncl (long double x)
          ldbl_canonicalize_int (&xh, &xl);
        }
     }
+  else
+    /* Quiet signaling NaN arguments.  */
+    xh += xh;
 
   return ldbl_pack (xh, xl);
 }