bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Merge glibc ieee128 ldbl redirect support into cdefs.h


From: Paul E Murphy
Subject: [PATCH] Merge glibc ieee128 ldbl redirect support into cdefs.h
Date: Thu, 10 Dec 2020 17:08:32 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

While trying to build gdb with ldbl == ieee128 on ppc64le, we found out
gnulib's copy of cdefs.h needs to be synchronized with upstream glibc.

The only notable divergence is to ensure
__LDOUBLE_REDIRECTS_TO_FLOAT128_ABI is always defined as this macro is
fairly recent.

---8<---
* lib/cdefs.h [__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR):
New macros synchronized from upstream glibc.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR_DECL): Likewise.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR2_DECL): Likewise.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR1): Likewise.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR1_DECL): Likewise.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR1_NTH): Likewise.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__REDIRECT_LDBL): Likewise.
[__LDOUBLE_REDIECTS_TO_FLOAT128_ABI == 1](__LDBL_REDIR_NTH): Likewise.
* lib/cdefs.h [__LONG_DOUBLE_MATH_OPTIONAL][__NO_LONG_DOUBLE_MATH](__LDBL_REDIR2_DECL):
Likewise.
* lib/cdefs.h [!__LDOUBLE_REDIECTS_TO_FLOAT128_ABI](__LDOUBLE_REDIECTS_TO_FLOAT128_ABI):
Define to 0 if glibc headers do not provide this definition.
* lib/libc-config.h (__LDBL_REDIR2_DECL): Undefine new ldbl redirect macro.
---
 lib/cdefs.h       | 42 ++++++++++++++++++++++++++++++++++++++++--
 lib/libc-config.h |  1 +
 2 files changed, 41 insertions(+), 2 deletions(-)

diff --git a/lib/cdefs.h b/lib/cdefs.h
index b4ac4df66..cb2d289fa 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -483,7 +483,42 @@
 # include <bits/long-double.h>
 #endif
 -#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+/* Versions of glibc prior to 2.32 may not define this macro.  */
+#ifndef __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI
+#  define __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI 0
+#endif
+
+#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
+# ifdef __REDIRECT
+
+/* Alias name defined automatically.  */
+#  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
+#  define __LDBL_REDIR_DECL(name) \
+  extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined automatically, with leading underscores.  */
+#  define __LDBL_REDIR2_DECL(name) \
+  extern __typeof (__##name) __##name \
+    __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined manually.  */
+#  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
+#  define __LDBL_REDIR1_DECL(name, alias) \
+  extern __typeof (name) name __asm (__ASMNAME (#alias));
+
+#  define __LDBL_REDIR1_NTH(name, proto, alias) \
+  __REDIRECT_NTH (name, proto, alias)
+#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
+  __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
+
+/* Unused.  */
+#  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
+#  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
+
+# else
+_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
+# endif
+#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
 # define __LDBL_COMPAT 1
 # ifdef __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -492,6 +527,8 @@
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
 #  define __LDBL_REDIR_NTH(name, proto) \
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+#  define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
 #  define __LDBL_REDIR1_DECL(name, alias) \
   extern __typeof (name) name __asm (__ASMNAME (#alias));
 #  define __LDBL_REDIR_DECL(name) \
@@ -502,7 +539,8 @@
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
 # endif
 #endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
+    || !defined __REDIRECT
 # define __LDBL_REDIR1(name, proto, alias) name proto
 # define __LDBL_REDIR(name, proto) name proto
 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
diff --git a/lib/libc-config.h b/lib/libc-config.h
index 59cfbe5cb..613cf06d6 100644
--- a/lib/libc-config.h
+++ b/lib/libc-config.h
@@ -100,6 +100,7 @@
 #undef __LDBL_REDIR
 #undef __LDBL_REDIR1
 #undef __LDBL_REDIR1_DECL
+#undef __LDBL_REDIR2_DECL
 #undef __LDBL_REDIR1_NTH
 #undef __LDBL_REDIR_DECL
 #undef __LDBL_REDIR_NTH
--
2.26.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]