[04/14] ldbl-128ibm-compat: Add regular character printing functions

Message ID 20180621021023.17036-5-gabriel@inconstante.eti.br
State New, archived
Headers

Commit Message

Gabriel F. T. Gomes June 21, 2018, 2:10 a.m. UTC
  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.

Tested for powerpc64le.

	* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
	[subdir == stdio-common] (routines): Add ieee128-asprintf,
	ieee128-dprintf, ieee128-fprintf, ieee128-printf,
	ieee128-snprintf, ieee128-sprintf, ieee128-vasprintf,
	ieee128-vdprintf, ieee128-vfprintf, ieee128-vprintf,
	ieee128-vsnprintf, and ieee128-vsprintf.
	[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.
	[subdir == stdio-common && run-built-tests == yes]
	(tests-special): Add $(objpfx)test-printf-ieee128.out and
	$(objpfx)test-printf-ibm128.out.
	[subdir == stdio-common] ($(objpfx)test-printf-ieee128.out):
	New build and test rule.
	[subdir == stdio-common] ($(objpfx)test-printf-ibm128.out):
	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/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h:
	Likewise.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile        |  46 +++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions        |  17 +++
 .../ieee754/ldbl-128ibm-compat/ieee128-asprintf.c  |  35 ++++++
 .../ieee754/ldbl-128ibm-compat/ieee128-dprintf.c   |  34 ++++++
 .../ieee754/ldbl-128ibm-compat/ieee128-fprintf.c   |  34 ++++++
 .../ieee754/ldbl-128ibm-compat/ieee128-printf.c    |  35 ++++++
 .../ieee754/ldbl-128ibm-compat/ieee128-snprintf.c  |  35 ++++++
 .../ieee754/ldbl-128ibm-compat/ieee128-sprintf.c   |  35 ++++++
 .../ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c |  27 +++++
 .../ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c  |  26 ++++
 .../ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c  |  26 ++++
 .../ieee754/ldbl-128ibm-compat/ieee128-vprintf.c   |  27 +++++
 .../ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c |  28 +++++
 .../ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c  |  27 +++++
 .../ldbl-128ibm-compat/test-printf-ibm128.c        |   1 +
 .../ldbl-128ibm-compat/test-printf-ieee128.c       |   1 +
 .../ldbl-128ibm-compat/test-printf-ldbl-compat.c   | 134 +++++++++++++++++++++
 .../ldbl-128ibm-compat/test-printf-ldbl-compat.sh  |  64 ++++++++++
 .../powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h  |   8 ++
 19 files changed, 640 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makefile
 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/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
  

Comments

Joseph Myers June 21, 2018, 9:03 p.m. UTC | #1
I noted in my review of a previous version of the printf changes that 
there should be a test involving positional arguments (%n$La, etc., where 
n is the position of the long double argument in that case) - because of 
the significantly different code paths involved in processing formats 
using such arguments.  I don't see any tests with positional arguments in 
this patch series.
  

Patch

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
new file mode 100644
index 0000000000..7cc05b85ab
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -0,0 +1,46 @@ 
+ifeq ($(subdir),stdio-common)
+# Wrappers for *printf functions that take long double arguments with
+# IEEE binary128 format
+routines += ieee128-asprintf
+routines += ieee128-dprintf
+routines += ieee128-fprintf
+routines += ieee128-printf
+routines += ieee128-snprintf
+routines += ieee128-sprintf
+
+routines += ieee128-vasprintf
+routines += ieee128-vdprintf
+routines += ieee128-vfprintf
+routines += ieee128-vprintf
+routines += ieee128-vsnprintf
+routines += ieee128-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 passed to the compiler.
+CFLAGS-vfprintf-internal.c += -mfloat128
+
+# 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
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)test-printf-ieee128.out
+tests-special += $(objpfx)test-printf-ibm128.out
+endif
+
+$(objpfx)test-printf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh \
+  $(objpfx)test-printf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-printf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh \
+  $(objpfx)test-printf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 322041132e..c55c2c1b4a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -111,3 +111,20 @@  libm {
     __ynieee128;
   }
 }
+libc {
+  LDBL_IBM128_VERSION {
+    __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..543b646c3e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
@@ -0,0 +1,35 @@ 
+/* Wrapper for asprintf.  IEEE128 version.
+   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/>.  */
+
+#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..2c7ea41b92
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
@@ -0,0 +1,34 @@ 
+/* Wrapper for dprintf.  IEEE128 version.
+   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/>.  */
+
+#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..e4b9bc66a5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
@@ -0,0 +1,34 @@ 
+/* Wrapper for fprintf.  IEEE128 version.
+   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/>.  */
+
+#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..acf7479d2c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
@@ -0,0 +1,35 @@ 
+/* Wrapper for printf.  IEEE128 version.
+   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/>.  */
+
+#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..f1b4bb8111
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
@@ -0,0 +1,35 @@ 
+/* Wrapper for snprintf.  IEEE128 version.
+   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/>.  */
+
+#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..d0790f0a11
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
@@ -0,0 +1,35 @@ 
+/* Wrapper for sprintf.  IEEE128 version.
+   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/>.  */
+
+#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..ae9714790e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
@@ -0,0 +1,27 @@ 
+/* Wrapper for vasprintf.  IEEE128 version.
+   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/>.  */
+
+#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..d02b56299f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
@@ -0,0 +1,26 @@ 
+/* Wrapper for vdprintf.  IEEE128 version.
+   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/>.  */
+
+#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..8f5e268516
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
@@ -0,0 +1,26 @@ 
+/* Wrapper for vfprintf.  IEEE128 version.
+   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/>.  */
+
+#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..40ffe87ae2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
@@ -0,0 +1,27 @@ 
+/* Wrapper for vprintf.  IEEE128 version.
+   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/>.  */
+
+#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..f597df429d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
@@ -0,0 +1,28 @@ 
+/* Wrapper for vsnprintf.  IEEE128 version.
+   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/>.  */
+
+#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..29d6e24c2f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
@@ -0,0 +1,27 @@ 
+/* Wrapper for vsprintf.  IEEE128 version.
+   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/>.  */
+
+#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..936e85f8d6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -0,0 +1,134 @@ 
+/* Test for the long double variants of *printf 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/>.  */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.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 ("%20s", "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 ("%20s", "vdprintf: ");
+  va_start (args, format);
+  vdprintf (1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "vfprintf: ");
+  va_start (args, format);
+  vfprintf (stream, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "vprintf: ");
+  va_start (args, format);
+  vprintf (format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "vsnprintf: ");
+  va_start (args, format);
+  vsnprintf (string, 127, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%20s", "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 ("%20s", "asprintf: ");
+  asprintf (&buffer, format, ld);
+  if (buffer == NULL)
+    printf ("Error using asprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%20s", "dprintf: ");
+  dprintf (1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "fprintf: ");
+  fprintf (stdout, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "printf: ");
+  printf (format, ld);
+  printf ("\n");
+
+  printf ("%20s", "snprintf: ");
+  snprintf (string, 127, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%20s", "sprintf: ");
+  sprintf (string, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static int
+do_test (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, "%.60Lf", ld);
+  do_test_call_varg (stdout, "%.60Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, "%.60La", ld);
+  do_test_call_varg (stdout, "%.60La", ld);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
new file mode 100644
index 0000000000..62bc5d03a6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
@@ -0,0 +1,64 @@ 
+#!/bin/sh
+# Testing of *printf.  IEEE binary128 for powerpc64le version.
+# 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/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+  ${test_program} \
+  > ${test_program_output} || status=1
+
+cat <<'EOF' |
+          asprintf: -1.000000000000000000000000000000000000000000000000000000000000
+           dprintf: -1.000000000000000000000000000000000000000000000000000000000000
+           fprintf: -1.000000000000000000000000000000000000000000000000000000000000
+            printf: -1.000000000000000000000000000000000000000000000000000000000000
+          snprintf: -1.000000000000000000000000000000000000000000000000000000000000
+           sprintf: -1.000000000000000000000000000000000000000000000000000000000000
+         vasprintf: -1.000000000000000000000000000000000000000000000000000000000000
+          vdprintf: -1.000000000000000000000000000000000000000000000000000000000000
+          vfprintf: -1.000000000000000000000000000000000000000000000000000000000000
+           vprintf: -1.000000000000000000000000000000000000000000000000000000000000
+         vsnprintf: -1.000000000000000000000000000000000000000000000000000000000000
+          vsprintf: -1.000000000000000000000000000000000000000000000000000000000000
+          asprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+           dprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+           fprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+            printf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+          snprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+           sprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+         vasprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+          vdprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+          vfprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+           vprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+         vsnprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+          vsprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+  status=1
+  echo "*** output comparison failed"
+}
+
+exit $status
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..6eb0e72b07
--- /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.28
+#define LDBL_IBM128_COMPAT_VERSION	GLIBC_2_28