From: Gabriel F. T. Gomes Date: Wed, 8 Aug 2018 20:26:22 +0000 (-0300) Subject: ldbl-opt: Add error and error_at_line (bug 23984) X-Git-Tag: glibc-2.30~308 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d11086a9391b6066458947b80c0d0059b6b461d8;p=thirdparty%2Fglibc.git ldbl-opt: Add error and error_at_line (bug 23984) 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. --- diff --git a/ChangeLog b/ChangeLog index 37183907e72..886af2b2adf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2019-03-01 Gabriel F. T. Gomes + + [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 [BZ #23984] diff --git a/include/bits/error-ldbl.h b/include/bits/error-ldbl.h new file mode 100644 index 00000000000..84b26468679 --- /dev/null +++ b/include/bits/error-ldbl.h @@ -0,0 +1 @@ +#include diff --git a/include/error.h b/include/error.h index 70f3192fa6b..9e96262fc5a 100644 --- a/include/error.h +++ b/include/error.h @@ -1 +1,15 @@ +#ifndef _ERROR_H #include + +#include + +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 diff --git a/misc/Makefile b/misc/Makefile index 6cb660bd3e2..032f28fc38e 100644 --- a/misc/Makefile +++ b/misc/Makefile @@ -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 index 00000000000..c3883da2992 --- /dev/null +++ b/misc/bits/error-ldbl.h @@ -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 + . */ + +#ifndef _ERROR_H +# error "Never include directly; use instead." +#endif + +__LDBL_REDIR_DECL (error) +__LDBL_REDIR_DECL (error_at_line) diff --git a/misc/error.h b/misc/error.h index 34d4a6d4c68..ba0c9293ed6 100644 --- a/misc/error.h +++ b/misc/error.h @@ -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 +#ifdef __LDBL_COMPAT +# 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 + compatibility functions. */ +# if defined __extern_always_inline && defined __va_arg_pack +# include +# endif #endif __END_DECLS diff --git a/sysdeps/ieee754/ldbl-opt/Versions b/sysdeps/ieee754/ldbl-opt/Versions index 5d6051a12d8..21a2db68885 100644 --- a/sysdeps/ieee754/ldbl-opt/Versions +++ b/sysdeps/ieee754/ldbl-opt/Versions @@ -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 { diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index 6883814d58c..86ac418007e 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -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); diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h index eeda11b4209..aed1cc1497e 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h @@ -28,6 +28,7 @@ #define __NO_LONG_DOUBLE_MATH 1 #include #include +#include #include #include #include @@ -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. */ diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 1b95af13bcd..fd81fc4ad0e 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 8973a44b56e..a701584422b 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index c89ca3efaa9..bbb647cd98a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 1b0f108c19f..bb23bf61a83 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index 02504aeb586..7921dda9794 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index c46f1119d46..2aed339af4e 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 47b0be5e504..e46feb56e5c 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -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 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index 854708e37c7..ebdbd2c5aee 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -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