From 6e1f6440b99d74db314a9f1a1b27c050ef62a45c Mon Sep 17 00:00:00 2001 From: "Gabriel F. T. Gomes" Date: Wed, 4 Jul 2018 11:54:11 -0300 Subject: ldbl-opt: Add argp_error and argp_failure (bug 23983) The functions argp_error and argp_failure are missing support for printing long double values when long double has the same format as double. This patch adds the new functions __nldbl_argp_error and __nldbl_argp_failure, as well as header magic to redirect calls to them when -mlong-double-64 is in use. Tested for powerpc, powerpc64 and powerpc64le. --- sysdeps/ieee754/ldbl-opt/Versions | 3 +++ sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 21 +++++++++++++++++++++ sysdeps/ieee754/ldbl-opt/nldbl-compat.h | 3 +++ 3 files changed, 27 insertions(+) (limited to 'sysdeps/ieee754/ldbl-opt') diff --git a/sysdeps/ieee754/ldbl-opt/Versions b/sysdeps/ieee754/ldbl-opt/Versions index af0c4a098c..1842a1a3ef 100644 --- a/sysdeps/ieee754/ldbl-opt/Versions +++ b/sysdeps/ieee754/ldbl-opt/Versions @@ -78,6 +78,9 @@ libc { __nldbl___dprintf_chk; __nldbl___vdprintf_chk; __nldbl___obstack_printf_chk; __nldbl___obstack_vprintf_chk; } + GLIBC_2.30 { + __nldbl_argp_error; __nldbl_argp_failure; + } } libm { NLDBL_VERSION { diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index 76ef8a8f74..4f70207f2d 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -22,6 +22,7 @@ #undef __GLIBC_USE_DEPRECATED_SCANF #define __GLIBC_USE_DEPRECATED_SCANF 1 +#include #include #include #include @@ -990,6 +991,26 @@ __nldbl___isoc99_wscanf (const wchar_t *fmt, ...) return ret; } +void +__nldbl_argp_error (const struct argp_state *state, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + __argp_error_internal (state, fmt, ap, PRINTF_LDBL_IS_DBL); + va_end (ap); +} + +void +__nldbl_argp_failure (const struct argp_state *state, int status, + int errnum, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + __argp_failure_internal (state, status, errnum, fmt, 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 f2079066cf..9f5836586c 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.h +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.h @@ -26,6 +26,7 @@ /* Avoid long double prototypes. */ #define __NO_LONG_DOUBLE_MATH 1 +#include #include #include #include @@ -76,6 +77,8 @@ NLDBL_DECL (__isoc99_swscanf); NLDBL_DECL (__isoc99_vwscanf); NLDBL_DECL (__isoc99_vfwscanf); NLDBL_DECL (__isoc99_vswscanf); +NLDBL_DECL (argp_error); +NLDBL_DECL (argp_failure); /* These do not exist in the normal interface, but must exist in the __nldbl interface so that they can be called from libnldbl. */ -- cgit 1.4.1