about summary refs log tree commit diff
path: root/sysdeps/ieee754
diff options
context:
space:
mode:
authorGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-08-08 09:58:36 -0300
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2019-03-01 15:24:51 -0300
commit90188e7d1adc5d8743d7933c9ed1bf95f91dda62 (patch)
treeb95a92a1f310ed52f9340a905bf1da7835106a3d /sysdeps/ieee754
parentea2d89d01c2be3e87eced8bb51ce5dc66d09ac35 (diff)
downloadglibc-90188e7d1adc5d8743d7933c9ed1bf95f91dda62.tar.gz
glibc-90188e7d1adc5d8743d7933c9ed1bf95f91dda62.tar.xz
glibc-90188e7d1adc5d8743d7933c9ed1bf95f91dda62.zip
ldbl-opt: Add err, errx, verr, verrx, warn, warnx, vwarn, and vwarnx (bug 23984)
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 powerpc, powerpc64 and powerpc64le.
Diffstat (limited to 'sysdeps/ieee754')
-rw-r--r--sysdeps/ieee754/ldbl-opt/Versions2
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.c61
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.h9
3 files changed, 72 insertions, 0 deletions
diff --git a/sysdeps/ieee754/ldbl-opt/Versions b/sysdeps/ieee754/ldbl-opt/Versions
index 1842a1a3ef..5d6051a12d 100644
--- a/sysdeps/ieee754/ldbl-opt/Versions
+++ b/sysdeps/ieee754/ldbl-opt/Versions
@@ -80,6 +80,8 @@ libc {
   }
   GLIBC_2.30 {
     __nldbl_argp_error; __nldbl_argp_failure;
+    __nldbl_warn; __nldbl_vwarn; __nldbl_warnx; __nldbl_vwarnx;
+    __nldbl_err; __nldbl_verr; __nldbl_errx; __nldbl_verrx;
   }
 }
 libm {
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
index 4f70207f2d..6883814d58 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -23,6 +23,7 @@
 #define __GLIBC_USE_DEPRECATED_SCANF 1
 
 #include <argp.h>
+#include <err.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <libio/strfile.h>
@@ -1011,6 +1012,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);
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
index 9f5836586c..eeda11b420 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h
@@ -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.  */