summary refs log tree commit diff
path: root/sysdeps/ia64
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2017-06-29 15:34:05 -0300
committerGabriel F. T. Gomes <gftg@linux.vnet.ibm.com>2017-06-30 18:34:29 -0300
commit8466ee1cb7c2041d8471dad0aa53af35ab599012 (patch)
treeb448538ed77b0a029712d8ba134b18675d5c1413 /sysdeps/ia64
parent9b8f8593e5d919d8ea9a5f21ce7473246651ec2f (diff)
downloadglibc-8466ee1cb7c2041d8471dad0aa53af35ab599012.tar.gz
glibc-8466ee1cb7c2041d8471dad0aa53af35ab599012.tar.xz
glibc-8466ee1cb7c2041d8471dad0aa53af35ab599012.zip
float128: Add signbit alternative for old compilers
In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
e.g.: __builtin_signbitf128, before GCC 6.  However, there has never
been a __builtin_signbitf128 in GCC and the type-generic builtin is
only available since GCC 6.  For older GCC, this patch defines
__builtin_signbitf128 to __signbitf128, so that the internal function
is used instead of the non-existent builtin.

This patch also changes the implementation of __signbitf128, because
it was reusing the implementation of __signbitl from ldbl-128, which
calls __builtin_signbitl.  Using the long double version of the
builtin is not correct on machines where _Float128 is ABI-distinct
from long double (i.e.: ia64, powerpc64le, x86, x86_84).  The new
implementation does not rely on builtins when being built with GCC
versions older than 6.0.

The new code does not currently affect powerpc64le builds, because
only GCC 6.2 fulfills the requirements from configure.  It might
affect powerpc64le builds if those requirements are backported to
older versions of the compiler.  The new code affects x86_64 builds,
since glibc is supposed to build correctly with older versions of GCC.

Tested for powerpc64le and x86_64.

	* include/math.h (__signbitf128): Define as hidden.
	* sysdeps/ieee754/float128/s_signbitf128.c (__signbitf128):
	Reimplement without builtins.
	* sysdeps/ia64/bits/floatn.h [!__GNUC_PREREQ (6, 0)]
	(__builtin_signbitf128): Define to __signbitf128.
	* sysdeps/powerpc/bits/floatn.h: Likewise.
	* sysdeps/x86/bits/floatn.h: Likewise.
Diffstat (limited to 'sysdeps/ia64')
-rw-r--r--sysdeps/ia64/bits/floatn.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sysdeps/ia64/bits/floatn.h b/sysdeps/ia64/bits/floatn.h
index c7b1df6d2c..dbb6eb2325 100644
--- a/sysdeps/ia64/bits/floatn.h
+++ b/sysdeps/ia64/bits/floatn.h
@@ -89,6 +89,14 @@ typedef __float128 _Float128;
 #  define __builtin_nansf128(x) ((_Float128) __builtin_nans (x))
 # endif
 
+/* In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
+   e.g.: __builtin_signbitf128, before GCC 6.  However, there has never
+   been a __builtin_signbitf128 in GCC and the type-generic builtin is
+   only available since GCC 6.  */
+# if !__GNUC_PREREQ (6, 0)
+#  define __builtin_signbitf128 __signbitf128
+# endif
+
 #endif
 
 #endif /* _BITS_FLOATN_H */