[v1,3/7] ldbl-opt: Add arpg_error and argp_failure

Message ID 20181206180824.1761-4-gabriel@inconstante.eti.br
State Superseded
Delegated to: Joseph Myers
Headers

Commit Message

Gabriel F. T. Gomes Dec. 6, 2018, 6:08 p.m. UTC
  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 powerpc64 and powerpc64le.

	* argp/argp.h [defined __LDBL_COMPAT]: Include bits/argp-ldbl.h.
	* argp/bits/argp-ldbl.h: New file.
	* include/argp.h: Include stdarg.h.  Add prototypes for internal
	functions: __argp_error_internal and __argp_failure_internal.
	* sysdeps/ieee754/ldbl-opt/Versions (libc) Add
	__nldbl_argp_error and __nldbl_argp_failure.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Include argp.h.
	(__nldbl_argp_error, __nldbl_argp_failure): New functions.
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Include argp.h.
	Redirect argp_error and argp_failure calls.
	* 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.
---
 argp/argp.h                                        |  4 ++++
 argp/bits/argp-ldbl.h                              | 24 ++++++++++++++++++++++
 include/argp.h                                     | 11 ++++++++++
 sysdeps/ieee754/ldbl-opt/Versions                  |  3 +++
 sysdeps/ieee754/ldbl-opt/nldbl-compat.c            | 21 +++++++++++++++++++
 sysdeps/ieee754/ldbl-opt/nldbl-compat.h            |  3 +++
 sysdeps/unix/sysv/linux/alpha/libc.abilist         |  2 ++
 .../sysv/linux/powerpc/powerpc32/fpu/libc.abilist  |  2 ++
 .../linux/powerpc/powerpc32/nofpu/libc.abilist     |  2 ++
 .../sysv/linux/powerpc/powerpc64/libc-le.abilist   |  2 ++
 .../unix/sysv/linux/powerpc/powerpc64/libc.abilist |  2 ++
 sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist  |  2 ++
 sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist  |  2 ++
 sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist |  2 ++
 14 files changed, 82 insertions(+)
 create mode 100644 argp/bits/argp-ldbl.h
  

Patch

diff --git a/argp/argp.h b/argp/argp.h
index 0f2583340f..fd2b20d2a1 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -554,6 +554,10 @@  __NTH (__option_is_end (const struct argp_option *__opt))
 # endif
 #endif /* Use extern inlines.  */
 
+#ifdef __LDBL_COMPAT
+# include <bits/argp-ldbl.h>
+#endif
+
 __END_DECLS
 
 #endif /* argp.h */
diff --git a/argp/bits/argp-ldbl.h b/argp/bits/argp-ldbl.h
new file mode 100644
index 0000000000..e3a3ed97d2
--- /dev/null
+++ b/argp/bits/argp-ldbl.h
@@ -0,0 +1,24 @@ 
+/* Redirections for argp 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 _ARGP_H
+# error "Never include <bits/argp-ldbl.h> directly; use <argp.h> instead."
+#endif
+
+__LDBL_REDIR_DECL (argp_error)
+__LDBL_REDIR_DECL (argp_failure)
diff --git a/include/argp.h b/include/argp.h
index 6cf8782060..7077471d99 100644
--- a/include/argp.h
+++ b/include/argp.h
@@ -1,6 +1,17 @@ 
 #ifndef _ARGP_H
 #include <argp/argp.h>
 
+/* Prototypes for internal argp.h functions.  */
+#include <stdarg.h>
+void
+__argp_error_internal (const struct argp_state *state, const char *fmt,
+		       va_list ap, unsigned int mode_flags);
+
+void
+__argp_failure_internal (const struct argp_state *state, int status,
+			 int errnum, const char *fmt, va_list ap,
+			 unsigned int mode_flags);
+
 #ifndef _ISOMAC
 extern __typeof (__argp_error) __argp_error attribute_hidden;
 extern __typeof (__argp_failure) __argp_failure attribute_hidden;
diff --git a/sysdeps/ieee754/ldbl-opt/Versions b/sysdeps/ieee754/ldbl-opt/Versions
index af0c4a098c..855f541c48 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.29 {
+    __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 f6dd81759d..0cc9ab0f7a 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -17,6 +17,7 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
+#include <argp.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <libio/strfile.h>
@@ -985,6 +986,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 b7606c3c2d..d263b19c5b 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 <argp.h>
 #include <stdarg.h>
 #include <stdlib.h>
 #include <stdint.h>
@@ -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.  */
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 8df162fe99..3a7c918c93 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2033,6 +2033,8 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index e9ecbccb71..481b689b0e 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -1993,6 +1993,8 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index da83ea6028..35f413c0cc 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -1997,6 +1997,8 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
index 4535b40d15..8b011c93a0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
@@ -2228,4 +2228,6 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
index 65725de4f0..565f32e53a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
@@ -123,6 +123,8 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 _Exit F
 GLIBC_2.3 _IO_2_1_stderr_ D 0xe0
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index e85ac2a178..0233991ff0 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2002,6 +2002,8 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index d56931022c..a1ebf17ee0 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -1908,6 +1908,8 @@  GLIBC_2.28 thrd_equal F
 GLIBC_2.28 thrd_sleep F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index 64fa9e10a5..76c5b297c3 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -1996,6 +1996,8 @@  GLIBC_2.28 thrd_current F
 GLIBC_2.28 thrd_equal F
 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 posix_spawn_file_actions_addchdir_np F
 GLIBC_2.3 __ctype_b_loc F
 GLIBC_2.3 __ctype_tolower_loc F