Added Redirects to longdouble error functions [BZ #29033]

Message ID 20230220071715.3736520-1-smonga@linux.ibm.com
State Superseded
Headers
Series Added Redirects to longdouble error functions [BZ #29033] |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit fail Patch caused testsuite regressions

Commit Message

Sachin Monga Feb. 20, 2023, 7:17 a.m. UTC
  This patch redirects the error functions to the appropriate
longdouble variants which enables the compiler to optimize
for the abi ieeelongdouble.

Signed-off-by: Sachin Monga <smonga@linux.ibm.com>
---
 misc/bits/error-ldbl.h | 53 ++++++++++++++++++++++++++++++++++++++++--
 misc/sys/cdefs.h       |  3 ++-
 2 files changed, 53 insertions(+), 3 deletions(-)
  

Comments

Florian Weimer Feb. 21, 2023, 10:16 a.m. UTC | #1
* Sachin Monga via Libc-alpha:

> This patch redirects the error functions to the appropriate
> longdouble variants which enables the compiler to optimize
> for the abi ieeelongdouble.

Thanks.

I started a new thread regarding the <sys/cdefs.h> update:

  From: Florian Weimer <fweimer@redhat.com>
  Subject: Updating <sys/cdefs.h> in glibc and gnulib
  To: libc-alpha@sourceware.org, bug-gnulib@gnu.org
  Cc: Sachin Monga <smonga@linux.ibm.com>
  Date: Tue, 21 Feb 2023 11:14:57 +0100 (55 seconds ago)
  Message-ID: <87ilfvqq8u.fsf@oldenburg.str.redhat.com>

Florian
  

Patch

diff --git a/misc/bits/error-ldbl.h b/misc/bits/error-ldbl.h
index 599a7d6e06..638e030c96 100644
--- a/misc/bits/error-ldbl.h
+++ b/misc/bits/error-ldbl.h
@@ -20,5 +20,54 @@ 
 # error "Never include <bits/error-ldbl.h> directly; use <error.h> instead."
 #endif
 
-__LDBL_REDIR_DECL (error)
-__LDBL_REDIR_DECL (error_at_line)
+
+extern void __REDIRECT_LDBL (__error_alias, (int __status, int __errnum,
+					const char *__format, ...),
+			error)
+  __attribute__ ((__format__ (__printf__, 3, 4)));
+extern void __REDIRECT_LDBL (__error_noreturn, (int __status, int __errnum,
+					   const char *__format, ...),
+			error)
+  __attribute__ ((__noreturn__, __format__ (__printf__, 3, 4)));
+
+
+/* If we know the function will never return make sure the compiler
+   realizes that, too.  */
+__extern_always_inline void
+error (int __status, int __errnum, const char *__format, ...)
+{
+  if (__builtin_constant_p (__status) && __status != 0)
+    __error_noreturn (__status, __errnum, __format, __va_arg_pack ());
+  else
+    __error_alias (__status, __errnum, __format, __va_arg_pack ());
+}
+
+
+extern void __REDIRECT_LDBL (__error_at_line_alias, (int __status, int __errnum,
+						const char *__fname,
+						unsigned int __line,
+						const char *__format, ...),
+			error_at_line)
+  __attribute__ ((__format__ (__printf__, 5, 6)));
+extern void __REDIRECT_LDBL (__error_at_line_noreturn, (int __status, int __errnum,
+						   const char *__fname,
+						   unsigned int __line,
+						   const char *__format,
+						   ...),
+			error_at_line)
+  __attribute__ ((__noreturn__, __format__ (__printf__, 5, 6)));
+
+
+/* If we know the function will never return make sure the compiler
+   realizes that, too.  */
+__extern_always_inline void
+error_at_line (int __status, int __errnum, const char *__fname,
+	       unsigned int __line, const char *__format, ...)
+{
+  if (__builtin_constant_p (__status) && __status != 0)
+    __error_at_line_noreturn (__status, __errnum, __fname, __line, __format,
+			      __va_arg_pack ());
+  else
+    __error_at_line_alias (__status, __errnum, __fname, __line,
+			   __format, __va_arg_pack ());
+}
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index 66d6702123..37b20fe3d6 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -567,6 +567,8 @@ 
 #  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
 #  define __LDBL_REDIR_DECL(name) \
   extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+#  define __REDIRECT_LDBL(name, proto, alias) \
+  name proto __asm (__ASMNAME ("__" #alias "ieee128"))
 
 /* Alias name defined automatically, with leading underscores.  */
 #  define __LDBL_REDIR2_DECL(name) \
@@ -584,7 +586,6 @@ 
   __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