Changes since v2:
- Added bits/err-ldbl.h to the list of installed headers.
Changes since v1:
- Added include/bits/err-ldbl.h
- Added mention to bugzilla fix.
-- 8< --
When support for long double format with 128-bits (-mlong-double-128)
was added for platforms where long double had the same format as double,
such as powerpc, compatibility versions for the functions listed in the
commit title were missed. Since the older format of long double can
still be used (with -mlong-double-64), using these functions with a
format string that requests the printing of long double variables will
produce wrong outputs.
This patch adds the missing compatibility functions and header magic to
redirect calls to them when -mlong-double-64 is in use.
Tested for powerpc64 and powerpc64le.
[BZ #23984]
* include/bits/err-ldbl.h: New file.
* include/err.h: Add prototypes for the internal functions:
__vwarnx_internal and __vwarn_internal.
* misc/Makefile (headers): Add bits/err-ldbl.h.
* misc/bits/err-ldbl.h: New file.
* misc/err.h: Include bits/err-ldbl.h when __LDBL_COMPAT is
defined, i.e.: when -mlong-double-64 is in use.
* sysdeps/ieee754/ldbl-opt/Versions (libc): Add __nldbl_warn,
__nldbl_vwarn, __nldbl_warnx, __nldbl_vwarnx, __nldbl_err,
__nldbl_verr, __nldbl_errx, and __nldbl_verrx.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Include err.h.
(VA_CALL): New macro.
(__nldbl_vwarn, __nldbl_vwarnx, __nldbl_warn, __nldbl_warnx)
(__nldbl_verr, __nldbl_verrx, __nldbl_err, __nldbl_errx): New
functions.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include err.h and
declare prototypes for the new functions.
* 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.
---
include/bits/err-ldbl.h | 1 +
include/err.h | 9 ++++
misc/Makefile | 3 +-
misc/bits/err-ldbl.h | 30 +++++++++++
misc/err.h | 4 ++
sysdeps/ieee754/ldbl-opt/Versions | 2 +
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 61 ++++++++++++++++++++++
sysdeps/ieee754/ldbl-opt/nldbl-compat.h | 9 ++++
sysdeps/unix/sysv/linux/alpha/libc.abilist | 8 +++
.../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 8 +++
.../linux/powerpc/powerpc32/nofpu/libc.abilist | 8 +++
.../sysv/linux/powerpc/powerpc64/be/libc.abilist | 8 +++
.../sysv/linux/powerpc/powerpc64/le/libc.abilist | 8 +++
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 8 +++
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 8 +++
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 8 +++
16 files changed, 182 insertions(+), 1 deletion(-)
create mode 100644 include/bits/err-ldbl.h
create mode 100644 misc/bits/err-ldbl.h
new file mode 100644
@@ -0,0 +1 @@
+#include <misc/bits/err-ldbl.h>
@@ -1,6 +1,15 @@
#ifndef _ERR_H
#include <misc/err.h>
+/* Prototypes for internal err.h functions. */
+void
+__vwarnx_internal (const char *format, __gnuc_va_list ap,
+ unsigned int mode_flags);
+
+void
+__vwarn_internal (const char *format, __gnuc_va_list ap,
+ unsigned int mode_flags);
+
# ifndef _ISOMAC
libc_hidden_proto (warn)
@@ -36,7 +36,8 @@ headers := sys/uio.h bits/uio-ext.h bits/uio_lim.h \
syslog.h sys/syslog.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
+ sys/sysmacros.h bits/sysmacros.h bits/types/struct_iovec.h \
+ bits/err-ldbl.h
routines := brk sbrk sstk ioctl \
readv writev preadv preadv64 pwritev pwritev64 \
new file mode 100644
@@ -0,0 +1,30 @@
+/* Redirections for err.h functions for -mlong-double-64.
+ Copyright (C) 2018 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 _ERR_H
+# error "Never include <bits/err-ldbl.h> directly; use <err.h> instead."
+#endif
+
+__LDBL_REDIR_DECL (warn)
+__LDBL_REDIR_DECL (vwarn)
+__LDBL_REDIR_DECL (warnx)
+__LDBL_REDIR_DECL (vwarnx)
+__LDBL_REDIR_DECL (err)
+__LDBL_REDIR_DECL (verr)
+__LDBL_REDIR_DECL (errx)
+__LDBL_REDIR_DECL (verrx)
@@ -52,6 +52,10 @@ 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 <bits/err-ldbl.h>
+#endif
+
__END_DECLS
#endif /* err.h */
@@ -80,6 +80,8 @@ libc {
}
GLIBC_2.29 {
__nldbl_argp_error; __nldbl_argp_failure;
+ __nldbl_warn; __nldbl_vwarn; __nldbl_warnx; __nldbl_vwarnx;
+ __nldbl_err; __nldbl_verr; __nldbl_errx; __nldbl_verrx;
}
}
libm {
@@ -18,6 +18,7 @@
<http://www.gnu.org/licenses/>. */
#include <argp.h>
+#include <err.h>
#include <stdarg.h>
#include <stdio.h>
#include <libio/strfile.h>
@@ -1006,6 +1007,66 @@ __nldbl_argp_failure (const struct argp_state *state, int status,
va_end (ap);
}
+#define VA_CALL(call) \
+{ \
+ va_list ap; \
+ va_start (ap, format); \
+ call (format, ap, PRINTF_LDBL_IS_DBL); \
+ va_end (ap); \
+}
+
+void
+__nldbl_err (int status, const char *format, ...)
+{
+ VA_CALL (__vwarn_internal)
+ exit (status);
+}
+
+void
+__nldbl_errx (int status, const char *format, ...)
+{
+ VA_CALL (__vwarnx_internal)
+ exit (status);
+}
+
+void
+__nldbl_verr (int status, const char *format, __gnuc_va_list ap)
+{
+ __vwarn_internal (format, ap, PRINTF_LDBL_IS_DBL);
+ exit (status);
+}
+
+void
+__nldbl_verrx (int status, const char *format, __gnuc_va_list ap)
+{
+ __vwarnx_internal (format, ap, PRINTF_LDBL_IS_DBL);
+ exit (status);
+}
+
+void
+__nldbl_warn (const char *format, ...)
+{
+ VA_CALL (__vwarn_internal)
+}
+
+void
+__nldbl_warnx (const char *format, ...)
+{
+ VA_CALL (__vwarnx_internal)
+}
+
+void
+__nldbl_vwarn (const char *format, __gnuc_va_list ap)
+{
+ __vwarn_internal (format, ap, PRINTF_LDBL_IS_DBL);
+}
+
+void
+__nldbl_vwarnx (const char *format, __gnuc_va_list ap)
+{
+ __vwarnx_internal (format, ap, PRINTF_LDBL_IS_DBL);
+}
+
#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);
@@ -27,6 +27,7 @@
/* Avoid long double prototypes. */
#define __NO_LONG_DOUBLE_MATH 1
#include <argp.h>
+#include <err.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
@@ -79,6 +80,14 @@ NLDBL_DECL (__isoc99_vfwscanf);
NLDBL_DECL (__isoc99_vswscanf);
NLDBL_DECL (argp_error);
NLDBL_DECL (argp_failure);
+NLDBL_DECL (warn);
+NLDBL_DECL (vwarn);
+NLDBL_DECL (warnx);
+NLDBL_DECL (vwarnx);
+NLDBL_DECL (err);
+NLDBL_DECL (verr);
+NLDBL_DECL (errx);
+NLDBL_DECL (verrx);
/* These do not exist in the normal interface, but must exist in the
__nldbl interface so that they can be called from libnldbl. */
@@ -2035,6 +2035,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -1995,6 +1995,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -1999,6 +1999,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -125,6 +125,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -2230,6 +2230,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -2004,6 +2004,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -1910,6 +1910,14 @@ GLIBC_2.28 thrd_yield F
GLIBC_2.29 __fentry__ F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F
@@ -1998,6 +1998,14 @@ GLIBC_2.28 thrd_sleep F
GLIBC_2.28 thrd_yield F
GLIBC_2.29 __nldbl_argp_error F
GLIBC_2.29 __nldbl_argp_failure F
+GLIBC_2.29 __nldbl_err F
+GLIBC_2.29 __nldbl_errx F
+GLIBC_2.29 __nldbl_verr F
+GLIBC_2.29 __nldbl_verrx F
+GLIBC_2.29 __nldbl_vwarn F
+GLIBC_2.29 __nldbl_vwarnx F
+GLIBC_2.29 __nldbl_warn F
+GLIBC_2.29 __nldbl_warnx F
GLIBC_2.29 getcpu F
GLIBC_2.29 posix_spawn_file_actions_addchdir_np F
GLIBC_2.29 posix_spawn_file_actions_addfchdir_np F