Blame SOURCES/glibc-ppc64le-11.patch

147e83
# commit 62a728aeff93507ce5975f245a5f1d2046fb4503
147e83
# Author: Alan Modra <amodra@gmail.com>
147e83
# Date:   Sat Aug 17 18:27:19 2013 +0930
147e83
# 
147e83
#     PowerPC floating point little-endian [6 of 15]
147e83
#     http://sourceware.org/ml/libc-alpha/2013-07/msg00197.html
147e83
#     
147e83
#     A rewrite to make this code correct for little-endian.
147e83
#     
147e83
#         * sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c (mynumber): Replace
147e83
#         union 32-bit int array member with 64-bit int array.
147e83
#         (t515, tm256): Double rather than long double.
147e83
#         (__ieee754_sqrtl): Rewrite using 64-bit arithmetic.
147e83
#
147e83
diff -urN glibc-2.17-c758a686/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c glibc-2.17-c758a686/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c
147e83
--- glibc-2.17-c758a686/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c	2014-05-27 22:20:12.000000000 -0500
147e83
+++ glibc-2.17-c758a686/sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c	2014-05-27 22:21:39.000000000 -0500
147e83
@@ -34,15 +34,13 @@
147e83
 
147e83
 #include <math_private.h>
147e83
 
147e83
-typedef unsigned int int4;
147e83
-typedef union {int4 i[4]; long double x; double d[2]; } mynumber;
147e83
+typedef union {int64_t i[2]; long double x; double d[2]; } mynumber;
147e83
 
147e83
-static const  mynumber
147e83
-  t512 = {{0x5ff00000, 0x00000000, 0x00000000, 0x00000000 }},  /* 2^512  */
147e83
-  tm256 = {{0x2ff00000, 0x00000000, 0x00000000, 0x00000000 }};  /* 2^-256 */
147e83
 static const double
147e83
-two54 = 1.80143985094819840000e+16, /* 0x4350000000000000 */
147e83
-twom54 = 5.55111512312578270212e-17; /* 0x3C90000000000000 */
147e83
+  t512 = 0x1p512,
147e83
+  tm256 = 0x1p-256,
147e83
+  two54 = 0x1p54,	/* 0x4350000000000000 */
147e83
+  twom54 = 0x1p-54;	/* 0x3C90000000000000 */
147e83
 
147e83
 /*********************************************************************/
147e83
 /* An ultimate sqrt routine. Given an IEEE double machine number x   */
147e83
@@ -54,56 +52,53 @@
147e83
   static const long double big = 134217728.0, big1 = 134217729.0;
147e83
   long double t,s,i;
147e83
   mynumber a,c;
147e83
-  int4 k, l, m;
147e83
-  int n;
147e83
+  uint64_t k, l;
147e83
+  int64_t m, n;
147e83
   double d;
147e83
 
147e83
   a.x=x;
147e83
-  k=a.i[0] & 0x7fffffff;
147e83
+  k=a.i[0] & INT64_C(0x7fffffffffffffff);
147e83
   /*----------------- 2^-1022  <= | x |< 2^1024  -----------------*/
147e83
-  if (k>0x000fffff && k<0x7ff00000) {
147e83
+  if (k>INT64_C(0x000fffff00000000) && k
147e83
     if (x < 0) return (big1-big1)/(big-big);
147e83
-    l = (k&0x001fffff)|0x3fe00000;
147e83
-    if (((a.i[2] & 0x7fffffff) | a.i[3]) != 0) {
147e83
-      n = (int) ((l - k) * 2) >> 21;
147e83
-      m = (a.i[2] >> 20) & 0x7ff;
147e83
+    l = (k&INT64_C(0x001fffffffffffff))|INT64_C(0x3fe0000000000000);
147e83
+    if ((a.i[1] & INT64_C(0x7fffffffffffffff)) != 0) {
147e83
+      n = (int64_t) ((l - k) * 2) >> 53;
147e83
+      m = (a.i[1] >> 52) & 0x7ff;
147e83
       if (m == 0) {
147e83
 	a.d[1] *= two54;
147e83
-	m = ((a.i[2] >> 20) & 0x7ff) - 54;
147e83
+	m = ((a.i[1] >> 52) & 0x7ff) - 54;
147e83
       }
147e83
       m += n;
147e83
-      if ((int) m > 0)
147e83
-	a.i[2] = (a.i[2] & 0x800fffff) | (m << 20);
147e83
-      else if ((int) m <= -54) {
147e83
-	a.i[2] &= 0x80000000;
147e83
-	a.i[3] = 0;
147e83
+      if (m > 0)
147e83
+	a.i[1] = (a.i[1] & INT64_C(0x800fffffffffffff)) | (m << 52);
147e83
+      else if (m <= -54) {
147e83
+	a.i[1] &= INT64_C(0x8000000000000000);
147e83
       } else {
147e83
 	m += 54;
147e83
-	a.i[2] = (a.i[2] & 0x800fffff) | (m << 20);
147e83
+	a.i[1] = (a.i[1] & INT64_C(0x800fffffffffffff)) | (m << 52);
147e83
 	a.d[1] *= twom54;
147e83
       }
147e83
     }
147e83
     a.i[0] = l;
147e83
     s = a.x;
147e83
     d = __ieee754_sqrt (a.d[0]);
147e83
-    c.i[0] = 0x20000000+((k&0x7fe00000)>>1);
147e83
+    c.i[0] = INT64_C(0x2000000000000000)+((k&INT64_C(0x7fe0000000000000))>>1);
147e83
     c.i[1] = 0;
147e83
-    c.i[2] = 0;
147e83
-    c.i[3] = 0;
147e83
     i = d;
147e83
     t = 0.5L * (i + s / i);
147e83
     i = 0.5L * (t + s / t);
147e83
     return c.x * i;
147e83
   }
147e83
   else {
147e83
-    if (k>=0x7ff00000) {
147e83
-      if (a.i[0] == 0xfff00000 && a.i[1] == 0)
147e83
+    if (k>=INT64_C(0x7ff0000000000000)) {
147e83
+      if (a.i[0] == INT64_C(0xfff0000000000000))
147e83
 	return (big1-big1)/(big-big); /* sqrt (-Inf) = NaN.  */
147e83
       return x; /* sqrt (NaN) = NaN, sqrt (+Inf) = +Inf.  */
147e83
     }
147e83
     if (x == 0) return x;
147e83
     if (x < 0) return (big1-big1)/(big-big);
147e83
-    return tm256.x*__ieee754_sqrtl(x*t512.x);
147e83
+    return tm256*__ieee754_sqrtl(x*t512);
147e83
   }
147e83
 }
147e83
 strong_alias (__ieee754_sqrtl, __sqrtl_finite)