ce426f
# commit 2ca85d2bbbaa60b9c83bf1f57a2801c84e0a3625
ce426f
# Author: Anton Blanchard <anton@au1.ibm.com>
ce426f
# Date:   Sat Aug 17 18:28:06 2013 +0930
ce426f
# 
ce426f
#     PowerPC floating point little-endian [7 of 15]
ce426f
#     http://sourceware.org/ml/libc-alpha/2013-08/msg00086.html
ce426f
#     
ce426f
#         * sysdeps/powerpc/bits/mathinline.h (__signbitf): Use builtin.
ce426f
#         (__signbit): Likewise.  Correct for little-endian.
ce426f
#         (__signbitl): Call __signbit.
ce426f
#         (lrint): Correct for little-endian.
ce426f
#         (lrintf): Call lrint.
ce426f
# 
ce426f
diff -urN glibc-2.17-c758a686/sysdeps/powerpc/fpu/bits/mathinline.h glibc-2.17-c758a686/sysdeps/powerpc/fpu/bits/mathinline.h
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/fpu/bits/mathinline.h	2014-05-27 22:28:12.000000000 -0500
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/fpu/bits/mathinline.h	2014-05-27 22:28:37.000000000 -0500
ce426f
@@ -62,21 +62,28 @@
ce426f
 __MATH_INLINE int
ce426f
 __NTH (__signbitf (float __x))
ce426f
 {
ce426f
+#if __GNUC_PREREQ (4, 0)
ce426f
+  return __builtin_signbitf (__x);
ce426f
+#else
ce426f
   __extension__ union { float __f; int __i; } __u = { __f: __x };
ce426f
   return __u.__i < 0;
ce426f
+#endif
ce426f
 }
ce426f
 __MATH_INLINE int
ce426f
 __NTH (__signbit (double __x))
ce426f
 {
ce426f
-  __extension__ union { double __d; int __i[2]; } __u = { __d: __x };
ce426f
-  return __u.__i[0] < 0;
ce426f
+#if __GNUC_PREREQ (4, 0)
ce426f
+  return __builtin_signbit (__x);
ce426f
+#else
ce426f
+  __extension__ union { double __d; long long __i; } __u = { __d: __x };
ce426f
+  return __u.__i < 0;
ce426f
+#endif
ce426f
 }
ce426f
 #  ifdef __LONG_DOUBLE_128__
ce426f
 __MATH_INLINE int
ce426f
 __NTH (__signbitl (long double __x))
ce426f
 {
ce426f
-  __extension__ union { long double __d; int __i[4]; } __u = { __d: __x };
ce426f
-  return __u.__i[0] < 0;
ce426f
+  return __signbit ((double) __x);
ce426f
 }
ce426f
 #  endif
ce426f
 # endif
ce426f
@@ -93,22 +100,17 @@
ce426f
 {
ce426f
   union {
ce426f
     double __d;
ce426f
-    int __ll[2];
ce426f
+    long long __ll;
ce426f
   } __u;
ce426f
   __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x));
ce426f
-  return __u.__ll[1];
ce426f
+  return __u.__ll;
ce426f
 }
ce426f
 
ce426f
 __MATH_INLINE long int lrintf (float __x) __THROW;
ce426f
 __MATH_INLINE long int
ce426f
 __NTH (lrintf (float __x))
ce426f
 {
ce426f
-  union {
ce426f
-    double __d;
ce426f
-    int __ll[2];
ce426f
-  } __u;
ce426f
-  __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x));
ce426f
-  return __u.__ll[1];
ce426f
+  return lrint ((double) __x);
ce426f
 }
ce426f
 # endif
ce426f