]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Changes to compile glibc-2.27 on PPC (Power8) with clang.
authorRaman Tenneti <rtenneti@google.com>
Fri, 27 Aug 2021 23:36:05 +0000 (16:36 -0700)
committerFangrui Song <i@maskray.me>
Sat, 28 Aug 2021 00:23:15 +0000 (17:23 -0700)
+ Use DOT_MACHINE macro instead of ".machine" instruction.
+ Use __isinf and __isinff instead of builtin versions.
+ In s_logb, s_logbf and s_logbl functions, used float versions to
  calculate "ret = x & 0x7f800000;" expression.

sysdeps/powerpc/power5+/fpu/s_modf.c
sysdeps/powerpc/power5+/fpu/s_modff.c
sysdeps/powerpc/power7/fpu/s_logb.c
sysdeps/powerpc/power7/fpu/s_logbf.c
sysdeps/powerpc/power7/fpu/s_logbl.c

index 7a32d313032ffe73f294c17007760a6542a73531..041f2153ffc62a4b178356c222ead36d174525b2 100644 (file)
 double
 __modf (double x, double *iptr)
 {
+  /* Google-specific: Fix for clang. */
+#if defined __clang__
+  if (__isinf (x))
+#else
   if (__builtin_isinf (x))
+#endif
     {
       *iptr = x;
       return __copysign (0.0, x);
     }
+  /* Google-specific: Fix for clang. */
+#if defined __clang__
+  else if (__isnan (x))
+#else
   else if (__builtin_isnan (x))
+#endif
     {
       *iptr = NAN;
       return NAN;
index c1bbae64799067bccdddbf4c164302df91b92dff..3b7460593522fdc57374c4f955cbec94d508899b 100644 (file)
 float
 __modff (float x, float *iptr)
 {
+  /* Google-specific: Fix for clang. */
+#if defined __clang__
+  if (__isinff (x))
+#else
   if (__builtin_isinff (x))
+#endif
     {
       *iptr = x;
       return __copysignf (0.0, x);
     }
+  /* Google-specific: Fix for clang. */
+#if defined __clang__
+  else if (__isnanf (x))
+#else
   else if (__builtin_isnanf (x))
+#endif
     {
       *iptr = NAN;
       return NAN;
index 160b9334de76298129bf98bde7d01d570f2b929c..40a689725db36af8190759f1575bfa8b85641795 100644 (file)
@@ -17,6 +17,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <math_ldbl_opt.h>
+#include <math_private.h>
 #include <libm-alias-double.h>
 
 /* This implementation avoids FP to INT conversions by using VSX
@@ -41,11 +42,19 @@ __logb (double x)
     return -1.0 / __builtin_fabs (x);
 
   /* ret = x & 0x7ff0000000000000;  */
+#if !defined __clang__
   asm (
     "xxland %x0,%x1,%x2\n"
     "fcfid  %0,%0"
     : "=f" (ret)
     : "f" (x), "f" (mask.d));
+#else
+  /* TODO(rtenneti): This is wrong. Handle double */
+  int64_t inum;
+  GET_FLOAT_WORD(inum, x);
+  inum = (inum & 0x7ff0000000000000);
+  SET_FLOAT_WORD(ret, inum);
+#endif
   /* ret = (ret >> 52) - 1023.0;  */
   ret = (ret * two1div52) + two10m1;
   if (__builtin_expect (ret > -two10m1, 0))
index 0832ad70225e0b05500a70261346106abd229733..0da0f374906017ff0d69e5774e012b165d84685f 100644 (file)
@@ -43,11 +43,18 @@ __logbf (float x)
     return -1.0 / __builtin_fabsf (x);
 
   /* ret = x & 0x7f800000;  */
+#if !defined __clang__
   asm (
     "xxland %x0,%x1,%x2\n"
     "fcfid  %0,%0"
     : "=f"(ret)
     : "f" (x), "f" (mask.d));
+#else
+  int32_t inum;
+  GET_FLOAT_WORD(inum, x);
+  inum = (inum & 0x7ff0000000000000);
+  SET_FLOAT_WORD(ret, inum);
+#endif
   /* ret = (ret >> 52) - 1023.0, since ret is double.  */
   ret = (ret * two1div52) + two10m1;
   if (__builtin_expect (ret > -two7m1, 0))
index 192145a7a1b904fc85833c56ccf300935ed9719c..997dfcf8fbc2d11068065ba04d88f7755ddb3a33 100644 (file)
@@ -46,11 +46,19 @@ __logbl (long double x)
   ldbl_unpack (x, &xh, &xl);
   EXTRACT_WORDS64 (hx, xh);
   /* ret = x & 0x7ff0000000000000;  */
+#if !defined __clang__
   asm (
     "xxland %x0,%x1,%x2\n"
     "fcfid  %0,%0"
     : "=f" (ret)
     : "f" (xh), "f" (mask.d));
+#else
+  /* TODO(rtenneti): This is wrong. Handle double */
+  int64_t inum;
+  GET_FLOAT_WORD(inum, x);
+  inum = (inum & 0x7ff0000000000000);
+  SET_FLOAT_WORD(ret, inum);
+#endif
   /* ret = (ret >> 52) - 1023.0;  */
   ret = (ret * two1div52) + two10m1;
   if (__builtin_expect (ret > -two10m1, 0))