unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] IEEE long double printf and friends for powerpc64le
@ 2019-08-09 18:31 Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

A long time ago [1], I sent a patch set with the initial implementations
of many string to/from IEEE long double conversion routines for
powerpc64le.  The patch set depended on other, at the time unapplied,
patch sets [2,3], which are now all integrated into master.  Even though
this dependency existed, I got a lot of feedback (thanks, btw), which I
tried to address for this new round.

In this thread, I only included printf and friends functions, which
helps reduce the size of the patch set and maybe ease review. :)

As with previous submissions, these changes can only be tested once all
other functions have actually been integrated (because the function
redirections in our installed headers are macroized and work for all
long double routines).  So, in order to test it, I use a more complete
branch, which I made available at:
https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/gabriel/powerpc-ieee128-printscan

[1] https://sourceware.org/ml/libc-alpha/2018-06/msg00652.html
[2] https://sourceware.org/ml/libc-alpha/2018-10/msg00612.html
[3] https://sourceware.org/ml/libc-alpha/2019-02/msg00582.html

Gabriel F. T. Gomes (6):
  ldbl-128ibm-compat: Add regular character printing functions
  ldbl-128ibm-compat: Add wide character printing functions
  ldbl-128ibm-compat: Add regular character, fortified printing
    functions
  ldbl-128ibm-compat: Add wide character, fortified printing functions
  ldbl-128ibm-compat: Test double values
  ldbl-128ibm-compat: Test positional arguments

 elf/tst-addr1.c                               |   7 +-
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 104 +++++++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  45 +++++
 .../ldbl-128ibm-compat/ieee128-asprintf.c     |  35 ++++
 .../ldbl-128ibm-compat/ieee128-asprintf_chk.c |  38 ++++
 .../ldbl-128ibm-compat/ieee128-dprintf.c      |  34 ++++
 .../ldbl-128ibm-compat/ieee128-dprintf_chk.c  |  38 ++++
 .../ldbl-128ibm-compat/ieee128-fprintf.c      |  34 ++++
 .../ldbl-128ibm-compat/ieee128-fprintf_chk.c  |  38 ++++
 .../ldbl-128ibm-compat/ieee128-fwprintf.c     |  35 ++++
 .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |  38 ++++
 .../ldbl-128ibm-compat/ieee128-printf.c       |  35 ++++
 .../ldbl-128ibm-compat/ieee128-printf_chk.c   |  38 ++++
 .../ldbl-128ibm-compat/ieee128-snprintf.c     |  35 ++++
 .../ldbl-128ibm-compat/ieee128-snprintf_chk.c |  42 ++++
 .../ldbl-128ibm-compat/ieee128-sprintf.c      |  35 ++++
 .../ldbl-128ibm-compat/ieee128-sprintf_chk.c  |  42 ++++
 .../ldbl-128ibm-compat/ieee128-swprintf.c     |  36 ++++
 .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |  42 ++++
 .../ldbl-128ibm-compat/ieee128-vasprintf.c    |  27 +++
 .../ieee128-vasprintf_chk.c                   |  31 +++
 .../ldbl-128ibm-compat/ieee128-vdprintf.c     |  26 +++
 .../ldbl-128ibm-compat/ieee128-vdprintf_chk.c |  30 +++
 .../ldbl-128ibm-compat/ieee128-vfprintf.c     |  26 +++
 .../ldbl-128ibm-compat/ieee128-vfprintf_chk.c |  30 +++
 .../ldbl-128ibm-compat/ieee128-vfwprintf.c    |  27 +++
 .../ieee128-vfwprintf_chk.c                   |  31 +++
 .../ldbl-128ibm-compat/ieee128-vprintf.c      |  27 +++
 .../ldbl-128ibm-compat/ieee128-vprintf_chk.c  |  30 +++
 .../ldbl-128ibm-compat/ieee128-vsnprintf.c    |  28 +++
 .../ieee128-vsnprintf_chk.c                   |  34 ++++
 .../ldbl-128ibm-compat/ieee128-vsprintf.c     |  27 +++
 .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c |  34 ++++
 .../ldbl-128ibm-compat/ieee128-vswprintf.c    |  28 +++
 .../ieee128-vswprintf_chk.c                   |  34 ++++
 .../ldbl-128ibm-compat/ieee128-vwprintf.c     |  27 +++
 .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |  30 +++
 .../ldbl-128ibm-compat/ieee128-wprintf.c      |  35 ++++
 .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |  38 ++++
 .../test-printf-chk-ibm128.c                  |   1 +
 .../test-printf-chk-ieee128.c                 |   1 +
 .../test-printf-chk-ldbl-compat.c             | 191 ++++++++++++++++++
 .../test-printf-chk-redir-ibm128.c            |   2 +
 .../test-printf-chk-redir-ieee128.c           |   2 +
 .../ldbl-128ibm-compat/test-printf-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-printf-ieee128.c  |   1 +
 .../test-printf-ldbl-compat.c                 | 182 +++++++++++++++++
 .../test-wprintf-chk-ibm128.c                 |   1 +
 .../test-wprintf-chk-ieee128.c                |   1 +
 .../test-wprintf-chk-ldbl-compat.c            | 122 +++++++++++
 .../test-wprintf-chk-redir-ibm128.c           |   2 +
 .../test-wprintf-chk-redir-ieee128.c          |   2 +
 .../ldbl-128ibm-compat/test-wprintf-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-wprintf-ieee128.c |   1 +
 .../test-wprintf-ldbl-compat.c                | 120 +++++++++++
 .../powerpc64/le/ldbl-128ibm-compat-abi.h     |   8 +
 56 files changed, 1988 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h

-- 
2.21.0


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
@ 2019-08-09 18:31 ` Gabriel F. T. Gomes
  2019-08-14 11:46   ` Florian Weimer
  2019-08-09 18:31 ` [PATCH 2/6] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

The 'mode' argument to __vfprintf_internal allows the selection of the
long double format for all long double arguments requested by the format
string.  Currently, there are two possibilities: long double with the
same format as double or long double as something else.  The 'something
else' format varies between architectures, and on powerpc64le, it means
IBM Extended Precision format.

In preparation for the third option of long double format on
powerpc64le, this patch uses the new mode mask,
PRINTF_LDBL_USES_FLOAT128, which tells __vfprintf_internal to save the
floating-point values into variables of type __float128 and adjusts the
parameters to __printf_fp and __printf_fphex as if it was a call from
strfromf128.

Many files from the stdio-common, wcsmbs, argp, misc, and libio
directories will have IEEE binary128 counterparts.  Setting the correct
compiler options to these files (original and counterparts) would
produce a large amount of repetitive Makefile rules.  To avoid this
repetition, this patch adds a Makefile routine that iterates over the
files adding or removing the appropriate flags.

Tested for powerpc64le.

	* elf/tst-addr1.c (do_test): Accept redirections of printf to
	__printfieee128.

	* sysdeps/ieee754/ldbl-128ibm-compat/Makefile
	[subdir == stdio-common] (routines): Move the addition of
	printf_size to ldbl-extra-routines.
	[subdir == stdio-common] (ldbl-extra-routines): New variable.
	[subdir == stdio-common] (ldbl-ibm128-files): New variable.
	[subdir == stdio-common] (obj-suf-foreach): New routine.
	[subdir == stdio-common] (CFLAGS-vfprintf-internal.c): New
	variable.  Add -mfloat128 to the compilation of
	vfprintf-internal.c, so that it gets support for the use of
	__printf_fp and __printf_fphex with __float128 parameter.
	[subdir == stdio-common] (tests-internal): Add
	test-printf-ieee128 and test-printf-ibm128.
	[subdir == stdio-common] (CFLAGS-test-printf-ieee128.c): New
	variable to add the relevant -mabi flags to the compilation.
	[subdir == stdio-common] (CFLAGS-test-printf-ibm128.c): Likewise.

	* sysdeps/ieee754/ldbl-128ibm-compat/Versions: (libc): Add
	__asprintfieee128, __dprintfieee128, __fprintfieee128,
	__printfieee128, __snprintfieee128, __sprintfieee128,
	__vasprintfieee128, __vdprintfieee128, __vfprintfieee128,
	__vprintfieee128, __vsnprintfieee128, and __vsprintfieee128.

	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h:
	Likewise.
---
 elf/tst-addr1.c                               |   7 +-
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  45 ++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  15 ++
 .../ldbl-128ibm-compat/ieee128-asprintf.c     |  35 ++++
 .../ldbl-128ibm-compat/ieee128-dprintf.c      |  34 ++++
 .../ldbl-128ibm-compat/ieee128-fprintf.c      |  34 ++++
 .../ldbl-128ibm-compat/ieee128-printf.c       |  35 ++++
 .../ldbl-128ibm-compat/ieee128-snprintf.c     |  35 ++++
 .../ldbl-128ibm-compat/ieee128-sprintf.c      |  35 ++++
 .../ldbl-128ibm-compat/ieee128-vasprintf.c    |  27 +++
 .../ldbl-128ibm-compat/ieee128-vdprintf.c     |  26 +++
 .../ldbl-128ibm-compat/ieee128-vfprintf.c     |  26 +++
 .../ldbl-128ibm-compat/ieee128-vprintf.c      |  27 +++
 .../ldbl-128ibm-compat/ieee128-vsnprintf.c    |  28 +++
 .../ldbl-128ibm-compat/ieee128-vsprintf.c     |  27 +++
 .../ldbl-128ibm-compat/test-printf-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-printf-ieee128.c  |   1 +
 .../test-printf-ldbl-compat.c                 | 171 ++++++++++++++++++
 .../powerpc64/le/ldbl-128ibm-compat-abi.h     |   8 +
 19 files changed, 615 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h

diff --git a/elf/tst-addr1.c b/elf/tst-addr1.c
index 68ff74aabd..ee81acda5b 100644
--- a/elf/tst-addr1.c
+++ b/elf/tst-addr1.c
@@ -19,7 +19,12 @@ do_test (void)
 		rather than in the binary.  printf and _IO_printf
 		are aliased and which one comes first in the
 		hash table is up to the linker.  */
-	     && strcmp (i.dli_sname, "_IO_printf") != 0);
+	     && strcmp (i.dli_sname, "_IO_printf") != 0
+	     /* On architectures where long double with IEEE binary128
+		format is available as a third option (initially, true
+		for powerpc64le), printf may be redirected to
+		__printfieee128.  */
+	     && strcmp (i.dli_sname, "__printfieee128") != 0);
 }
 
 #include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 412beb5b5c..102973add9 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -1,5 +1,30 @@
 ifeq ($(subdir),stdio-common)
-routines += ieee128-printf_size
+ldbl-extra-routines += printf_size \
+		       asprintf \
+		       dprintf \
+		       fprintf \
+		       printf \
+		       snprintf \
+		       sprintf \
+		       vasprintf \
+		       vdprintf \
+		       vfprintf \
+		       vprintf \
+		       vsnprintf \
+		       vsprintf
+
+# Printing long double values with IEEE binary128 format reuses part
+# of the internal float128 implementation (__printf_fp, __printf_fphex,
+# and __float128 variables and union members).  Thus, the compilation of
+# the following functions, must have -mfloat128 and -mabi=ibmlongdouble
+# passed to the compiler.
+CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
+
+# Basic tests for the implementation of long double with IEEE binary128
+# format and for the related redirections in installed headers.
+tests-internal += test-printf-ieee128 test-printf-ibm128
+CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
 tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
@@ -20,3 +45,21 @@ $(objpfx)test-printf-size-ibm128.out: \
 	$(SHELL) $^ '$(test-program-prefix)' $@; \
 	$(evaluate-test)
 endif
+
+# Add IEEE binary128 files as make targets.
+routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
+
+# On powerpc64le, the routines responsible for converting between long
+# double and string (e.g.: printf, scanf, strtold, strfroml) default to
+# IBM long double mode.  When support for TS 18661-3 was added, several
+# internal functions were modified so that they could also handle
+# floating-point variables with IEEE binary128 format, but as an
+# additional type, _Float128.
+#
+# The following rule ensures that the string conversion routines will
+# always be built in IBM long double mode, with additional support for
+# IEEE binary128, through the use of -mabi=ibmlongdouble and -mfloat128.
+ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \
+		     $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \
+		     $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^)
+obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1)))
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 4aa34dbe59..6a27befed2 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -120,4 +120,19 @@ libc {
     __wcstoieee128_l;
 
     __printf_sizeieee128;
+
+    __asprintfieee128;
+    __dprintfieee128;
+    __fprintfieee128;
+    __printfieee128;
+    __snprintfieee128;
+    __sprintfieee128;
+
+    __vasprintfieee128;
+    __vdprintfieee128;
+    __vfprintfieee128;
+    __vprintfieee128;
+    __vsnprintfieee128;
+    __vsprintfieee128;
   }
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
new file mode 100644
index 0000000000..35c909b124
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for asprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_asprintf (char **string_ptr, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vasprintf_internal (string_ptr, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_asprintf, __asprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
new file mode 100644
index 0000000000..0c66c9758b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
@@ -0,0 +1,34 @@
+/* Wrapper for dprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_dprintf (int d, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vdprintf_internal (d, format, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_dprintf, __dprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
new file mode 100644
index 0000000000..b4b945092a
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
@@ -0,0 +1,34 @@
+/* Wrapper for fprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fprintf (FILE *fp, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fprintf, __fprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
new file mode 100644
index 0000000000..a1c6d7e0cf
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
@@ -0,0 +1,35 @@
+/* Wrapper for printf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_printf (const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfprintf_internal (stdout, format, ap,
+			      PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_printf, __printfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
new file mode 100644
index 0000000000..2c09a75d59
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for snprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_snprintf (char *s, size_t maxlen, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vsnprintf_internal (s, maxlen, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_snprintf, __snprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
new file mode 100644
index 0000000000..727a403634
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for sprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_sprintf (char *s, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vsprintf_internal (s, -1, format, ap,
+			      PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_sprintf, __sprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
new file mode 100644
index 0000000000..650e40affb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vasprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vasprintf (char **result_ptr, const char *format, va_list ap)
+{
+  return __vasprintf_internal (result_ptr, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vasprintf, __vasprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
new file mode 100644
index 0000000000..88fbb3743d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vdprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vdprintf (int d, const char *format, va_list ap)
+{
+  return __vdprintf_internal (d, format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vdprintf, __vdprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
new file mode 100644
index 0000000000..ecc2fd36da
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vfprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfprintf (FILE *fp, const char *format, va_list ap)
+{
+  return __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfprintf, __vfprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
new file mode 100644
index 0000000000..35347c60be
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vprintf (const char *format, va_list ap)
+{
+  return __vfprintf_internal (stdout, format, ap,
+			      PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vprintf, __vprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
new file mode 100644
index 0000000000..963b0cb228
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
@@ -0,0 +1,28 @@
+/* Wrapper for vsnprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsnprintf (char *string, size_t maxlen, const char *format,
+		      va_list ap)
+{
+  return __vsnprintf_internal (string, maxlen, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsnprintf, __vsnprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
new file mode 100644
index 0000000000..822cc31c16
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vsprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsprintf (char *string, const char *format, va_list ap)
+{
+  return __vsprintf_internal (string, -1, format, ap,
+			      PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsprintf, __vsprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
new file mode 100644
index 0000000000..5de4ea3e7f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
@@ -0,0 +1 @@
+#include <test-printf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
new file mode 100644
index 0000000000..5de4ea3e7f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
@@ -0,0 +1 @@
+#include <test-printf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
new file mode 100644
index 0000000000..939a6aad9c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -0,0 +1,171 @@
+/* Test for the long double variants of *printf functions.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const char *format, ...)
+{
+  char *buffer = NULL;
+  char string[128];
+  va_list args;
+
+  printf ("%15s", "vasprintf: ");
+  va_start (args, format);
+  vasprintf (&buffer, format, args);
+  va_end (args);
+  if (buffer == NULL)
+    printf ("Error using vasprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%15s", "vdprintf: ");
+  va_start (args, format);
+  vdprintf (fileno (stream), format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%15s", "vfprintf: ");
+  va_start (args, format);
+  vfprintf (stream, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%15s", "vprintf: ");
+  va_start (args, format);
+  vprintf (format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%15s", "vsnprintf: ");
+  va_start (args, format);
+  vsnprintf (string, 127, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%15s", "vsprintf: ");
+  va_start (args, format);
+  vsprintf (string, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const char *format, long double ld)
+{
+  char *buffer = NULL;
+  char string[128];
+
+  printf ("%15s", "asprintf: ");
+  asprintf (&buffer, format, ld);
+  if (buffer == NULL)
+    printf ("Error using asprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%15s", "dprintf: ");
+  dprintf (fileno (stream), format, ld);
+  printf ("\n");
+
+  printf ("%15s", "fprintf: ");
+  fprintf (stream, format, ld);
+  printf ("\n");
+
+  printf ("%15s", "printf: ");
+  printf (format, ld);
+  printf ("\n");
+
+  printf ("%15s", "snprintf: ");
+  snprintf (string, 127, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%15s", "sprintf: ");
+  sprintf (string, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, "%.10Lf", ld);
+  do_test_call_varg (stdout, "%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, "%.10La", ld);
+  do_test_call_varg (stdout, "%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "     asprintf: -1.0000000000\n"
+    "      dprintf: -1.0000000000\n"
+    "      fprintf: -1.0000000000\n"
+    "       printf: -1.0000000000\n"
+    "     snprintf: -1.0000000000\n"
+    "      sprintf: -1.0000000000\n"
+    "    vasprintf: -1.0000000000\n"
+    "     vdprintf: -1.0000000000\n"
+    "     vfprintf: -1.0000000000\n"
+    "      vprintf: -1.0000000000\n"
+    "    vsnprintf: -1.0000000000\n"
+    "     vsprintf: -1.0000000000\n"
+    "     asprintf: -0x1.0000000000p+0\n"
+    "      dprintf: -0x1.0000000000p+0\n"
+    "      fprintf: -0x1.0000000000p+0\n"
+    "       printf: -0x1.0000000000p+0\n"
+    "     snprintf: -0x1.0000000000p+0\n"
+    "      sprintf: -0x1.0000000000p+0\n"
+    "    vasprintf: -0x1.0000000000p+0\n"
+    "     vdprintf: -0x1.0000000000p+0\n"
+    "     vfprintf: -0x1.0000000000p+0\n"
+    "      vprintf: -0x1.0000000000p+0\n"
+    "    vsnprintf: -0x1.0000000000p+0\n"
+    "     vsprintf: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
new file mode 100644
index 0000000000..285216b231
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
@@ -0,0 +1,8 @@
+/* ABI version for long double switch to IEEE 128-bit floating point..
+   This is used by the Versions and math_ldbl_opt.h files in
+   sysdeps/ieee754/ldbl-128ibm-compat/.  It gives the ABI version where
+   long double == ibm128 was replaced with long double == _Float128
+   for libm *l functions and libc functions using long double.  */
+
+#define LDBL_IBM128_VERSION		GLIBC_2.31
+#define LDBL_IBM128_COMPAT_VERSION	GLIBC_2_31
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 2/6] ldbl-128ibm-compat: Add wide character printing functions
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
@ 2019-08-09 18:31 ` Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 3/6] ldbl-128ibm-compat: Add regular character, fortified " Gabriel F. T. Gomes
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

Similarly to what was done for regular character printing functions,
this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, in the
'mode' argument of the wide characters printing function,
__vfwprintf_internal (which is also extended to support printing
floating-point values with IEEE binary128, by saving floating-point
values into variables of type __float128 and adjusting the parameters to
__printf_fp and __printf_fphex as if it was a call from a wide-character
version of strfromf128 (even though such version does not exist)).

Tested for powerpc64le.

	* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
	[subdir == stdio-common] (ldbl-extra-routines): Add fwprintf,
	swprintf, wprintf, vfwprintf, vswprintf, and vwprintf.
	[subdir == stdio-common] (CFLAGS-vfwprintf-internal.c): New
	variable.  Add -mfloat128 to the compilation of
	vfprintf-internal.c, so that it gets support for the use of
	__printf_fp and __printf_fphex with __float128 parameter.
	[subdir == stdio-common] (tests-internal): Add
	test-wprintf-ieee128 and test-wprintf-ibm128.
	[subdir == stdio-common] (CFLAGS-test-wprintf-ieee128.c): New
	variable to add the relevant -mabi flags to the compilation.
	[subdir == stdio-common] (CFLAGS-test-wprintf-ibm128.c): Likewise.

	* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
	__fwprintfieee128, __swprintfieee128, __wprintfieee128,
	__vfwprintfieee128, __vswprintfieee128, and __vwprintfieee128.

	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c:
	Likewise.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  13 +-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |   8 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf.c     |  35 ++++++
 .../ldbl-128ibm-compat/ieee128-swprintf.c     |  36 ++++++
 .../ldbl-128ibm-compat/ieee128-vfwprintf.c    |  27 +++++
 .../ldbl-128ibm-compat/ieee128-vswprintf.c    |  28 +++++
 .../ldbl-128ibm-compat/ieee128-vwprintf.c     |  27 +++++
 .../ldbl-128ibm-compat/ieee128-wprintf.c      |  35 ++++++
 .../ldbl-128ibm-compat/test-wprintf-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-wprintf-ieee128.c |   1 +
 .../test-wprintf-ldbl-compat.c                | 111 ++++++++++++++++++
 11 files changed, 321 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 102973add9..0b6948e5af 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -11,7 +11,13 @@ ldbl-extra-routines += printf_size \
 		       vfprintf \
 		       vprintf \
 		       vsnprintf \
-		       vsprintf
+		       vsprintf \
+		       fwprintf \
+		       swprintf \
+		       wprintf \
+		       vfwprintf \
+		       vswprintf \
+		       vwprintf
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -19,6 +25,7 @@ ldbl-extra-routines += printf_size \
 # the following functions, must have -mfloat128 and -mabi=ibmlongdouble
 # passed to the compiler.
 CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 
 # Basic tests for the implementation of long double with IEEE binary128
 # format and for the related redirections in installed headers.
@@ -26,6 +33,10 @@ tests-internal += test-printf-ieee128 test-printf-ibm128
 CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
+tests-internal += test-wprintf-ieee128 test-wprintf-ibm128
+CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
 tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 6a27befed2..0485a2b5d4 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -134,5 +134,13 @@ libc {
     __vprintfieee128;
     __vsnprintfieee128;
     __vsprintfieee128;
+
+    __fwprintfieee128;
+    __swprintfieee128;
+    __wprintfieee128;
+
+    __vfwprintfieee128;
+    __vswprintfieee128;
+    __vwprintfieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
new file mode 100644
index 0000000000..4b350a6e0b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for fwprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fwprintf (FILE *fp, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (fp, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fwprintf, __fwprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
new file mode 100644
index 0000000000..4fb40e3c42
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
@@ -0,0 +1,36 @@
+/* Wrapper for swprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_swprintf (wchar_t *string, size_t maxlen,
+		    const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vswprintf_internal (string, maxlen, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_swprintf, __swprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
new file mode 100644
index 0000000000..757f4b31a8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vfwprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfwprintf (FILE *fp, const wchar_t *format, va_list ap)
+{
+  return __vfwprintf_internal (fp, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfwprintf, __vfwprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
new file mode 100644
index 0000000000..9bb36cfae9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
@@ -0,0 +1,28 @@
+/* Wrapper for vswprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vswprintf (wchar_t *string, size_t maxlen,
+		     const wchar_t *format, va_list ap)
+{
+  return __vswprintf_internal (string, maxlen, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vswprintf, __vswprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
new file mode 100644
index 0000000000..44ec37e24f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vwprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vwprintf (const wchar_t *format, va_list ap)
+{
+  return __vfwprintf_internal (stdout, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vwprintf, __vwprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
new file mode 100644
index 0000000000..c949f328c2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for wprintf.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_wprintf (const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (stdout, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_wprintf, __wprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
new file mode 100644
index 0000000000..9e230cd6f8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
@@ -0,0 +1 @@
+#include <test-wprintf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
new file mode 100644
index 0000000000..9e230cd6f8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
@@ -0,0 +1 @@
+#include <test-wprintf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
new file mode 100644
index 0000000000..71edfec235
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -0,0 +1,111 @@
+/* Test for the long double variants of *w*printf functions.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const wchar_t *format, ...)
+{
+  wchar_t string[128];
+  va_list args;
+
+  wprintf (L"%15Ls", L"vfwprintf: ");
+  va_start (args, format);
+  vfwprintf (stream, format, args);
+  va_end (args);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"vswprintf: ");
+  va_start (args, format);
+  vswprintf (string, 127, format, args);
+  va_end (args);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"vwprintf: ");
+  va_start (args, format);
+  vwprintf (format, args);
+  va_end (args);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+{
+  wchar_t string[128];
+
+  wprintf (L"%15Ls", L"fwprintf: ");
+  fwprintf (stream, format, ld);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"swprintf: ");
+  swprintf (string, 127, format, ld);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"wprintf: ");
+  wprintf (format, ld);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, L"%.10Lf", ld);
+  do_test_call_varg (stdout, L"%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, L"%.10La", ld);
+  do_test_call_varg (stdout, L"%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "     fwprintf: -1.0000000000\n"
+    "     swprintf: -1.0000000000\n"
+    "      wprintf: -1.0000000000\n"
+    "    vfwprintf: -1.0000000000\n"
+    "    vswprintf: -1.0000000000\n"
+    "     vwprintf: -1.0000000000\n"
+    "     fwprintf: -0x1.0000000000p+0\n"
+    "     swprintf: -0x1.0000000000p+0\n"
+    "      wprintf: -0x1.0000000000p+0\n"
+    "    vfwprintf: -0x1.0000000000p+0\n"
+    "    vswprintf: -0x1.0000000000p+0\n"
+    "     vwprintf: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 3/6] ldbl-128ibm-compat: Add regular character, fortified printing functions
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 2/6] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-08-09 18:31 ` Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 4/6] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

Since the introduction of internal functions with explicit flags for the
printf family of functions, the 'mode' parameter can be used to select
which format long double parameters have (with the mode flags:
PRINTF_LDBL_IS_DBL and PRINTF_LDBL_USES_FLOAT128), as well as to select
whether to check for overflows (mode flag: PRINTF_FORTIFY).

This patch combines PRINTF_LDBL_USES_FLOAT128 and PRINTF_FORTIFY to
provide the IEEE binary128 version of printf-like function for platforms
where long double can take this format, in addition to the double format
and to some non-ieee format (currently, this means powerpc64le).

There are two flavors of test cases provided with this patch: one that
explicitly calls the fortified functions, for instance __asprintf_chk,
and another that reuses the non-fortified test, but defining
_FORTIFY_SOURCE as 2.  The first guarantees that the implementations are
actually being tested (in bits/stdio2.h, vprintf gets redirected to
__vfprintf_chk, which would leave __vprintf_chk untested), whereas the
second guarantees that the redirections calls the correct function in
the IBM and IEEE long double cases.

Tested for powerpc64le.

	* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
	[subdir == debug] (ldbl-extra-routines): Add
	asprintf_chk, dprintf_chk, fprintf_chk, printf_chk,
	snprintf_chk, sprintf_chk, vasprintf_chk, vdprintf_chk,
	vfprintf_chk, vprintf_chk, vsnprintf_chk, and vsprintf_chk.
	[subdir == debug] (tests-internal): Add
	test-printf-chk-ieee128, test-printf-chk-ibm128,
	test-printf-chk-redir-ieee128, and test-printf-chk-redir-ibm128.
	[subdir == debug] (CFLAGS-test-printf-chk-ieee128.c): New
	variable to add the relevant -mabi flags to the compilation.
	[subdir == debug] (CFLAGS-test-printf-chk-ibm128.c): Likewise.
	[subdir == debug] (CFLAGS-test-printf-chk-redir-ieee128.c):
	Likewise.
	[subdir == debug] (CFLAGS-test-printf-chk-redir-ibm128.c):
	Likewise.

	* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
	__asprintf_chkieee128, __dprintf_chkieee128, __fprintf_chkieee128,
	__printf_chkieee128, __snprintf_chkieee128, __sprintf_chkieee128,
	__vasprintf_chkieee128, __vdprintf_chkieee128, __vfprintf_chkieee128,
	__vprintf_chkieee128, __vsnprintf_chkieee128, __vsprintf_chkieee128.

	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c: New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c:
	Likewise.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  25 +++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  14 ++
 .../ldbl-128ibm-compat/ieee128-asprintf_chk.c |  38 ++++
 .../ldbl-128ibm-compat/ieee128-dprintf_chk.c  |  38 ++++
 .../ldbl-128ibm-compat/ieee128-fprintf_chk.c  |  38 ++++
 .../ldbl-128ibm-compat/ieee128-printf_chk.c   |  38 ++++
 .../ldbl-128ibm-compat/ieee128-snprintf_chk.c |  42 ++++
 .../ldbl-128ibm-compat/ieee128-sprintf_chk.c  |  42 ++++
 .../ieee128-vasprintf_chk.c                   |  31 +++
 .../ldbl-128ibm-compat/ieee128-vdprintf_chk.c |  30 +++
 .../ldbl-128ibm-compat/ieee128-vfprintf_chk.c |  30 +++
 .../ldbl-128ibm-compat/ieee128-vprintf_chk.c  |  30 +++
 .../ieee128-vsnprintf_chk.c                   |  34 ++++
 .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c |  34 ++++
 .../test-printf-chk-ibm128.c                  |   1 +
 .../test-printf-chk-ieee128.c                 |   1 +
 .../test-printf-chk-ldbl-compat.c             | 179 ++++++++++++++++++
 .../test-printf-chk-redir-ibm128.c            |   2 +
 .../test-printf-chk-redir-ieee128.c           |   2 +
 19 files changed, 649 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 0b6948e5af..3f7e53adad 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -57,6 +57,31 @@ $(objpfx)test-printf-size-ibm128.out: \
 	$(evaluate-test)
 endif
 
+ifeq ($(subdir),debug)
+ldbl-extra-routines += asprintf_chk \
+		       dprintf_chk \
+		       fprintf_chk \
+		       printf_chk \
+		       snprintf_chk \
+		       sprintf_chk \
+		       vasprintf_chk \
+		       vdprintf_chk \
+		       vfprintf_chk \
+		       vprintf_chk \
+		       vsnprintf_chk \
+		       vsprintf_chk
+
+tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128
+CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-printf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-printf-chk-redir-ieee128 test-printf-chk-redir-ibm128
+CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \
+					  -Wno-psabi -Wno-unused-result
+CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
+					 -Wno-unused-result
+endif
+
 # Add IEEE binary128 files as make targets.
 routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 0485a2b5d4..aac08a3ad3 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -142,5 +142,19 @@ libc {
     __vfwprintfieee128;
     __vswprintfieee128;
     __vwprintfieee128;
+
+    __asprintf_chkieee128;
+    __dprintf_chkieee128;
+    __fprintf_chkieee128;
+    __printf_chkieee128;
+    __snprintf_chkieee128;
+    __sprintf_chkieee128;
+
+    __vasprintf_chkieee128;
+    __vdprintf_chkieee128;
+    __vfprintf_chkieee128;
+    __vprintf_chkieee128;
+    __vsnprintf_chkieee128;
+    __vsprintf_chkieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
new file mode 100644
index 0000000000..149fc046b6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __asprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_asprintf_chk (char **string_ptr, int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vasprintf_internal (string_ptr, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_asprintf_chk, __asprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
new file mode 100644
index 0000000000..724fb0bd43
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __dprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_dprintf_chk (int d, int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vdprintf_internal (d, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_dprintf_chk, __dprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
new file mode 100644
index 0000000000..fc15b0bfbd
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __fprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fprintf_chk (FILE *fp, int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfprintf_internal (fp, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fprintf_chk, __fprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
new file mode 100644
index 0000000000..f3fe2900c3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __printf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_printf_chk (int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfprintf_internal (stdout, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_printf_chk, __printf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
new file mode 100644
index 0000000000..7f19962dd5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __snprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
+			const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  va_start (ap, format);
+  done = __vsnprintf_internal (s, maxlen, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_snprintf_chk, __snprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
new file mode 100644
index 0000000000..7cea1225c0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __sprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_sprintf_chk (char *s, int flag, size_t slen,
+		       const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (slen == 0)
+    __chk_fail ();
+
+  va_start (ap, format);
+  done = __vsprintf_internal (s, slen, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_sprintf_chk, __sprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
new file mode 100644
index 0000000000..c496ebe5a3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __vasprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vasprintf_chk (char **result_ptr, int flag, const char *format,
+			 va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vasprintf_internal (result_ptr, format, ap, mode);
+}
+strong_alias (___ieee128_vasprintf_chk, __vasprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
new file mode 100644
index 0000000000..1b96f5fd21
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vdprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vdprintf_chk (int d, int flag, const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vdprintf_internal (d, format, ap, mode);
+}
+strong_alias (___ieee128_vdprintf_chk, __vdprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
new file mode 100644
index 0000000000..67b29b5e55
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vfprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfprintf_internal (fp, format, ap, mode);
+}
+strong_alias (___ieee128_vfprintf_chk, __vfprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
new file mode 100644
index 0000000000..15d3e82d76
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vprintf_chk (int flag, const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfprintf_internal (stdout, format, ap, mode);
+}
+strong_alias (___ieee128_vprintf_chk, __vprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
new file mode 100644
index 0000000000..8df93abf33
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vsnprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsnprintf_chk (char *string, size_t maxlen, int flag,
+			 size_t slen, const char *format, va_list ap)
+{
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vsnprintf_internal (string, maxlen, format, ap, mode);
+}
+strong_alias (___ieee128_vsnprintf_chk, __vsnprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
new file mode 100644
index 0000000000..3de4c12199
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vsprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsprintf_chk (char *string, int flag, size_t slen,
+			const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (slen == 0)
+    __chk_fail ();
+
+  return __vsprintf_internal (string, slen, format, ap, mode);
+}
+strong_alias (___ieee128_vsprintf_chk, __vsprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
new file mode 100644
index 0000000000..7d50284d9c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-printf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
new file mode 100644
index 0000000000..7d50284d9c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-printf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
new file mode 100644
index 0000000000..f3d18c92ec
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
@@ -0,0 +1,179 @@
+/* Test for the long double variants of *printf_chk functions.
+   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/>.  */
+
+#define _FORTIFY_SOURCE 2
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const char *format, ...)
+{
+  char *buffer = NULL;
+  char string[128];
+  int res;
+  va_list args;
+
+  printf ("%20s", "__vasprintf_chk: ");
+  va_start (args, format);
+  res = __vasprintf_chk (&buffer, 1, format, args);
+  va_end (args);
+  if (res == -1)
+    printf ("Error using vasprintf\n");
+  if (buffer == NULL)
+    printf ("Error using vasprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%20s", "__vdprintf_chk: ");
+  va_start (args, format);
+  __vdprintf_chk (fileno (stream), 1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "__vfprintf_chk: ");
+  va_start (args, format);
+  __vfprintf_chk (stream, 1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "__vprintf_chk: ");
+  va_start (args, format);
+  __vprintf_chk (1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "__vsnprintf_chk: ");
+  va_start (args, format);
+  __vsnprintf_chk (string, 79, 1, 127, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%20s", "__vsprintf_chk: ");
+  va_start (args, format);
+  __vsprintf_chk (string, 1, 127, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const char *format, long double ld)
+{
+  char *buffer = NULL;
+  char string[128];
+  int res;
+
+  printf ("%20s", "__asprintf_chk: ");
+  res = __asprintf_chk (&buffer, 1, format, ld);
+  if (res == -1)
+    printf ("Error using vasprintf\n");
+  if (buffer == NULL)
+    printf ("Error using asprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%20s", "__dprintf_chk: ");
+  __dprintf_chk (fileno (stream), 1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "__fprintf_chk: ");
+  __fprintf_chk (stdout, 1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "__printf_chk: ");
+  __printf_chk (1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "__snprintf_chk: ");
+  __snprintf_chk (string, 79, 1, 127, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%20s", "__sprintf_chk: ");
+  __sprintf_chk (string, 1, 127, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, "%.10Lf", ld);
+  do_test_call_varg (stdout, "%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, "%.10La", ld);
+  do_test_call_varg (stdout, "%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "    __asprintf_chk: -1.0000000000\n"
+    "     __dprintf_chk: -1.0000000000\n"
+    "     __fprintf_chk: -1.0000000000\n"
+    "      __printf_chk: -1.0000000000\n"
+    "    __snprintf_chk: -1.0000000000\n"
+    "     __sprintf_chk: -1.0000000000\n"
+    "   __vasprintf_chk: -1.0000000000\n"
+    "    __vdprintf_chk: -1.0000000000\n"
+    "    __vfprintf_chk: -1.0000000000\n"
+    "     __vprintf_chk: -1.0000000000\n"
+    "   __vsnprintf_chk: -1.0000000000\n"
+    "    __vsprintf_chk: -1.0000000000\n"
+    "    __asprintf_chk: -0x1.0000000000p+0\n"
+    "     __dprintf_chk: -0x1.0000000000p+0\n"
+    "     __fprintf_chk: -0x1.0000000000p+0\n"
+    "      __printf_chk: -0x1.0000000000p+0\n"
+    "    __snprintf_chk: -0x1.0000000000p+0\n"
+    "     __sprintf_chk: -0x1.0000000000p+0\n"
+    "   __vasprintf_chk: -0x1.0000000000p+0\n"
+    "    __vdprintf_chk: -0x1.0000000000p+0\n"
+    "    __vfprintf_chk: -0x1.0000000000p+0\n"
+    "     __vprintf_chk: -0x1.0000000000p+0\n"
+    "   __vsnprintf_chk: -0x1.0000000000p+0\n"
+    "    __vsprintf_chk: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
new file mode 100644
index 0000000000..aeab22412b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
new file mode 100644
index 0000000000..aeab22412b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 4/6] ldbl-128ibm-compat: Add wide character, fortified printing functions
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
                   ` (2 preceding siblings ...)
  2019-08-09 18:31 ` [PATCH 3/6] ldbl-128ibm-compat: Add regular character, fortified " Gabriel F. T. Gomes
@ 2019-08-09 18:31 ` Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 5/6] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

Similarly to what was done for the regular character, fortified printing
functions, this patch combines the mode masks PRINTF_LDBL_USES_FLOAT128
and PRINTF_FORTIFY to provide wide character versions of fortified
printf functions.  It also adds two flavors of test cases: one that
explicitly calls the fortified functions, and another that reuses the
non-fortified test, but defining _FORTIFY_SOURCE as 2.  The first
guarantees that the implementations are actually being tested
(independently of what's in bits/wchar2.h), whereas the second
guarantees that the redirections calls the correct function in the IBM
and IEEE long double cases.

Tested for powerpc64le.

	* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
	[subdir == debug] (ldbl-extra-routines): Add
	fwprintf_chk, swprintf_chk, wprintf_chk, vfwprintf_chk,
	vswprintf_chk, and vwprintf_chk.
	[subdir == debug] (tests-internal): Add
	test-wprintf-chk-ieee128, test-wprintf-chk-ibm128,
	test-wprintf-chk-redir-ieee128 and test-wprintf-chk-redir-ibm128.
	[subdir == debug] (CFLAGS-test-wprintf-chk-ieee128.c): New
	variable to add the relevant -mabi flags to the compilation.
	[subdir == debug] (CFLAGS-test-wprintf-chk-ibm128.c): Likewise.
	[subdir == debug] (CFLAGS-test-wprintf-chk-redir-ieee128.c):
	Likewise.
	[subdir == debug] (CFLAGS-test-wprintf-chk-redir-ibm128.c):
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
	__fwprintf_chkieee128, __swprintf_chkieee128,
	__wprintf_chkieee128, __vfwprintf_chkieee128,
	__vswprintf_chkieee128, and __vwprintf_chkieee128;
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c:
	New file.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c:
	Likewise.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  18 ++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |   8 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |  38 ++++++
 .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |  42 +++++++
 .../ieee128-vfwprintf_chk.c                   |  31 +++++
 .../ieee128-vswprintf_chk.c                   |  34 ++++++
 .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |  30 +++++
 .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |  38 ++++++
 .../test-wprintf-chk-ibm128.c                 |   1 +
 .../test-wprintf-chk-ieee128.c                |   1 +
 .../test-wprintf-chk-ldbl-compat.c            | 113 ++++++++++++++++++
 .../test-wprintf-chk-redir-ibm128.c           |   2 +
 .../test-wprintf-chk-redir-ieee128.c          |   2 +
 13 files changed, 357 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 3f7e53adad..4a2c5947b0 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -69,7 +69,13 @@ ldbl-extra-routines += asprintf_chk \
 		       vfprintf_chk \
 		       vprintf_chk \
 		       vsnprintf_chk \
-		       vsprintf_chk
+		       vsprintf_chk \
+		       fwprintf_chk \
+		       swprintf_chk \
+		       wprintf_chk \
+		       vfwprintf_chk \
+		       vswprintf_chk \
+		       vwprintf_chk
 
 tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128
 CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
@@ -80,6 +86,16 @@ CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \
 					  -Wno-psabi -Wno-unused-result
 CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
 					 -Wno-unused-result
+
+tests-internal += test-wprintf-chk-ieee128 test-wprintf-chk-ibm128
+CFLAGS-test-wprintf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wprintf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-wprintf-chk-redir-ieee128 test-wprintf-chk-redir-ibm128
+CFLAGS-test-wprintf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \
+					   -Wno-psabi -Wno-unused-result
+CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
+					  -Wno-unused-result
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index aac08a3ad3..e438c7c306 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -156,5 +156,13 @@ libc {
     __vprintf_chkieee128;
     __vsnprintf_chkieee128;
     __vsprintf_chkieee128;
+
+    __fwprintf_chkieee128;
+    __swprintf_chkieee128;
+    __wprintf_chkieee128;
+
+    __vfwprintf_chkieee128;
+    __vswprintf_chkieee128;
+    __vwprintf_chkieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
new file mode 100644
index 0000000000..04d2632e6c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __fwprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fwprintf_chk (FILE *fp, int flag, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (fp, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fwprintf_chk, __fwprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
new file mode 100644
index 0000000000..854ff2ef2c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __swprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_swprintf_chk (wchar_t *string, size_t maxlen, int flag,
+			size_t slen, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  va_start (ap, format);
+  done = __vswprintf_internal (string, maxlen, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_swprintf_chk, __swprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
new file mode 100644
index 0000000000..2f880930ff
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __vfwprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfwprintf_chk (FILE *fp, int flag, const wchar_t *format,
+			 va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfwprintf_internal (fp, format, ap, mode);
+}
+strong_alias (___ieee128_vfwprintf_chk, __vfwprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
new file mode 100644
index 0000000000..0d995cacf4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vswprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vswprintf_chk (wchar_t *string, size_t maxlen, int flag,
+			 size_t slen, const wchar_t *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  return __vswprintf_internal (string, maxlen, format, ap, mode);
+}
+strong_alias (___ieee128_vswprintf_chk, __vswprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
new file mode 100644
index 0000000000..5e47dccc0d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vwprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vwprintf_chk (int flag, const wchar_t *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfwprintf_internal (stdout, format, ap, mode);
+}
+strong_alias (___ieee128_vwprintf_chk, __vwprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
new file mode 100644
index 0000000000..ba00b7be54
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __wprintf_chk.  IEEE128 version.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_wprintf_chk (int flag, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (stdout, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_wprintf_chk, __wprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
new file mode 100644
index 0000000000..5323df71e2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-wprintf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
new file mode 100644
index 0000000000..5323df71e2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-wprintf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
new file mode 100644
index 0000000000..f614004f27
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
@@ -0,0 +1,113 @@
+/* Test for the long double variants of *w*printf_chk functions.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#define _FORTIFY_SOURCE 2
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const wchar_t *format, ...)
+{
+  wchar_t string[128];
+  va_list args;
+
+  wprintf (L"%20Ls", L"__vfwprintf_chk: ");
+  va_start (args, format);
+  __vfwprintf_chk (stream, 1, format, args);
+  va_end (args);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__vswprintf_chk: ");
+  va_start (args, format);
+  __vswprintf_chk (string, 79, 1, 127, format, args);
+  va_end (args);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__vwprintf_chk: ");
+  va_start (args, format);
+  __vwprintf_chk (1, format, args);
+  va_end (args);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+{
+  wchar_t string[128];
+
+  wprintf (L"%20Ls", L"__fwprintf_chk: ");
+  __fwprintf_chk (stream, 1, format, ld);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__swprintf_chk: ");
+  __swprintf_chk (string, 79, 1, 127, format, ld);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__wprintf_chk: ");
+  __wprintf_chk (1, format, ld);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, L"%.10Lf", ld);
+  do_test_call_varg (stdout, L"%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, L"%.10La", ld);
+  do_test_call_varg (stdout, L"%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "    __fwprintf_chk: -1.0000000000\n"
+    "    __swprintf_chk: -1.0000000000\n"
+    "     __wprintf_chk: -1.0000000000\n"
+    "   __vfwprintf_chk: -1.0000000000\n"
+    "   __vswprintf_chk: -1.0000000000\n"
+    "    __vwprintf_chk: -1.0000000000\n"
+    "    __fwprintf_chk: -0x1.0000000000p+0\n"
+    "    __swprintf_chk: -0x1.0000000000p+0\n"
+    "     __wprintf_chk: -0x1.0000000000p+0\n"
+    "   __vfwprintf_chk: -0x1.0000000000p+0\n"
+    "   __vswprintf_chk: -0x1.0000000000p+0\n"
+    "    __vwprintf_chk: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
new file mode 100644
index 0000000000..a12186a945
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
new file mode 100644
index 0000000000..a12186a945
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c>
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 5/6] ldbl-128ibm-compat: Test double values
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
                   ` (3 preceding siblings ...)
  2019-08-09 18:31 ` [PATCH 4/6] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-08-09 18:31 ` Gabriel F. T. Gomes
  2019-08-09 18:31 ` [PATCH 6/6] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
  2019-09-02 14:15 ` Ping. Re: [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
  6 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

A single format string can take double and long double parameters at the
same time.  Internally, these parameters are routed to the same
function, which correctly reads them and calls the underlying functions
responsible for the actual conversion to string.  This patch adds a new
case to test this scenario.

Tested for powerpc64le.

	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c:
	(do_test_call_rarg): Add parameter of double type and use it in
	the calls to *printf functions under test.
	(do_test_call): Add a parameter of double type to the calls to
	do_test_call_rarg and do_test_call_varg.
	(do_test): Update expected result.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c:
	Likewise.
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c:
	Likewise.
---
 .../test-printf-chk-ldbl-compat.c             | 72 ++++++++++---------
 .../test-printf-ldbl-compat.c                 | 71 +++++++++---------
 .../test-wprintf-chk-ldbl-compat.c            | 42 +++++------
 .../test-wprintf-ldbl-compat.c                | 42 +++++------
 4 files changed, 117 insertions(+), 110 deletions(-)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
index f3d18c92ec..e8e124425b 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
@@ -83,14 +83,15 @@ do_test_call_varg (FILE *stream, const char *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const char *format, long double ld)
+do_test_call_rarg (FILE *stream, const char *format, long double ld,
+		   double d)
 {
   char *buffer = NULL;
   char string[128];
   int res;
 
   printf ("%20s", "__asprintf_chk: ");
-  res = __asprintf_chk (&buffer, 1, format, ld);
+  res = __asprintf_chk (&buffer, 1, format, ld, d);
   if (res == -1)
     printf ("Error using vasprintf\n");
   if (buffer == NULL)
@@ -103,24 +104,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld)
   printf ("\n");
 
   printf ("%20s", "__dprintf_chk: ");
-  __dprintf_chk (fileno (stream), 1, format, ld);
+  __dprintf_chk (fileno (stream), 1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "__fprintf_chk: ");
-  __fprintf_chk (stdout, 1, format, ld);
+  __fprintf_chk (stdout, 1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "__printf_chk: ");
-  __printf_chk (1, format, ld);
+  __printf_chk (1, format, ld, d);
   printf ("\n");
 
   printf ("%20s", "__snprintf_chk: ");
-  __snprintf_chk (string, 79, 1, 127, format, ld);
+  __snprintf_chk (string, 79, 1, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 
   printf ("%20s", "__sprintf_chk: ");
-  __sprintf_chk (string, 1, 127, format, ld);
+  __sprintf_chk (string, 1, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 }
@@ -129,14 +130,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, "%.10Lf", ld);
-  do_test_call_varg (stdout, "%.10Lf", ld);
+  do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, "%.10La", ld);
-  do_test_call_varg (stdout, "%.10La", ld);
+  do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
 }
 
 static int
@@ -147,30 +149,30 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "    __asprintf_chk: -1.0000000000\n"
-    "     __dprintf_chk: -1.0000000000\n"
-    "     __fprintf_chk: -1.0000000000\n"
-    "      __printf_chk: -1.0000000000\n"
-    "    __snprintf_chk: -1.0000000000\n"
-    "     __sprintf_chk: -1.0000000000\n"
-    "   __vasprintf_chk: -1.0000000000\n"
-    "    __vdprintf_chk: -1.0000000000\n"
-    "    __vfprintf_chk: -1.0000000000\n"
-    "     __vprintf_chk: -1.0000000000\n"
-    "   __vsnprintf_chk: -1.0000000000\n"
-    "    __vsprintf_chk: -1.0000000000\n"
-    "    __asprintf_chk: -0x1.0000000000p+0\n"
-    "     __dprintf_chk: -0x1.0000000000p+0\n"
-    "     __fprintf_chk: -0x1.0000000000p+0\n"
-    "      __printf_chk: -0x1.0000000000p+0\n"
-    "    __snprintf_chk: -0x1.0000000000p+0\n"
-    "     __sprintf_chk: -0x1.0000000000p+0\n"
-    "   __vasprintf_chk: -0x1.0000000000p+0\n"
-    "    __vdprintf_chk: -0x1.0000000000p+0\n"
-    "    __vfprintf_chk: -0x1.0000000000p+0\n"
-    "     __vprintf_chk: -0x1.0000000000p+0\n"
-    "   __vsnprintf_chk: -0x1.0000000000p+0\n"
-    "    __vsprintf_chk: -0x1.0000000000p+0\n";
+    "    __asprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __dprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __fprintf_chk: -1.0000000000, -1.0000000000\n"
+    "      __printf_chk: -1.0000000000, -1.0000000000\n"
+    "    __snprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __sprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vasprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vdprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vfprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __vprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vsnprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vsprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __asprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __dprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __fprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      __printf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __snprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __sprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vasprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vdprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vfprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __vprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vsnprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
index 939a6aad9c..2b8d424473 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -78,13 +78,13 @@ do_test_call_varg (FILE *stream, const char *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const char *format, long double ld)
+do_test_call_rarg (FILE *stream, const char *format, long double ld, double d)
 {
   char *buffer = NULL;
   char string[128];
 
   printf ("%15s", "asprintf: ");
-  asprintf (&buffer, format, ld);
+  asprintf (&buffer, format, ld, d);
   if (buffer == NULL)
     printf ("Error using asprintf\n");
   else
@@ -95,24 +95,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld)
   printf ("\n");
 
   printf ("%15s", "dprintf: ");
-  dprintf (fileno (stream), format, ld);
+  dprintf (fileno (stream), format, ld, d);
   printf ("\n");
 
   printf ("%15s", "fprintf: ");
-  fprintf (stream, format, ld);
+  fprintf (stream, format, ld, d);
   printf ("\n");
 
   printf ("%15s", "printf: ");
-  printf (format, ld);
+  printf (format, ld, d);
   printf ("\n");
 
   printf ("%15s", "snprintf: ");
-  snprintf (string, 127, format, ld);
+  snprintf (string, 127, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 
   printf ("%15s", "sprintf: ");
-  sprintf (string, format, ld);
+  sprintf (string, format, ld, d);
   printf ("%s", string);
   printf ("\n");
 }
@@ -121,14 +121,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, "%.10Lf", ld);
-  do_test_call_varg (stdout, "%.10Lf", ld);
+  do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, "%.10La", ld);
-  do_test_call_varg (stdout, "%.10La", ld);
+  do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
 }
 
 static int
@@ -139,30 +140,30 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "     asprintf: -1.0000000000\n"
-    "      dprintf: -1.0000000000\n"
-    "      fprintf: -1.0000000000\n"
-    "       printf: -1.0000000000\n"
-    "     snprintf: -1.0000000000\n"
-    "      sprintf: -1.0000000000\n"
-    "    vasprintf: -1.0000000000\n"
-    "     vdprintf: -1.0000000000\n"
-    "     vfprintf: -1.0000000000\n"
-    "      vprintf: -1.0000000000\n"
-    "    vsnprintf: -1.0000000000\n"
-    "     vsprintf: -1.0000000000\n"
-    "     asprintf: -0x1.0000000000p+0\n"
-    "      dprintf: -0x1.0000000000p+0\n"
-    "      fprintf: -0x1.0000000000p+0\n"
-    "       printf: -0x1.0000000000p+0\n"
-    "     snprintf: -0x1.0000000000p+0\n"
-    "      sprintf: -0x1.0000000000p+0\n"
-    "    vasprintf: -0x1.0000000000p+0\n"
-    "     vdprintf: -0x1.0000000000p+0\n"
-    "     vfprintf: -0x1.0000000000p+0\n"
-    "      vprintf: -0x1.0000000000p+0\n"
-    "    vsnprintf: -0x1.0000000000p+0\n"
-    "     vsprintf: -0x1.0000000000p+0\n";
+    "     asprintf: -1.0000000000, -1.0000000000\n"
+    "      dprintf: -1.0000000000, -1.0000000000\n"
+    "      fprintf: -1.0000000000, -1.0000000000\n"
+    "       printf: -1.0000000000, -1.0000000000\n"
+    "     snprintf: -1.0000000000, -1.0000000000\n"
+    "      sprintf: -1.0000000000, -1.0000000000\n"
+    "    vasprintf: -1.0000000000, -1.0000000000\n"
+    "     vdprintf: -1.0000000000, -1.0000000000\n"
+    "     vfprintf: -1.0000000000, -1.0000000000\n"
+    "      vprintf: -1.0000000000, -1.0000000000\n"
+    "    vsnprintf: -1.0000000000, -1.0000000000\n"
+    "     vsprintf: -1.0000000000, -1.0000000000\n"
+    "     asprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      dprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      fprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "       printf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     snprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      sprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vasprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vdprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vfprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      vprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vsnprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
index f614004f27..0dcabec38a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
@@ -53,21 +53,22 @@ do_test_call_varg (FILE *stream, const wchar_t *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld,
+		   double d)
 {
   wchar_t string[128];
 
   wprintf (L"%20Ls", L"__fwprintf_chk: ");
-  __fwprintf_chk (stream, 1, format, ld);
+  __fwprintf_chk (stream, 1, format, ld, d);
   wprintf (L"\n");
 
   wprintf (L"%20Ls", L"__swprintf_chk: ");
-  __swprintf_chk (string, 79, 1, 127, format, ld);
+  __swprintf_chk (string, 79, 1, 127, format, ld, d);
   wprintf (L"%Ls", string);
   wprintf (L"\n");
 
   wprintf (L"%20Ls", L"__wprintf_chk: ");
-  __wprintf_chk (1, format, ld);
+  __wprintf_chk (1, format, ld, d);
   wprintf (L"\n");
 }
 
@@ -75,14 +76,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, L"%.10Lf", ld);
-  do_test_call_varg (stdout, L"%.10Lf", ld);
+  do_test_call_rarg (stdout, L"%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, L"%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, L"%.10La", ld);
-  do_test_call_varg (stdout, L"%.10La", ld);
+  do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, L"%.10La, %.10a", ld, d);
 }
 
 static int
@@ -93,18 +95,18 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "    __fwprintf_chk: -1.0000000000\n"
-    "    __swprintf_chk: -1.0000000000\n"
-    "     __wprintf_chk: -1.0000000000\n"
-    "   __vfwprintf_chk: -1.0000000000\n"
-    "   __vswprintf_chk: -1.0000000000\n"
-    "    __vwprintf_chk: -1.0000000000\n"
-    "    __fwprintf_chk: -0x1.0000000000p+0\n"
-    "    __swprintf_chk: -0x1.0000000000p+0\n"
-    "     __wprintf_chk: -0x1.0000000000p+0\n"
-    "   __vfwprintf_chk: -0x1.0000000000p+0\n"
-    "   __vswprintf_chk: -0x1.0000000000p+0\n"
-    "    __vwprintf_chk: -0x1.0000000000p+0\n";
+    "    __fwprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __swprintf_chk: -1.0000000000, -1.0000000000\n"
+    "     __wprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vfwprintf_chk: -1.0000000000, -1.0000000000\n"
+    "   __vswprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __vwprintf_chk: -1.0000000000, -1.0000000000\n"
+    "    __fwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __swprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     __wprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vfwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vswprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
index 71edfec235..def4337571 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -51,21 +51,22 @@ do_test_call_varg (FILE *stream, const wchar_t *format, ...)
 }
 
 static void
-do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld,
+		   double d)
 {
   wchar_t string[128];
 
   wprintf (L"%15Ls", L"fwprintf: ");
-  fwprintf (stream, format, ld);
+  fwprintf (stream, format, ld, d);
   wprintf (L"\n");
 
   wprintf (L"%15Ls", L"swprintf: ");
-  swprintf (string, 127, format, ld);
+  swprintf (string, 127, format, ld, d);
   wprintf (L"%Ls", string);
   wprintf (L"\n");
 
   wprintf (L"%15Ls", L"wprintf: ");
-  wprintf (format, ld);
+  wprintf (format, ld, d);
   wprintf (L"\n");
 }
 
@@ -73,14 +74,15 @@ static void
 do_test_call (void)
 {
   long double ld = -1;
+  double d = -1;
 
   /* Print in decimal notation.  */
-  do_test_call_rarg (stdout, L"%.10Lf", ld);
-  do_test_call_varg (stdout, L"%.10Lf", ld);
+  do_test_call_rarg (stdout, L"%.10Lf, %.10f", ld, d);
+  do_test_call_varg (stdout, L"%.10Lf, %.10f", ld, d);
 
   /* Print in hexadecimal notation.  */
-  do_test_call_rarg (stdout, L"%.10La", ld);
-  do_test_call_varg (stdout, L"%.10La", ld);
+  do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d);
+  do_test_call_varg (stdout, L"%.10La, %.10a", ld, d);
 }
 
 static int
@@ -91,18 +93,18 @@ do_test (void)
 
   /* Compare against the expected output.  */
   const char *expected =
-    "     fwprintf: -1.0000000000\n"
-    "     swprintf: -1.0000000000\n"
-    "      wprintf: -1.0000000000\n"
-    "    vfwprintf: -1.0000000000\n"
-    "    vswprintf: -1.0000000000\n"
-    "     vwprintf: -1.0000000000\n"
-    "     fwprintf: -0x1.0000000000p+0\n"
-    "     swprintf: -0x1.0000000000p+0\n"
-    "      wprintf: -0x1.0000000000p+0\n"
-    "    vfwprintf: -0x1.0000000000p+0\n"
-    "    vswprintf: -0x1.0000000000p+0\n"
-    "     vwprintf: -0x1.0000000000p+0\n";
+    "     fwprintf: -1.0000000000, -1.0000000000\n"
+    "     swprintf: -1.0000000000, -1.0000000000\n"
+    "      wprintf: -1.0000000000, -1.0000000000\n"
+    "    vfwprintf: -1.0000000000, -1.0000000000\n"
+    "    vswprintf: -1.0000000000, -1.0000000000\n"
+    "     vwprintf: -1.0000000000, -1.0000000000\n"
+    "     fwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     swprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "      wprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vfwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vswprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "     vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [PATCH 6/6] ldbl-128ibm-compat: Test positional arguments
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
                   ` (4 preceding siblings ...)
  2019-08-09 18:31 ` [PATCH 5/6] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
@ 2019-08-09 18:31 ` Gabriel F. T. Gomes
  2019-09-02 14:15 ` Ping. Re: [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
  6 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-09 18:31 UTC (permalink / raw)
  To: libc-alpha

From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>

The format string can request positional parameters, instead of relying
on the order in which they appear as arguments.  Since this has an
effect on how the type of each argument is determined, this patch
extends the test cases to use positional parameters with mixed double
and long double types, to verify that the IEEE long double
implementations of *printf work correctly in this scenario.

Tested for powerpc64le.

	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
	* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
	* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
	(do_test_call): Test positional parameters.
	(do_test): Add results for positional parameters test.
---
 .../ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c | 12 +++++++++++-
 .../ldbl-128ibm-compat/test-printf-ldbl-compat.c     | 12 +++++++++++-
 .../test-wprintf-chk-ldbl-compat.c                   |  9 ++++++++-
 .../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c    |  9 ++++++++-
 4 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
index e8e124425b..153a35d451 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
@@ -139,6 +139,10 @@ do_test_call (void)
   /* Print in hexadecimal notation.  */
   do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
   do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
+
+  /* Test positional parameters.  */
+  do_test_call_varg (stdout, "%3$Lf, %2$Lf, %1$f",
+		     (double) 1, (long double) 2, (long double) 3);
 }
 
 static int
@@ -172,7 +176,13 @@ do_test (void)
     "    __vfprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "     __vprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "   __vsnprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
-    "    __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
+    "    __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vasprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "    __vdprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "    __vfprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "     __vprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "   __vsnprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "    __vsprintf_chk: 3.000000, 2.000000, 1.000000\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
index 2b8d424473..5b0e8d3bae 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -130,6 +130,10 @@ do_test_call (void)
   /* Print in hexadecimal notation.  */
   do_test_call_rarg (stdout, "%.10La, %.10a", ld, d);
   do_test_call_varg (stdout, "%.10La, %.10a", ld, d);
+
+  /* Test positional parameters.  */
+  do_test_call_varg (stdout, "%3$Lf, %2$Lf, %1$f",
+		     (double) 1, (long double) 2, (long double) 3);
 }
 
 static int
@@ -163,7 +167,13 @@ do_test (void)
     "     vfprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "      vprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "    vsnprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
-    "     vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
+    "     vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vasprintf: 3.000000, 2.000000, 1.000000\n"
+    "     vdprintf: 3.000000, 2.000000, 1.000000\n"
+    "     vfprintf: 3.000000, 2.000000, 1.000000\n"
+    "      vprintf: 3.000000, 2.000000, 1.000000\n"
+    "    vsnprintf: 3.000000, 2.000000, 1.000000\n"
+    "     vsprintf: 3.000000, 2.000000, 1.000000\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
index 0dcabec38a..49174625d4 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
@@ -85,6 +85,10 @@ do_test_call (void)
   /* Print in hexadecimal notation.  */
   do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d);
   do_test_call_varg (stdout, L"%.10La, %.10a", ld, d);
+
+  /* Test positional parameters.  */
+  do_test_call_varg (stdout, L"%3$Lf, %2$Lf, %1$f",
+		     (double) 1, (long double) 2, (long double) 3);
 }
 
 static int
@@ -106,7 +110,10 @@ do_test (void)
     "     __wprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "   __vfwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "   __vswprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
-    "    __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
+    "    __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "   __vfwprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "   __vswprintf_chk: 3.000000, 2.000000, 1.000000\n"
+    "    __vwprintf_chk: 3.000000, 2.000000, 1.000000\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
index def4337571..008275f529 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -83,6 +83,10 @@ do_test_call (void)
   /* Print in hexadecimal notation.  */
   do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d);
   do_test_call_varg (stdout, L"%.10La, %.10a", ld, d);
+
+  /* Test positional parameters.  */
+  do_test_call_varg (stdout, L"%3$Lf, %2$Lf, %1$f",
+		     (double) 1, (long double) 2, (long double) 3);
 }
 
 static int
@@ -104,7 +108,10 @@ do_test (void)
     "      wprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "    vfwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
     "    vswprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
-    "     vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n";
+    "     vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"
+    "    vfwprintf: 3.000000, 2.000000, 1.000000\n"
+    "    vswprintf: 3.000000, 2.000000, 1.000000\n"
+    "     vwprintf: 3.000000, 2.000000, 1.000000\n";
   TEST_COMPARE_STRING (expected, result.out.buffer);
 
   return 0;
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions
  2019-08-09 18:31 ` [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
@ 2019-08-14 11:46   ` Florian Weimer
  2019-08-15 18:30     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Weimer @ 2019-08-14 11:46 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

* Gabriel F. T. Gomes:

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index 412beb5b5c..102973add9 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile

> +# The following rule ensures that the string conversion routines will
> +# always be built in IBM long double mode, with additional support for
> +# IEEE binary128, through the use of -mabi=ibmlongdouble and -mfloat128.
> +ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \
> +		     $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \
> +		     $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^)
> +obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1)))

Why isn't the assignment to obj-suf-foreach dead?

Shouldn't this patch have abilist updates?

Thanks,
Florian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions
  2019-08-14 11:46   ` Florian Weimer
@ 2019-08-15 18:30     ` Gabriel F. T. Gomes
  2019-09-02 14:03       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-08-15 18:30 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Wed, 14 Aug 2019, Florian Weimer wrote:

>* Gabriel F. T. Gomes:
>
>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
>> index 412beb5b5c..102973add9 100644
>> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile  
>
>> +# The following rule ensures that the string conversion routines will
>> +# always be built in IBM long double mode, with additional support for
>> +# IEEE binary128, through the use of -mabi=ibmlongdouble and -mfloat128.
>> +ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \
>> +		     $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \
>> +		     $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^)
>> +obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1)))  
>
>Why isn't the assignment to obj-suf-foreach dead?

Oh!  There's a hunk missing in this patch.  It should have the following
extra statement:

+$(call obj-suf-foreach,$(ldbl-ibm128-files)): \
+  sysdep-CFLAGS += -mabi=ibmlongdouble

I accidentally removed it when preparing the patch for submission.  Sorry
and thanks for catching it.

It does not affect the test results because there's nothing currently
adding -mabi=ieeelongdouble to the build of powerpc64le files.  Anyway,
I'll reinstate this hunk locally, because it makes it clear *and explicit*
that these files must be built with -mabi=ibmlongdouble, regardless of
what becomes the default (if the default changes).

>Shouldn't this patch have abilist updates?

I kept the abilist change in the last commit on the branch [1] I mentioned
in the cover letter.  In that commit, this sysdeps directory
(ldbl-128ibm-compat) gets actually added to the Implies list.

The idea behind this decision is that the header redirections in our
installed headers (e.g.: stdio-ldbl.h) is implemented in a way that it
works for all functions or for none, so, I'm adding the functions to the
repository now (and testing with the development branch), but actually
enabling them only happens in the last commit.

[1] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/gabriel/powerpc-ieee128-printscan

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions
  2019-08-15 18:30     ` Gabriel F. T. Gomes
@ 2019-09-02 14:03       ` Gabriel F. T. Gomes
  2019-09-02 14:28         ` Florian Weimer
  0 siblings, 1 reply; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-09-02 14:03 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Thu, 15 Aug 2019, Gabriel F. T. Gomes wrote:

>On Wed, 14 Aug 2019, Florian Weimer wrote:
>
>>Why isn't the assignment to obj-suf-foreach dead?  
>
>Oh!  There's a hunk missing in this patch.  It should have the following
>extra statement:
>
>+$(call obj-suf-foreach,$(ldbl-ibm128-files)): \
>+  sysdep-CFLAGS += -mabi=ibmlongdouble
>
>I accidentally removed it when preparing the patch for submission.  Sorry
>and thanks for catching it.
>
>It does not affect the test results because there's nothing currently
>adding -mabi=ieeelongdouble to the build of powerpc64le files.  Anyway,
>I'll reinstate this hunk locally, because it makes it clear *and explicit*
>that these files must be built with -mabi=ibmlongdouble, regardless of
>what becomes the default (if the default changes).

Are you OK with this explanation (and amendment)?  I like the idea of
making it explicit that -mabi=ibmlongdouble is required for these files.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Ping. Re: [PATCH 0/6] IEEE long double printf and friends for powerpc64le
  2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
                   ` (5 preceding siblings ...)
  2019-08-09 18:31 ` [PATCH 6/6] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
@ 2019-09-02 14:15 ` Gabriel F. T. Gomes
  6 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-09-02 14:15 UTC (permalink / raw)
  To: libc-alpha

Any comments on these patches?

I believe I have addressed all the comments in previous submissions.

On Fri, 09 Aug 2019, Gabriel F. T. Gomes wrote:

>From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>
>A long time ago [1], I sent a patch set with the initial implementations
>of many string to/from IEEE long double conversion routines for
>powerpc64le.  The patch set depended on other, at the time unapplied,
>patch sets [2,3], which are now all integrated into master.  Even though
>this dependency existed, I got a lot of feedback (thanks, btw), which I
>tried to address for this new round.
>
>In this thread, I only included printf and friends functions, which
>helps reduce the size of the patch set and maybe ease review. :)
>
>As with previous submissions, these changes can only be tested once all
>other functions have actually been integrated (because the function
>redirections in our installed headers are macroized and work for all
>long double routines).  So, in order to test it, I use a more complete
>branch, which I made available at:
>https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/gabriel/powerpc-ieee128-printscan
>
>[1] https://sourceware.org/ml/libc-alpha/2018-06/msg00652.html
>[2] https://sourceware.org/ml/libc-alpha/2018-10/msg00612.html
>[3] https://sourceware.org/ml/libc-alpha/2019-02/msg00582.html
>
>Gabriel F. T. Gomes (6):
>  ldbl-128ibm-compat: Add regular character printing functions
>  ldbl-128ibm-compat: Add wide character printing functions
>  ldbl-128ibm-compat: Add regular character, fortified printing
>    functions
>  ldbl-128ibm-compat: Add wide character, fortified printing functions
>  ldbl-128ibm-compat: Test double values
>  ldbl-128ibm-compat: Test positional arguments

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions
  2019-09-02 14:03       ` Gabriel F. T. Gomes
@ 2019-09-02 14:28         ` Florian Weimer
  2019-09-02 15:11           ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 13+ messages in thread
From: Florian Weimer @ 2019-09-02 14:28 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

* Gabriel F. T. Gomes:

> On Thu, 15 Aug 2019, Gabriel F. T. Gomes wrote:
>
>>On Wed, 14 Aug 2019, Florian Weimer wrote:
>>
>>>Why isn't the assignment to obj-suf-foreach dead?  
>>
>>Oh!  There's a hunk missing in this patch.  It should have the following
>>extra statement:
>>
>>+$(call obj-suf-foreach,$(ldbl-ibm128-files)): \
>>+  sysdep-CFLAGS += -mabi=ibmlongdouble
>>
>>I accidentally removed it when preparing the patch for submission.  Sorry
>>and thanks for catching it.
>>
>>It does not affect the test results because there's nothing currently
>>adding -mabi=ieeelongdouble to the build of powerpc64le files.  Anyway,
>>I'll reinstate this hunk locally, because it makes it clear *and explicit*
>>that these files must be built with -mabi=ibmlongdouble, regardless of
>>what becomes the default (if the default changes).
>
> Are you OK with this explanation (and amendment)?  I like the idea of
> making it explicit that -mabi=ibmlongdouble is required for these files.

Sure, but it's not clear to me what the current state of the entire
series.  Is there a branch on sourceware with the updated set of
patches?

Thanks,
Florian

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions
  2019-09-02 14:28         ` Florian Weimer
@ 2019-09-02 15:11           ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 13+ messages in thread
From: Gabriel F. T. Gomes @ 2019-09-02 15:11 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

On Mon, 02 Sep 2019, Florian Weimer wrote:

>Sure, but it's not clear to me what the current state of the entire
>series.  Is there a branch on sourceware with the updated set of
>patches?

Yes, there is.  It has been updated when I submitted this patch set, so I
haven't updated it again (let me know if you think that this is too old
and that I should updated it again).

Here's the link:

https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/gabriel/powerpc-ieee128-printscan

Alternatively, I could post all these patches in a single patch set, but I
have the impression that posting related patches in smaller sets is
preferred (I might be wrong).

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-09-02 15:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 18:31 [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes
2019-08-09 18:31 ` [PATCH 1/6] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
2019-08-14 11:46   ` Florian Weimer
2019-08-15 18:30     ` Gabriel F. T. Gomes
2019-09-02 14:03       ` Gabriel F. T. Gomes
2019-09-02 14:28         ` Florian Weimer
2019-09-02 15:11           ` Gabriel F. T. Gomes
2019-08-09 18:31 ` [PATCH 2/6] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
2019-08-09 18:31 ` [PATCH 3/6] ldbl-128ibm-compat: Add regular character, fortified " Gabriel F. T. Gomes
2019-08-09 18:31 ` [PATCH 4/6] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
2019-08-09 18:31 ` [PATCH 5/6] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
2019-08-09 18:31 ` [PATCH 6/6] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
2019-09-02 14:15 ` Ping. Re: [PATCH 0/6] IEEE long double printf and friends for powerpc64le Gabriel F. T. Gomes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).