From e4a399921390509418826e8e8995d2441f29e243 Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Thu, 19 Dec 2019 12:06:09 -0300 Subject: Prepare redirections for IEEE long double on powerpc64le All functions that have a format string, which can consume a long double argument, must have one version for each long double format supported on a platform. On powerpc64le, these functions currently have two versions (i.e.: long double with the same format as double, and long double with IBM Extended Precision format). Support for a third long double format option (i.e. long double with IEEE long double format) is being prepared and all the aforementioned functions now have a third version (not yet exported on the master branch, but the code is in). For these functions to get selected (during build time), references to them in user programs (or dependent libraries) must get redirected to the aforementioned new versions of the functions. This patch installs the header magic required to perform such redirections. Notice, however, that since the redirections only happen when __LONG_DOUBLE_USES_FLOAT128 is set to 1, and no platform (including powerpc64le) currently does it, no redirections actually happen. Redirections and the exporting of the new functions will happen at the same time (when powerpc64le adds ldbl-128ibm-compat to their Implies. Reviewed-by: Tulio Magno Quites Machado Filho Reviewed-by: Paul E. Murphy --- misc/bits/syslog-ldbl.h | 4 ++-- misc/err.h | 3 ++- misc/error.h | 6 ++++-- misc/sys/cdefs.h | 38 ++++++++++++++++++++++++++++++++++++-- misc/sys/syslog.h | 4 +++- 5 files changed, 47 insertions(+), 8 deletions(-) (limited to 'misc') diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h index fead0d4..657b192 100644 --- a/misc/bits/syslog-ldbl.h +++ b/misc/bits/syslog-ldbl.h @@ -27,9 +27,9 @@ __LDBL_REDIR_DECL (vsyslog) #endif #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function -__LDBL_REDIR_DECL (__syslog_chk) +__LDBL_REDIR2_DECL (syslog_chk) # ifdef __USE_MISC -__LDBL_REDIR_DECL (__vsyslog_chk) +__LDBL_REDIR2_DECL (vsyslog_chk) # endif #endif diff --git a/misc/err.h b/misc/err.h index f6fd729..d146a55 100644 --- a/misc/err.h +++ b/misc/err.h @@ -52,7 +52,8 @@ extern void errx (int __status, const char *__format, ...) extern void verrx (int __status, const char *, __gnuc_va_list) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/misc/error.h b/misc/error.h index a456695..bb8a3b2 100644 --- a/misc/error.h +++ b/misc/error.h @@ -47,11 +47,13 @@ extern unsigned int error_message_count; variable controls whether this mode is selected or not. */ extern int error_one_per_line; -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #else /* Do not inline error and error_at_line when long double has the same - size of double, because that would invalidate the redirections to the + size of double, nor when long double reuses the float128 + implementation, because that would invalidate the redirections to the compatibility functions. */ # if defined __extern_always_inline && defined __va_arg_pack # include diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index ff7144f..dd5f69f 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -452,7 +452,37 @@ #include #include -#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH +#if __LONG_DOUBLE_USES_FLOAT128 == 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) @@ -461,6 +491,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) \ @@ -471,11 +503,13 @@ __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias) # endif #endif -#if !defined __LDBL_COMPAT || !defined __REDIRECT +#if (!defined __LDBL_COMPAT && __LONG_DOUBLE_USES_FLOAT128 == 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 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW +# define __LDBL_REDIR2_DECL(name) # define __LDBL_REDIR_DECL(name) # ifdef __REDIRECT # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h index ee01478..c000b8e 100644 --- a/misc/sys/syslog.h +++ b/misc/sys/syslog.h @@ -206,7 +206,9 @@ extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap) #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include #endif -#ifdef __LDBL_COMPAT + +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif -- cgit v1.1