about summary refs log tree commit diff
path: root/sysdeps/powerpc
diff options
context:
space:
mode:
authorAnton Blanchard <anton@au1.ibm.com>2013-08-17 18:28:06 +0930
committerAlan Modra <amodra@gmail.com>2013-10-04 10:34:14 +0930
commit2ca85d2bbbaa60b9c83bf1f57a2801c84e0a3625 (patch)
tree64d8544674cafe97205b19fdf8595083220add1c /sysdeps/powerpc
parent62a728aeff93507ce5975f245a5f1d2046fb4503 (diff)
downloadglibc-2ca85d2bbbaa60b9c83bf1f57a2801c84e0a3625.tar.gz
glibc-2ca85d2bbbaa60b9c83bf1f57a2801c84e0a3625.tar.xz
glibc-2ca85d2bbbaa60b9c83bf1f57a2801c84e0a3625.zip
PowerPC floating point little-endian [7 of 15]
http://sourceware.org/ml/libc-alpha/2013-08/msg00086.html

	* sysdeps/powerpc/bits/mathinline.h (__signbitf): Use builtin.
	(__signbit): Likewise.  Correct for little-endian.
	(__signbitl): Call __signbit.
	(lrint): Correct for little-endian.
	(lrintf): Call lrint.
Diffstat (limited to 'sysdeps/powerpc')
-rw-r--r--sysdeps/powerpc/bits/mathinline.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/sysdeps/powerpc/bits/mathinline.h b/sysdeps/powerpc/bits/mathinline.h
index 140fff08ef..cef5b29b14 100644
--- a/sysdeps/powerpc/bits/mathinline.h
+++ b/sysdeps/powerpc/bits/mathinline.h
@@ -61,21 +61,28 @@
 __MATH_INLINE int
 __NTH (__signbitf (float __x))
 {
+#if __GNUC_PREREQ (4, 0)
+  return __builtin_signbitf (__x);
+#else
   __extension__ union { float __f; int __i; } __u = { __f: __x };
   return __u.__i < 0;
+#endif
 }
 __MATH_INLINE int
 __NTH (__signbit (double __x))
 {
-  __extension__ union { double __d; int __i[2]; } __u = { __d: __x };
-  return __u.__i[0] < 0;
+#if __GNUC_PREREQ (4, 0)
+  return __builtin_signbit (__x);
+#else
+  __extension__ union { double __d; long long __i; } __u = { __d: __x };
+  return __u.__i < 0;
+#endif
 }
 #  ifdef __LONG_DOUBLE_128__
 __MATH_INLINE int
 __NTH (__signbitl (long double __x))
 {
-  __extension__ union { long double __d; int __i[4]; } __u = { __d: __x };
-  return __u.__i[0] < 0;
+  return __signbit ((double) __x);
 }
 #  endif
 # endif
@@ -92,22 +99,17 @@ __NTH (lrint (double __x))
 {
   union {
     double __d;
-    int __ll[2];
+    long long __ll;
   } __u;
   __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x));
-  return __u.__ll[1];
+  return __u.__ll;
 }
 
 __MATH_INLINE long int lrintf (float __x) __THROW;
 __MATH_INLINE long int
 __NTH (lrintf (float __x))
 {
-  union {
-    double __d;
-    int __ll[2];
-  } __u;
-  __asm__ ("fctiw %0,%1" : "=f"(__u.__d) : "f"(__x));
-  return __u.__ll[1];
+  return lrint ((double) __x);
 }
 # endif