]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
ldbl-opt: Add error and error_at_line (bug 23984)
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Wed, 8 Aug 2018 20:26:22 +0000 (17:26 -0300)
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>
Fri, 1 Mar 2019 18:26:36 +0000 (15:26 -0300)
On platforms where long double may have the same format as double
(-mlong-double-64), error and error_at_line do not take that into
account and might produce wrong output if a long double conversion is
requested by the format string ('%Lf').  This patch adds compatibility
functions for this situation and redirects calls via header magic.

Tested for powerpc, powerpc64 and powerpc64le.

17 files changed:
ChangeLog
include/bits/error-ldbl.h [new file with mode: 0644]
include/error.h
misc/Makefile
misc/bits/error-ldbl.h [new file with mode: 0644]
misc/error.h
sysdeps/ieee754/ldbl-opt/Versions
sysdeps/ieee754/ldbl-opt/nldbl-compat.c
sysdeps/ieee754/ldbl-opt/nldbl-compat.h
sysdeps/unix/sysv/linux/alpha/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist

index 37183907e723b94d8aaff5b04aabaac7cd526fcb..886af2b2adfe1f4de51f502b771cd044178569e4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2019-03-01  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
+
+       [BZ #23984]
+       * include/bits/error-ldbl.h: New file.
+       * include/error.h: Include stdarg.h.  Declare internal functions
+       __error_internal and __error_at_line_internal.
+       * misc/Makefile (headers): Add bits/error-ldbl.h.
+       * misc/bits/error-ldbl.h: New file.
+       * misc/error.h [__LDBL_COMPAT]: Include bits/error-ldbl.h and
+       avoid the inclusion of bits/error.h.
+       * sysdeps/ieee754/ldbl-opt/Versions (libc): Add __nldbl_error,
+       and __nldbl_error_at_line.
+       * sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Include error.h.
+       (__nldbl_error, __ndlbl_error_at_line): New functions.
+       * sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include error.h.
+       Redirect error and error_at_line.
+       * sysdeps/unix/sysv/linux/alpha/libc.abilist: Update.
+       * sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
+       Likewise.
+       * sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
+       Likewise.
+       * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist:
+       Likewise.
+       * sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist:
+       Likewise.
+       * sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
+       * sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
+       * sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
+
 2019-03-01  Gabriel F. T. Gomes  <gabriel@inconstante.eti.br>
 
        [BZ #23984]
diff --git a/include/bits/error-ldbl.h b/include/bits/error-ldbl.h
new file mode 100644 (file)
index 0000000..84b2646
--- /dev/null
@@ -0,0 +1 @@
+#include <misc/bits/error-ldbl.h>
index 70f3192fa6bf81962f3bec92a6394f2ba097d0bd..9e96262fc5ac3aa4e4b28911d02f3a9cc91f4aae 100644 (file)
@@ -1 +1,15 @@
+#ifndef _ERROR_H
 #include <misc/error.h>
+
+#include <stdarg.h>
+
+void
+__error_internal (int status, int errnum, const char *message,
+                 va_list args, unsigned int mode_flags);
+
+void
+__error_at_line_internal (int status, int errnum, const char *file_name,
+                         unsigned int line_number, const char *message,
+                         va_list args, unsigned int mode_flags);
+
+#endif
index 6cb660bd3e24deaf4ff24d52cddbd46b8d298ed0..032f28fc38e5a4e1ac0b37e4de943b8e6f733931 100644 (file)
@@ -37,7 +37,7 @@ headers       := sys/uio.h bits/uio-ext.h bits/uio_lim.h \
           bits/syslog.h bits/syslog-ldbl.h bits/syslog-path.h bits/error.h \
           bits/select2.h bits/hwcap.h sys/auxv.h \
           sys/sysmacros.h bits/sysmacros.h bits/types/struct_iovec.h \
-          bits/err-ldbl.h
+          bits/err-ldbl.h bits/error-ldbl.h
 
 routines := brk sbrk sstk ioctl \
            readv writev preadv preadv64 pwritev pwritev64 \
diff --git a/misc/bits/error-ldbl.h b/misc/bits/error-ldbl.h
new file mode 100644 (file)
index 0000000..c3883da
--- /dev/null
@@ -0,0 +1,24 @@
+/* Redirections for error.h functions for -mlong-double-64.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _ERROR_H
+# error "Never include <bits/error-ldbl.h> directly; use <error.h> instead."
+#endif
+
+__LDBL_REDIR_DECL (error)
+__LDBL_REDIR_DECL (error_at_line)
index 34d4a6d4c682da6771d7b2332df0ebfb1d58819f..ba0c9293ed6c419f10257d0a07cc4477d146c3c8 100644 (file)
@@ -47,9 +47,15 @@ extern unsigned int error_message_count;
    variable controls whether this mode is selected or not.  */
 extern int error_one_per_line;
 
-
-#if defined __extern_always_inline && defined __va_arg_pack
-# include <bits/error.h>
+#ifdef __LDBL_COMPAT
+# include <bits/error-ldbl.h>
+#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
+   compatibility functions.  */
+# if defined __extern_always_inline && defined __va_arg_pack
+#  include <bits/error.h>
+# endif
 #endif
 
 __END_DECLS
index 5d6051a12d892c7480538ec5049bf97afa465ad4..21a2db68885d8a481562ab53f3f8b05a4e6fbe2d 100644 (file)
@@ -82,6 +82,7 @@ libc {
     __nldbl_argp_error; __nldbl_argp_failure;
     __nldbl_warn; __nldbl_vwarn; __nldbl_warnx; __nldbl_vwarnx;
     __nldbl_err; __nldbl_verr; __nldbl_errx; __nldbl_verrx;
+    __nldbl_error; __nldbl_error_at_line;
   }
 }
 libm {
index 6883814d58c256ef9de0cc348b2f34efc393f5b0..86ac418007ee81c09b8ad6a9bf4776065aa4c25d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include <argp.h>
 #include <err.h>
+#include <error.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <libio/strfile.h>
@@ -1072,6 +1073,27 @@ __nldbl_vwarnx (const char *format, __gnuc_va_list ap)
   __vwarnx_internal (format, ap, PRINTF_LDBL_IS_DBL);
 }
 
+void
+__nldbl_error (int status, int errnum, const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  __error_internal (status, errnum, message, ap, PRINTF_LDBL_IS_DBL);
+  va_end (ap);
+}
+
+void
+__nldbl_error_at_line (int status, int errnum, const char *file_name,
+                      unsigned int line_number, const char *message,
+                      ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  __error_at_line_internal (status, errnum, file_name, line_number,
+                           message, ap, PRINTF_LDBL_IS_DBL);
+  va_end (ap);
+}
+
 #if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
 compat_symbol (libc, __nldbl__IO_printf, _IO_printf, GLIBC_2_0);
 compat_symbol (libc, __nldbl__IO_sprintf, _IO_sprintf, GLIBC_2_0);
index eeda11b42097641f43065e425c8ac4ee5985bcb3..aed1cc1497e4d28e97fc873d319dde822a59f219 100644 (file)
@@ -28,6 +28,7 @@
 #define __NO_LONG_DOUBLE_MATH  1
 #include <argp.h>
 #include <err.h>
+#include <error.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -88,6 +89,8 @@ NLDBL_DECL (err);
 NLDBL_DECL (verr);
 NLDBL_DECL (errx);
 NLDBL_DECL (verrx);
+NLDBL_DECL (error);
+NLDBL_DECL (error_at_line);
 
 /* These do not exist in the normal interface, but must exist in the
    __nldbl interface so that they can be called from libnldbl.  */
index 1b95af13bcd1df067bd1a88d6fb0c00b7a060572..fd81fc4ad0ed1f267e13224e26f545c012045d52 100644 (file)
@@ -2207,6 +2207,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index 8973a44b56ec324164324776db204897191327fd..a701584422ba83fcf3d326fab08080e75f4b396e 100644 (file)
@@ -2167,6 +2167,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index c89ca3efaa9defcc47541cd3507786d8d942feb4..bbb647cd98a874f113f43c49ac497bbb3c034762 100644 (file)
@@ -2200,6 +2200,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index 1b0f108c19fcf5efa247aad8bbf8f08987ed4335..bb23bf61a83f509e3906f31560c6a3d938a4097e 100644 (file)
@@ -2030,6 +2030,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index 02504aeb586477e6d68627959495f042a8e67084..7921dda97947602a2d181d7ee6891d35e3dba339 100644 (file)
@@ -2234,6 +2234,8 @@ GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index c46f1119d464a68b4c3a42b8b5e525646e5eb39d..2aed339af4e7bf83d0156cd07cc86331871809ac 100644 (file)
@@ -2162,6 +2162,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index 47b0be5e5042b3f3f3ef55725a631d9eadec45be..e46feb56e5ce54950ea4dc60a0d83bc5440719bd 100644 (file)
@@ -2066,6 +2066,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F
index 854708e37c75caa0cad7116787b8c892570bedaa..ebdbd2c5aee53a82c2db3a58e452aa25dd29da57 100644 (file)
@@ -2156,6 +2156,8 @@ GLIBC_2.3.4 xdr_u_quad_t F
 GLIBC_2.30 __nldbl_argp_error F
 GLIBC_2.30 __nldbl_argp_failure F
 GLIBC_2.30 __nldbl_err F
+GLIBC_2.30 __nldbl_error F
+GLIBC_2.30 __nldbl_error_at_line F
 GLIBC_2.30 __nldbl_errx F
 GLIBC_2.30 __nldbl_verr F
 GLIBC_2.30 __nldbl_verrx F