diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | sysdeps/powerpc/bits/mathinline.h | 26 |
2 files changed, 22 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog index dcb7deef9b..f03095c54c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2013-10-04 Anton Blanchard <anton@au1.ibm.com> + + * 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. + 2013-10-04 Alan Modra <amodra@gmail.com> * sysdeps/ieee754/ldbl-128ibm/e_sqrtl.c (mynumber): Replace 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 |