public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 02/31] ldbl-128ibm-compat: Add wide character printing functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
@ 2019-10-15 19:05 ` Gabriel F. T. Gomes
  2019-10-15 19:05 ` [PATCH 01/31] ldbl-128ibm-compat: Add regular " Gabriel F. T. Gomes
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:05 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   |  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 89059f37e2..0f2f58d5b9 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	[flat|nested] 42+ messages in thread

* [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le
@ 2019-10-15 19:05 Gabriel F. T. Gomes
  2019-10-15 19:05 ` [PATCH 02/31] ldbl-128ibm-compat: Add wide character printing functions Gabriel F. T. Gomes
                   ` (30 more replies)
  0 siblings, 31 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:05 UTC (permalink / raw)
  To: libc-alpha

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

Hi,

I have previously sent some of the patches in this set, but sending only
part of them usually raised the concern that they were hard to test,
because they depended on the remaining patches (making it also hard to
review).  To make testing easier, I provided the remaining patches in a
public branch (even though some weren't fully done), but that is not
what we usually do, which also contributes for the patch set being hard
to test and review.

I wanted to change this, so I finished the patches that weren't fully
ready in the branch, and I'm finally sending it as a regular patch
series by email.

Some notes to ease review:

  - Many of the patches are somewhat independent, for instance, it
    should be possible for someone to review only the syslog or cvt
    patches, but not those related to printf*.  The reason why I want to
    send them together is that many of them touch the same file
    (sysdeps/ieee754/ldbl-128ibm-compat/Makefile), so the order is
    important in this sense (I can change the order before commit if
    some later patch gets positive reviews first).
  - Beware that the *cvt refactoring is composed of 5 patches, but I
    will commit them only after squashing all into a *single* commit.
  - The last patch in the series is what makes all of this patches
    actually be used, so it's needed for the testing (and the last one
    needs all the others, because the function redirections (in *-ldbl.h
    files) is all-or-nothing.
  - This patch set is also available as a branch in the repository [1]
    (commit ID 1c4f7fffc4f1 - branch gabriel/powerpc-ieee128-printscan),
    maybe that helps.

PS: I removed all the ChangeLog entries (Hurray!)

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

Gabriel F. T. Gomes (28):
  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
  ldbl-128ibm-compat: Add regular character scanning functions
  ldbl-128ibm-compat: Add wide character scanning functions
  ldbl-128ibm-compat: Add argp_error and argp_failure
  ldbl-128ibm-compat: Add err.h functions
  ldbl-128ibm-compat: Add error.h functions
  ldbl-128ibm-compat: Reuse tests for err.h and error.h functions
  ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  ldbl-128ibm-compat: Add obstack printing functions
  ldbl-128ibm-compat: Add syslog functions
  ldbl-128ibm-compat: Add tests for strfmon and strfmon_l
  ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
  Remove hidden_def and hidden_proto from cvt functions
  Refactor *cvt functions implementation (1/5)
  Refactor *cvt functions implementation (2/5)
  Refactor *cvt functions implementation (3/5)
  Refactor *cvt functions implementation (4/5)
  Refactor *cvt functions implementation (5/5)
  ldbl-128ibm-compat: Add *cvt functions
  Avoid compat symbols for totalorder in powerpc64le IEEE long double
  ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128
  powerpc64le: Require a compiler with -mno-gnu-attribute
  RFC: powerpc64le: Enable support for IEEE long double

Rajalakshmi Srinivasaraghavan (1):
  ldbl-128ibm-compat: Add strfmon_l with IEEE long double format

Tulio Magno Quites Machado Filho (2):
  Do not redirect calls to __GI_* symbols, when redirecting to *ieee128
  ldbl-128ibm-compat: Compiler flags for stdio functions

 argp/argp.h                                   |   4 +-
 elf/tst-addr1.c                               |   7 +-
 include/err.h                                 |   3 +
 include/monetary.h                            |   1 +
 include/stdio.h                               |  14 +-
 include/stdlib.h                              |  20 +-
 include/sys/syslog.h                          |   5 +
 include/wchar.h                               |   7 +
 libio/bits/stdio-ldbl.h                       |  46 ++-
 libio/stdio.h                                 |  19 +-
 misc/bits/syslog-ldbl.h                       |   4 +-
 misc/efgcvt-dbl-macros.h                      |  52 +++
 misc/efgcvt-ldbl-macros.h                     |  59 +++
 misc/efgcvt-template.c                        |  75 ++++
 misc/efgcvt.c                                 | 130 ++-----
 misc/efgcvt_r-template.c                      | 195 ++++++++++
 misc/efgcvt_r.c                               | 257 +------------
 misc/err.h                                    |   4 +-
 misc/errP.h                                   |  28 ++
 misc/error.h                                  |   7 +-
 misc/errorP.h                                 |  28 ++
 misc/qefgcvt.c                                |  43 +--
 misc/qefgcvt_r.c                              |  48 +--
 misc/sys/cdefs.h                              |  41 ++-
 misc/sys/syslog.h                             |   5 +-
 stdio-common/printf.h                         |   4 +-
 stdlib/bits/stdlib-ldbl.h                     |  22 ++
 stdlib/monetary.h                             |   4 +-
 stdlib/stdlib.h                               |   5 +-
 stdlib/strfmon_l.c                            |  31 +-
 sysdeps/ieee754/ldbl-128/s_totalorderl.c      |   2 +
 sysdeps/ieee754/ldbl-128/s_totalordermagl.c   |   2 +
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 337 +++++++++++++++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   | 111 ++++++
 .../ldbl-128ibm-compat/bits/long-double.h     |  25 ++
 .../ldbl-128ibm-compat/ieee128-argp-help.c    |  42 +++
 .../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 ++
 .../ieee754/ldbl-128ibm-compat/ieee128-err.c  |  93 +++++
 .../ldbl-128ibm-compat/ieee128-error.c        |  51 +++
 .../ldbl-128ibm-compat/ieee128-fprintf.c      |  34 ++
 .../ldbl-128ibm-compat/ieee128-fprintf_chk.c  |  38 ++
 .../ldbl-128ibm-compat/ieee128-fscanf.c       |  34 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf.c     |  35 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |  38 ++
 .../ldbl-128ibm-compat/ieee128-fwscanf.c      |  35 ++
 .../ieee128-isoc99_fscanf.c                   |  35 ++
 .../ieee128-isoc99_fwscanf.c                  |  35 ++
 .../ldbl-128ibm-compat/ieee128-isoc99_scanf.c |  35 ++
 .../ieee128-isoc99_sscanf.c                   |  39 ++
 .../ieee128-isoc99_swscanf.c                  |  40 +++
 .../ieee128-isoc99_vfscanf.c                  |  27 ++
 .../ieee128-isoc99_vfwscanf.c                 |  27 ++
 .../ieee128-isoc99_vscanf.c                   |  27 ++
 .../ieee128-isoc99_vsscanf.c                  |  30 ++
 .../ieee128-isoc99_vswscanf.c                 |  32 ++
 .../ieee128-isoc99_vwscanf.c                  |  27 ++
 .../ieee128-isoc99_wscanf.c                   |  35 ++
 .../ldbl-128ibm-compat/ieee128-obprintf.c     |  42 +++
 .../ldbl-128ibm-compat/ieee128-obstack_chk.c  |  39 ++
 .../ldbl-128ibm-compat/ieee128-printf.c       |  35 ++
 .../ldbl-128ibm-compat/ieee128-printf_chk.c   |  38 ++
 .../ldbl-128ibm-compat/ieee128-qefgcvt.c      |  52 +++
 .../ldbl-128ibm-compat/ieee128-qefgcvt_r.c    |  34 ++
 .../ldbl-128ibm-compat/ieee128-scanf.c        |  34 ++
 .../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-sscanf.c       |  38 ++
 .../ldbl-128ibm-compat/ieee128-strfmon.c      |  35 ++
 .../ldbl-128ibm-compat/ieee128-strfmon_l.c    |  35 ++
 .../ldbl-128ibm-compat/ieee128-swprintf.c     |  36 ++
 .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |  42 +++
 .../ldbl-128ibm-compat/ieee128-swscanf.c      |  40 +++
 .../ldbl-128ibm-compat/ieee128-syslog.c       |  65 ++++
 .../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-vfscanf.c      |  26 ++
 .../ldbl-128ibm-compat/ieee128-vfwprintf.c    |  27 ++
 .../ieee128-vfwprintf_chk.c                   |  31 ++
 .../ldbl-128ibm-compat/ieee128-vfwscanf.c     |  27 ++
 .../ldbl-128ibm-compat/ieee128-vobstack_chk.c |  31 ++
 .../ldbl-128ibm-compat/ieee128-vprintf.c      |  27 ++
 .../ldbl-128ibm-compat/ieee128-vprintf_chk.c  |  30 ++
 .../ldbl-128ibm-compat/ieee128-vscanf.c       |  26 ++
 .../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-vsscanf.c      |  29 ++
 .../ldbl-128ibm-compat/ieee128-vswprintf.c    |  28 ++
 .../ieee128-vswprintf_chk.c                   |  34 ++
 .../ldbl-128ibm-compat/ieee128-vswscanf.c     |  32 ++
 .../ldbl-128ibm-compat/ieee128-vwprintf.c     |  27 ++
 .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |  30 ++
 .../ldbl-128ibm-compat/ieee128-vwscanf.c      |  27 ++
 .../ldbl-128ibm-compat/ieee128-wprintf.c      |  35 ++
 .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |  38 ++
 .../ldbl-128ibm-compat/ieee128-wscanf.c       |  35 ++
 .../test-isoc99-scanf-ibm128.c                |  13 +
 .../test-isoc99-scanf-ieee128.c               |  13 +
 .../test-isoc99-scanf-ldbl-compat-template.c  | 119 +++++++
 .../test-isoc99-scanf-ldbl-compat.c           |  10 +
 .../test-isoc99-scanf-ldbl-compat.sh          |  53 +++
 .../test-isoc99-wscanf-ibm128.c               |  13 +
 .../test-isoc99-wscanf-ieee128.c              |  13 +
 .../test-isoc99-wscanf-ldbl-compat.c          |  10 +
 .../test-obstack-chk-ibm128.c                 |   1 +
 .../test-obstack-chk-ieee128.c                |   1 +
 .../test-obstack-chk-ldbl-compat.c            |   6 +
 .../ldbl-128ibm-compat/test-obstack-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-obstack-ieee128.c |   1 +
 .../test-obstack-ldbl-compat-template.c       |  64 ++++
 .../test-obstack-ldbl-compat.c                |   6 +
 .../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 ++++++++++
 .../ldbl-128ibm-compat/test-scanf-ibm128.c    |   1 +
 .../ldbl-128ibm-compat/test-scanf-ieee128.c   |   1 +
 .../test-scanf-ldbl-compat-template.c         | 121 +++++++
 .../test-scanf-ldbl-compat.c                  |  10 +
 .../test-scanf-ldbl-compat.sh                 |  63 ++++
 .../ldbl-128ibm-compat/test-strfmon-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-strfmon-ieee128.c |   1 +
 .../test-strfmon-ldbl-compat.c                |  59 +++
 .../ldbl-128ibm-compat/test-strfrom-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-strfrom-ieee128.c |   1 +
 .../test-strfrom-ldbl-compat.c                |  49 +++
 .../test-syslog-chk-ibm128.c                  |   1 +
 .../test-syslog-chk-ieee128.c                 |   1 +
 .../test-syslog-chk-ldbl-compat.c             |   6 +
 .../ldbl-128ibm-compat/test-syslog-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-syslog-ieee128.c  |   1 +
 .../test-syslog-ldbl-compat-template.c        |  66 ++++
 .../test-syslog-ldbl-compat.c                 |   6 +
 .../ldbl-128ibm-compat/test-wcstold-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-wcstold-ieee128.c |   1 +
 .../test-wcstold-ldbl-compat.c                |  36 ++
 .../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 +++++++
 .../ldbl-128ibm-compat/test-wscanf-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-wscanf-ieee128.c  |   1 +
 .../test-wscanf-ldbl-compat.c                 |  10 +
 sysdeps/powerpc/powerpc64/le/Implies-before   |   1 +
 sysdeps/powerpc/powerpc64/le/configure        |  29 ++
 sysdeps/powerpc/powerpc64/le/configure.ac     |  15 +
 .../powerpc64/le/ldbl-128ibm-compat-abi.h     |   8 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |  93 +++++
 .../linux/powerpc/powerpc64/le/libm.abilist   | 104 ++++++
 wcsmbs/bits/wchar-ldbl.h                      |  36 +-
 wcsmbs/wchar.h                                |  17 +-
 169 files changed, 5360 insertions(+), 469 deletions(-)
 create mode 100644 misc/efgcvt-dbl-macros.h
 create mode 100644 misc/efgcvt-ldbl-macros.h
 create mode 100644 misc/efgcvt-template.c
 create mode 100644 misc/efgcvt_r-template.c
 create mode 100644 misc/errP.h
 create mode 100644 misc/errorP.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c
 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-err.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.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-fscanf.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-fwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_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-qefgcvt.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.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-sscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.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-swscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.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-vfscanf.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-vfwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_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-vscanf.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-vsscanf.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-vswscanf.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-vwscanf.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/ieee128-wscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.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-scanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-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/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-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] 42+ messages in thread

* [PATCH 01/31] ldbl-128ibm-compat: Add regular character printing functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
  2019-10-15 19:05 ` [PATCH 02/31] ldbl-128ibm-compat: Add wide character printing functions Gabriel F. T. Gomes
@ 2019-10-15 19:05 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 04/31] ldbl-128ibm-compat: Add wide character, fortified " Gabriel F. T. Gomes
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:05 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                               |   7 +-
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  47 ++++-
 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, 617 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..89059f37e2 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,23 @@ $(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)))
+$(call obj-suf-foreach,$(ldbl-ibm128-files)): \
+  sysdep-CFLAGS += -mabi=ibmlongdouble
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	[flat|nested] 42+ messages in thread

* [PATCH 12/31] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (3 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 08/31] ldbl-128ibm-compat: Add wide character scanning functions Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 07/31] ldbl-128ibm-compat: Add regular character scanning functions Gabriel F. T. Gomes
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 UTC (permalink / raw)
  To: libc-alpha

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

Commit IDs 9771e6cb5102 and 7597b0c7f711 added tests for the functions
from err.h and error.h that can take long double parameters.
Afterwards, commit ID f0eaf8627654 reused them on architectures that
changed the long double format from the same as double to something else
(i.e.: architectures that imply ldbl-opt).  This patch reuses it again
for IEEE long double on powerpc64le.

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index a09209a2dd..ed0e2ec098 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -177,6 +177,21 @@ endif
 ifeq ($(subdir),misc)
 ldbl-extra-routines += err \
 		       error
+
+tests-internal += tst-ibm128-warn tst-ieee128-warn
+tests-internal += tst-ibm128-error tst-ieee128-error
+
+$(objpfx)tst-ibm128-%.c: tst-ldbl-%.c
+	cp $< $@
+
+$(objpfx)tst-ieee128-%.c: tst-ldbl-%.c
+	cp $< $@
+
+CFLAGS-tst-ibm128-warn.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi
+
+CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 endif
 
 # Add IEEE binary128 files as make targets.
-- 
2.21.0

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

* [PATCH 07/31] ldbl-128ibm-compat: Add regular character scanning functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (4 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 12/31] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 11/31] ldbl-128ibm-compat: Add error.h functions Gabriel F. T. Gomes
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 UTC (permalink / raw)
  To: libc-alpha

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

The 'mode' argument to __vfscanf_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,
SCANF_LDBL_USES_FLOAT128, which tells __vfscanf_internal to call
__strtof128_internal, instead of __strtold_internal, and save the output
into a _Float128 variable.

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  37 +++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |   8 ++
 .../ldbl-128ibm-compat/ieee128-fscanf.c       |  34 +++++
 .../ldbl-128ibm-compat/ieee128-scanf.c        |  34 +++++
 .../ldbl-128ibm-compat/ieee128-sscanf.c       |  38 ++++++
 .../ldbl-128ibm-compat/ieee128-vfscanf.c      |  26 ++++
 .../ldbl-128ibm-compat/ieee128-vscanf.c       |  26 ++++
 .../ldbl-128ibm-compat/ieee128-vsscanf.c      |  29 +++++
 .../ldbl-128ibm-compat/test-scanf-ibm128.c    |   1 +
 .../ldbl-128ibm-compat/test-scanf-ieee128.c   |   1 +
 .../test-scanf-ldbl-compat-template.c         | 117 ++++++++++++++++++
 .../test-scanf-ldbl-compat.c                  |  10 ++
 .../test-scanf-ldbl-compat.sh                 |  63 ++++++++++
 13 files changed, 421 insertions(+), 3 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 7217987aa5..a1f0f7d74e 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -17,15 +17,23 @@ ldbl-extra-routines += printf_size \
 		       wprintf \
 		       vfwprintf \
 		       vswprintf \
-		       vwprintf
+		       vwprintf \
+		       fscanf \
+		       scanf \
+		       sscanf \
+		       vfscanf \
+		       vscanf \
+		       vsscanf
 
 # 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
+# and __float128 variables and union members).  Likewise, reading these
+# values reuses __strtof128_internal.  Thus, the compilation of 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
+CFLAGS-vfscanf-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.
@@ -37,6 +45,29 @@ 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-scanf-ieee128 test-scanf-ibm128
+CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link)
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)test-scanf-ieee128.out
+tests-special += $(objpfx)test-scanf-ibm128.out
+endif
+
+$(objpfx)test-scanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-scanf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-scanf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-scanf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
 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 e438c7c306..7971c7a7d1 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -164,5 +164,13 @@ libc {
     __vfwprintf_chkieee128;
     __vswprintf_chkieee128;
     __vwprintf_chkieee128;
+
+    __fscanfieee128;
+    __scanfieee128;
+    __sscanfieee128;
+
+    __vfscanfieee128;
+    __vscanfieee128;
+    __vsscanfieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
new file mode 100644
index 0000000000..f51e822094
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
@@ -0,0 +1,34 @@
+/* Wrapper for fscanf.  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_fscanf (FILE *fp, const char *format, ...)
+{
+  va_list arg;
+  int done;
+
+  va_start (arg, format);
+  done = __vfscanf_internal (fp, format, arg, SCANF_LDBL_USES_FLOAT128);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_fscanf, __fscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
new file mode 100644
index 0000000000..571cf7d75d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
@@ -0,0 +1,34 @@
+/* Wrapper for scanf.  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_scanf (const char *format, ...)
+{
+  va_list arg;
+  int done;
+
+  va_start (arg, format);
+  done = __vfscanf_internal (stdin, format, arg, SCANF_LDBL_USES_FLOAT128);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_scanf, __scanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
new file mode 100644
index 0000000000..7c932955f6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
@@ -0,0 +1,38 @@
+/* Wrapper for sscanf.  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 <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_sscanf (const char *string, const char *format, ...)
+{
+  va_list arg;
+  int done;
+
+  _IO_strfile sf;
+  FILE *fp = _IO_strfile_read (&sf, string);
+
+  va_start (arg, format);
+  done = __vfscanf_internal (fp, format, arg, SCANF_LDBL_USES_FLOAT128);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_sscanf, __sscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
new file mode 100644
index 0000000000..d6654e05f5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vfscanf.  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_vfscanf (FILE *fp, const char *format, va_list ap)
+{
+  return __vfscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfscanf, __vfscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
new file mode 100644
index 0000000000..5780c062bb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vscanf.  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_vscanf (const char *format, va_list ap)
+{
+  return __vfscanf_internal (stdin, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vscanf, __vscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
new file mode 100644
index 0000000000..8ff43a95c2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
@@ -0,0 +1,29 @@
+/* Wrapper for vsscanf.  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 <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_vsscanf (const char *string, const char *format, va_list ap)
+{
+  _IO_strfile sf;
+  FILE *fp = _IO_strfile_read (&sf, string);
+  return __vfscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsscanf, __vsscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
new file mode 100644
index 0000000000..8cdee601f2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
@@ -0,0 +1 @@
+#include <test-scanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
new file mode 100644
index 0000000000..8cdee601f2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
@@ -0,0 +1 @@
+#include <test-scanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
new file mode 100644
index 0000000000..4590e9da96
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
@@ -0,0 +1,117 @@
+/* Test for the long double variants of *scanf 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 <string.h>
+#include <wchar.h>
+
+#include <support/check.h>
+
+#define CLEAR								\
+  va_start (args, format);						\
+  ld = va_arg (args, long double *);					\
+  *ld = 0;								\
+  va_end (args);
+
+#define CLEAR_VALUE value = 0;
+
+#define CHECK								\
+  va_start (args, format);						\
+  ld = va_arg (args, long double *);					\
+  va_end (args);							\
+  if (*ld == -1.0L)							\
+    printf ("OK");							\
+  else									\
+    printf ("ERROR (%.60Lf)", *ld);					\
+  printf ("\n");
+
+#define CHECK_VALUE							\
+  if (value == -1.0L)							\
+    printf ("OK");							\
+  else									\
+    printf ("ERROR (%.60Lf)", value);					\
+  printf ("\n");
+
+static void
+do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
+{
+  long double value;
+  long double *ld;
+  va_list args;
+
+  CLEAR_VALUE
+  printf ("fscanf: ");
+  FSCANF (stream, format, &value);
+  CHECK_VALUE
+
+  CLEAR_VALUE
+  printf ("scanf: ");
+  SCANF (format, &value);
+  CHECK_VALUE
+
+  CLEAR_VALUE
+  printf ("sscanf: ");
+  SSCANF (string, format, &value);
+  CHECK_VALUE
+
+  CLEAR
+  printf ("vfscanf: ");
+  va_start (args, format);
+  VFSCANF (stream, format, args);
+  va_end (args);
+  CHECK
+
+  CLEAR
+  printf ("vscanf: ");
+  va_start (args, format);
+  VSCANF (format, args);
+  va_end (args);
+  CHECK
+
+  CLEAR
+  printf ("vsscanf: ");
+  va_start (args, format);
+  VSSCANF (string, format, args);
+  va_end (args);
+  CHECK
+}
+
+static int
+do_test (void)
+{
+  CHAR string[256];
+  long double ld;
+
+  /* Scan in decimal notation.  */
+  STRCPY (string,
+	  L ("-1.0\n")
+	  L ("-1.0\n") );
+  do_test_call (stdin, string, L("%Lf"), &ld);
+
+  /* Scan in hexadecimal notation.  */
+  STRCPY (string,
+	  L ("-0x1.0p+0\n")
+	  L ("-0x1.0p+0\n") );
+  do_test_call (stdin, string, L("%La"), &ld);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
new file mode 100644
index 0000000000..0759d8afab
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
@@ -0,0 +1,10 @@
+#define CHAR char
+#define L(x) x
+#define FSCANF fscanf
+#define SSCANF sscanf
+#define SCANF scanf
+#define VFSCANF vfscanf
+#define VSSCANF vsscanf
+#define VSCANF vscanf
+#define STRCPY strcpy
+#include <test-scanf-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
new file mode 100644
index 0000000000..822b4c3607
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Testing of *scanf.  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
+
+cat <<'EOF' |
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+${test_program_prefix} \
+  ${test_program} \
+  - \
+  > ${test_program_output} || status=1
+
+cat <<'EOF' |
+fscanf: OK
+scanf: OK
+sscanf: OK
+vfscanf: OK
+vscanf: OK
+vsscanf: OK
+fscanf: OK
+scanf: OK
+sscanf: OK
+vfscanf: OK
+vscanf: OK
+vsscanf: OK
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+  status=1
+  echo "*** output comparison failed"
+}
+
+exit $status
-- 
2.21.0

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

* [PATCH 11/31] ldbl-128ibm-compat: Add error.h functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (5 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 07/31] ldbl-128ibm-compat: Add regular character scanning functions Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 06/31] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 UTC (permalink / raw)
  To: libc-alpha

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

Use the recently added, internal functions, __error_at_line_internal and
__error_internal, to provide error.h functions that can take long double
arguments with IEEE binary128 format on platforms where long double can
also take double format or some non-IEEE format (currently, this means
powerpc64le).

Tested for powerpc64le.
---
 misc/errorP.h                                 | 28 ++++++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  3 +-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  3 ++
 .../ldbl-128ibm-compat/ieee128-error.c        | 51 +++++++++++++++++++
 4 files changed, 84 insertions(+), 1 deletion(-)
 create mode 100644 misc/errorP.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c

diff --git a/misc/errorP.h b/misc/errorP.h
new file mode 100644
index 0000000000..c61c49cd61
--- /dev/null
+++ b/misc/errorP.h
@@ -0,0 +1,28 @@
+/* Prototypes for internal error.h 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>
+
+void
+__error_internal (int status, int errnum, const char *message,
+		  va_list args, unsigned int mode_flags);
+
+void
+__error_at_line_internal (int status, int errnum, const char *file_name,
+			  unsigned int line_number, const char *message,
+			  va_list args, unsigned int mode_flags);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 6bb0bed2fc..a09209a2dd 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -175,7 +175,8 @@ CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
 ifeq ($(subdir),misc)
-ldbl-extra-routines += err
+ldbl-extra-routines += err \
+		       error
 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 e2b3dda551..dead38cdcb 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -192,5 +192,8 @@ libc {
     __errxieee128;
     __verrieee128;
     __verrxieee128;
+
+    __errorieee128;
+    __error_at_lineieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c
new file mode 100644
index 0000000000..9c74e060d7
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c
@@ -0,0 +1,51 @@
+/* Wrappers for error.h functions.  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 <misc/errorP.h>
+#include <libio/libioP.h>
+
+#define IEEE128_ALIAS(name) \
+  strong_alias (___ieee128_##name, __##name##ieee128)
+
+#define IEEE128_DECL(name) ___ieee128_##name
+
+void
+IEEE128_DECL (error) (int status, int errnum, const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  __error_internal (status, errnum, message, ap,
+		    PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+IEEE128_ALIAS (error)
+
+void
+IEEE128_DECL (error_at_line) (int status, int errnum,
+			      const char *file_name,
+			      unsigned int line_number,
+			      const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  __error_at_line_internal (status, errnum, file_name, line_number,
+			    message, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+IEEE128_ALIAS (error_at_line)
-- 
2.21.0

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

* [PATCH 08/31] ldbl-128ibm-compat: Add wide character scanning functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (2 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 04/31] ldbl-128ibm-compat: Add wide character, fortified " Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 12/31] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions Gabriel F. T. Gomes
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 UTC (permalink / raw)
  To: libc-alpha

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

Similarly to what was done for regular character scanning functions,
this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, in the
'mode' argument of the wide characters scanning function,
__vfwscanf_internal (which is also extended to support scanning
floating-point values with IEEE binary128, by redirecting calls to
__wcstold_internal to __wcstof128_internal).

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 33 ++++++++++++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  8 ++++
 .../ldbl-128ibm-compat/ieee128-fwscanf.c      | 35 ++++++++++++++++
 .../ldbl-128ibm-compat/ieee128-swscanf.c      | 40 +++++++++++++++++++
 .../ldbl-128ibm-compat/ieee128-vfwscanf.c     | 27 +++++++++++++
 .../ldbl-128ibm-compat/ieee128-vswscanf.c     | 32 +++++++++++++++
 .../ldbl-128ibm-compat/ieee128-vwscanf.c      | 27 +++++++++++++
 .../ldbl-128ibm-compat/ieee128-wscanf.c       | 35 ++++++++++++++++
 .../ldbl-128ibm-compat/test-wscanf-ibm128.c   |  1 +
 .../ldbl-128ibm-compat/test-wscanf-ieee128.c  |  1 +
 .../test-wscanf-ldbl-compat.c                 | 10 +++++
 11 files changed, 248 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index a1f0f7d74e..031ee0b38f 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -1,3 +1,11 @@
+ifeq ($(subdir),libio)
+ldbl-extra-routines += fwscanf \
+		       swscanf \
+		       wscanf \
+		       vswscanf \
+		       vwscanf
+endif
+
 ifeq ($(subdir),stdio-common)
 ldbl-extra-routines += printf_size \
 		       asprintf \
@@ -23,7 +31,8 @@ ldbl-extra-routines += printf_size \
 		       sscanf \
 		       vfscanf \
 		       vscanf \
-		       vsscanf
+		       vsscanf \
+		       vfwscanf
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -34,6 +43,7 @@ ldbl-extra-routines += printf_size \
 CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-vfscanf-internal.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-vfwscanf-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.
@@ -51,9 +61,18 @@ CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
 $(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link)
 
+tests-internal += test-wscanf-ieee128 test-wscanf-ibm128
+CFLAGS-test-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link)
+
 ifeq ($(run-built-tests),yes)
 tests-special += $(objpfx)test-scanf-ieee128.out
 tests-special += $(objpfx)test-scanf-ibm128.out
+
+tests-special += $(objpfx)test-wscanf-ieee128.out
+tests-special += $(objpfx)test-wscanf-ibm128.out
 endif
 
 $(objpfx)test-scanf-ieee128.out: \
@@ -68,6 +87,18 @@ $(objpfx)test-scanf-ibm128.out: \
 	$(SHELL) $^ '$(test-program-prefix)' $@; \
 	$(evaluate-test)
 
+$(objpfx)test-wscanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-wscanf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-wscanf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-wscanf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
 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 7971c7a7d1..8b23fdf56f 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -172,5 +172,13 @@ libc {
     __vfscanfieee128;
     __vscanfieee128;
     __vsscanfieee128;
+
+    __fwscanfieee128;
+    __swscanfieee128;
+    __wscanfieee128;
+
+    __vfwscanfieee128;
+    __vswscanfieee128;
+    __vwscanfieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
new file mode 100644
index 0000000000..b4b10cf9f8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for fwscanf.  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 <libioP.h>
+
+extern int
+___ieee128_fwscanf (FILE *fp, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (fp, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fwscanf, __fwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
new file mode 100644
index 0000000000..c7dfc24a9b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
@@ -0,0 +1,40 @@
+/* Wrapper for swscanf.  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 <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_swscanf (const wchar_t *string, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+  FILE *fp = _IO_strfile_readw (&sf, &wd, string);
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (fp, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_swscanf, __swscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
new file mode 100644
index 0000000000..de4918f536
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vfwscanf.  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 <libioP.h>
+
+extern int
+___ieee128_vfwscanf (FILE *fp, const wchar_t *format, va_list ap)
+{
+  return __vfwscanf_internal (fp, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfwscanf, __vfwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
new file mode 100644
index 0000000000..a241d6bd5e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
@@ -0,0 +1,32 @@
+/* Wrapper for vswscanf.  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 <libioP.h>
+#include <wchar.h>
+#include <strfile.h>
+
+extern int
+___ieee128_vswscanf (const wchar_t *string, const wchar_t *format,
+		     va_list ap)
+{
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+  FILE *fp = _IO_strfile_readw (&sf, &wd, string);
+  return __vfwscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vswscanf, __vswscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
new file mode 100644
index 0000000000..0944794ac5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vwscanf.  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 <libioP.h>
+
+extern int
+___ieee128_vwscanf (const wchar_t *format, va_list ap)
+{
+  return __vfwscanf_internal (stdin, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vwscanf, __vwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
new file mode 100644
index 0000000000..417f326cb4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for wscanf.  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 <libioP.h>
+
+extern int
+___ieee128_wscanf (const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (stdin, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_wscanf, __wscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
new file mode 100644
index 0000000000..ef21fc4741
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
@@ -0,0 +1 @@
+#include <test-wscanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
new file mode 100644
index 0000000000..ef21fc4741
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
@@ -0,0 +1 @@
+#include <test-wscanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
new file mode 100644
index 0000000000..e93cf3b9bd
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
@@ -0,0 +1,10 @@
+#define CHAR wchar_t
+#define L(x) L##x
+#define FSCANF fwscanf
+#define SSCANF swscanf
+#define SCANF wscanf
+#define VFSCANF vfwscanf
+#define VSSCANF vswscanf
+#define VSCANF vwscanf
+#define STRCPY wcscpy
+#include <test-scanf-ldbl-compat-template.c>
-- 
2.21.0

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

* [PATCH 04/31] ldbl-128ibm-compat: Add wide character, fortified printing functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
  2019-10-15 19:05 ` [PATCH 02/31] ldbl-128ibm-compat: Add wide character printing functions Gabriel F. T. Gomes
  2019-10-15 19:05 ` [PATCH 01/31] ldbl-128ibm-compat: Add regular " Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 08/31] ldbl-128ibm-compat: Add wide character scanning functions Gabriel F. T. Gomes
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 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   |  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 21056e38da..7217987aa5 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	[flat|nested] 42+ messages in thread

* [PATCH 03/31] ldbl-128ibm-compat: Add regular character, fortified printing functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (9 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 05/31] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 14/31] ldbl-128ibm-compat: Add obstack " Gabriel F. T. Gomes
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 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   |  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 0f2f58d5b9..21056e38da 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	[flat|nested] 42+ messages in thread

* [PATCH 10/31] ldbl-128ibm-compat: Add err.h functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (7 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 06/31] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 05/31] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 UTC (permalink / raw)
  To: libc-alpha

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

Use the recently added, internal functions, __vwarnx_internal and
__vwarn_internal, to provide err.h functions that can take long double
arguments with IEEE binary128 format on platforms where long double can
also take double format or some non-IEEE format (currently, this means
powerpc64le).

Tested for powerpc64le.
---
 misc/errP.h                                   | 28 ++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  4 +
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  9 ++
 .../ieee754/ldbl-128ibm-compat/ieee128-err.c  | 93 +++++++++++++++++++
 4 files changed, 134 insertions(+)
 create mode 100644 misc/errP.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c

diff --git a/misc/errP.h b/misc/errP.h
new file mode 100644
index 0000000000..09e1f72289
--- /dev/null
+++ b/misc/errP.h
@@ -0,0 +1,28 @@
+/* Prototypes for internal err.h 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 <err.h>
+
+void
+__vwarnx_internal (const char *format, __gnuc_va_list ap,
+		   unsigned int mode_flags);
+
+void
+__vwarn_internal (const char *format, __gnuc_va_list ap,
+		   unsigned int mode_flags);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index dc1ceaae7e..6bb0bed2fc 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -174,6 +174,10 @@ CFLAGS-tst-ieee128-argp.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
+ifeq ($(subdir),misc)
+ldbl-extra-routines += err
+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 8e80b2bade..e2b3dda551 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -183,5 +183,14 @@ libc {
 
     __argp_errorieee128;
     __argp_failureieee128;
+
+    __warnieee128;
+    __warnxieee128;
+    __vwarnieee128;
+    __vwarnxieee128;
+    __errieee128;
+    __errxieee128;
+    __verrieee128;
+    __verrxieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
new file mode 100644
index 0000000000..8a34508e5e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
@@ -0,0 +1,93 @@
+/* Wrappers for err.h functions.  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 <misc/errP.h>
+#include <libio/libioP.h>
+
+#define VA(call)							\
+{									\
+  va_list ap;								\
+  va_start (ap, format);						\
+  IEEE128_CALL (call);							\
+  va_end (ap);								\
+}
+
+#define IEEE128_ALIAS(name) \
+  strong_alias (___ieee128_##name, __##name##ieee128)
+
+#define IEEE128_DECL(name) ___ieee128_##name
+#define IEEE128_CALL(name) ___ieee128_##name
+
+void
+IEEE128_DECL (vwarn) (const char *format, __gnuc_va_list ap)
+{
+  __vwarn_internal (format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+IEEE128_ALIAS (vwarn)
+
+void
+IEEE128_DECL (vwarnx) (const char *format, __gnuc_va_list ap)
+{
+  __vwarnx_internal (format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+IEEE128_ALIAS (vwarnx)
+
+void
+IEEE128_DECL (warn) (const char *format, ...)
+{
+  VA (vwarn (format, ap))
+}
+IEEE128_ALIAS (warn)
+
+void
+IEEE128_DECL (warnx) (const char *format, ...)
+{
+  VA (vwarnx (format, ap))
+}
+IEEE128_ALIAS (warnx)
+
+void
+IEEE128_DECL (verr) (int status, const char *format, __gnuc_va_list ap)
+{
+  IEEE128_CALL (vwarn) (format, ap);
+  exit (status);
+}
+IEEE128_ALIAS (verr)
+
+void
+IEEE128_DECL (verrx) (int status, const char *format, __gnuc_va_list ap)
+{
+  IEEE128_CALL (vwarnx) (format, ap);
+  exit (status);
+}
+IEEE128_ALIAS (verrx)
+
+void
+IEEE128_DECL (err) (int status, const char *format, ...)
+{
+  VA (verr (status, format, ap))
+}
+IEEE128_ALIAS (err)
+
+void
+IEEE128_DECL (errx) (int status, const char *format, ...)
+{
+  VA (verrx (status, format, ap))
+}
+IEEE128_ALIAS (errx)
-- 
2.21.0

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

* [PATCH 06/31] ldbl-128ibm-compat: Test positional arguments
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (6 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 11/31] ldbl-128ibm-compat: Add error.h functions Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 10/31] ldbl-128ibm-compat: Add err.h functions Gabriel F. T. Gomes
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 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.
---
 .../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	[flat|nested] 42+ messages in thread

* [PATCH 05/31] ldbl-128ibm-compat: Test double values
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (8 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 10/31] ldbl-128ibm-compat: Add err.h functions Gabriel F. T. Gomes
@ 2019-10-15 19:06 ` Gabriel F. T. Gomes
  2019-10-15 19:06 ` [PATCH 03/31] ldbl-128ibm-compat: Add regular character, fortified printing functions Gabriel F. T. Gomes
                   ` (20 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:06 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.
---
 .../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	[flat|nested] 42+ messages in thread

* [PATCH 14/31] ldbl-128ibm-compat: Add obstack printing functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (10 preceding siblings ...)
  2019-10-15 19:06 ` [PATCH 03/31] ldbl-128ibm-compat: Add regular character, fortified printing functions Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 13/31] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

Similarly to the functions from the *printf family, this patch adds
implementations for __obstack_*printf* functions that set the
'mode_flags' parameter to PRINTF_LDBL_USES_FLOAT128, before making calls
to __vfprintf_internal (indirectly through __obstack_vprintf_internal).

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 13 +++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  5 ++
 .../ldbl-128ibm-compat/ieee128-obprintf.c     | 42 ++++++++++++
 .../ldbl-128ibm-compat/ieee128-obstack_chk.c  | 39 +++++++++++
 .../ldbl-128ibm-compat/ieee128-vobstack_chk.c | 31 +++++++++
 .../test-obstack-chk-ibm128.c                 |  1 +
 .../test-obstack-chk-ieee128.c                |  1 +
 .../test-obstack-chk-ldbl-compat.c            |  6 ++
 .../ldbl-128ibm-compat/test-obstack-ibm128.c  |  1 +
 .../ldbl-128ibm-compat/test-obstack-ieee128.c |  1 +
 .../test-obstack-ldbl-compat-template.c       | 64 +++++++++++++++++++
 .../test-obstack-ldbl-compat.c                |  6 ++
 12 files changed, 209 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 1f944806e7..9e8237d075 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -47,7 +47,10 @@ ldbl-extra-routines += printf_size \
 		       isoc99_sscanf \
 		       isoc99_vfscanf \
 		       isoc99_vscanf \
-		       isoc99_vsscanf
+		       isoc99_vsscanf \
+		       obprintf \
+		       obstack_chk \
+		       vobstack_chk
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -70,6 +73,14 @@ 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-obstack-ieee128 test-obstack-ibm128
+CFLAGS-test-obstack-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-obstack-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-obstack-chk-ieee128 test-obstack-chk-ibm128
+CFLAGS-test-obstack-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-obstack-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
 tests-internal += test-scanf-ieee128 test-scanf-ibm128
 CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 23c2fd9793..f59dfb59fe 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -165,6 +165,11 @@ libc {
     __vswprintf_chkieee128;
     __vwprintf_chkieee128;
 
+    __obstack_printfieee128;
+    __obstack_vprintfieee128;
+    __obstack_printf_chkieee128;
+    __obstack_vprintf_chkieee128;
+
     __fscanfieee128;
     __scanfieee128;
     __sscanfieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
new file mode 100644
index 0000000000..924838eed5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
@@ -0,0 +1,42 @@
+/* Wrapper for obstack_vprintf and obstack_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>
+
+int
+__ieee128_obstack_vprintf (struct obstack *obstack, const char *format,
+			   va_list ap)
+{
+  return __obstack_vprintf_internal (obstack, format, ap,
+				     PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (__ieee128_obstack_vprintf, __obstack_vprintfieee128)
+
+int
+__ieee128_obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+  int result;
+  va_list ap;
+  va_start (ap, format);
+  result = __obstack_vprintf_internal (obstack, format, ap,
+				       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+  return result;
+}
+strong_alias (__ieee128_obstack_printf, __obstack_printfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c
new file mode 100644
index 0000000000..194589ca26
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c
@@ -0,0 +1,39 @@
+/* Wrapper for __obstack_printf_chk.  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_obstack_printf_chk (struct obstack *obstack, 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 = __obstack_vprintf_internal (obstack, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_obstack_printf_chk, __obstack_printf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c
new file mode 100644
index 0000000000..fa5182aac9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __obstack_vprintf_chk.  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__obstack_vprintf_chk  (struct obstack *obstack, int flag,
+				  const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __obstack_vprintf_internal (obstack, format, ap, mode);
+}
+strong_alias (___ieee128__obstack_vprintf_chk, __obstack_vprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
new file mode 100644
index 0000000000..ca4c9f2d22
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-obstack-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
new file mode 100644
index 0000000000..ca4c9f2d22
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-obstack-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
new file mode 100644
index 0000000000..feae8f21c6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 2
+#define OBSTACK_FUNCTION __obstack_printf_chk
+#define OBSTACK_FUNCTION_PARAMS (&ob, 1, "%.30Lf", ld)
+#define VOBSTACK_FUNCTION __obstack_vprintf_chk
+#define VOBSTACK_FUNCTION_PARAMS (&ob, 1, "%.30Lf", ap)
+#include <test-obstack-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
new file mode 100644
index 0000000000..be88675030
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
@@ -0,0 +1 @@
+#include <test-obstack-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
new file mode 100644
index 0000000000..be88675030
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
@@ -0,0 +1 @@
+#include <test-obstack-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
new file mode 100644
index 0000000000..c82ddc4355
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
@@ -0,0 +1,64 @@
+/* Test for the long double variants of obstrack*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 <malloc.h>
+#include <obstack.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <support/check.h>
+
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+
+static void
+do_test_call (void *last, ...)
+{
+  const char *expected = "-1.000000000000000000000000000000";
+  char *actual = NULL;
+  long double ld = -1;
+  struct obstack ob;
+  va_list ap;
+
+  obstack_init (&ob);
+  OBSTACK_FUNCTION OBSTACK_FUNCTION_PARAMS;
+  actual = (char *) obstack_finish (&ob);
+  TEST_VERIFY (strncmp (expected, actual, 33) == 0);
+  obstack_free (&ob, NULL);
+  actual = NULL;
+
+  obstack_init (&ob);
+  va_start (ap, last);
+  VOBSTACK_FUNCTION VOBSTACK_FUNCTION_PARAMS;
+  va_end (ap);
+  actual = (char *) obstack_finish (&ob);
+  TEST_VERIFY (strncmp (expected, actual, 33) == 0);
+  obstack_free (&ob, NULL);
+  actual = NULL;
+}
+
+static int
+do_test (void)
+{
+  long double ld = -1;
+  do_test_call (NULL, ld);
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c
new file mode 100644
index 0000000000..3849d25ef1
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 0
+#define OBSTACK_FUNCTION obstack_printf
+#define OBSTACK_FUNCTION_PARAMS (&ob, "%.30Lf", ld)
+#define VOBSTACK_FUNCTION obstack_vprintf
+#define VOBSTACK_FUNCTION_PARAMS (&ob, "%.30Lf", ap)
+#include <test-obstack-ldbl-compat-template.c>
-- 
2.21.0

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

* [PATCH 13/31] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (11 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 14/31] ldbl-128ibm-compat: Add obstack " Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 19/31] Remove hidden_def and hidden_proto from cvt functions Gabriel F. T. Gomes
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

In the format string for *scanf functions, the '%as', '%aS', and '%a[]'
modifiers behave differently depending on ISO C99 compatibility and on
_GNU_SOURCE.  When _GNU_SOURCE is not set and when in compatibility with
ISO C99, these modifiers consume a floating-point argument.  Otherwise,
they behave like ascanf, and allocate memory for the output.  This patch
adds the IEEE binary128 variant of these functions for the third long
double format on powerpc64le.

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  59 ++++++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  16 +++
 .../ieee128-isoc99_fscanf.c                   |  35 ++++++
 .../ieee128-isoc99_fwscanf.c                  |  35 ++++++
 .../ldbl-128ibm-compat/ieee128-isoc99_scanf.c |  35 ++++++
 .../ieee128-isoc99_sscanf.c                   |  39 ++++++
 .../ieee128-isoc99_swscanf.c                  |  40 ++++++
 .../ieee128-isoc99_vfscanf.c                  |  27 ++++
 .../ieee128-isoc99_vfwscanf.c                 |  27 ++++
 .../ieee128-isoc99_vscanf.c                   |  27 ++++
 .../ieee128-isoc99_vsscanf.c                  |  30 +++++
 .../ieee128-isoc99_vswscanf.c                 |  32 +++++
 .../ieee128-isoc99_vwscanf.c                  |  27 ++++
 .../ieee128-isoc99_wscanf.c                   |  35 ++++++
 .../test-isoc99-scanf-ibm128.c                |  13 ++
 .../test-isoc99-scanf-ieee128.c               |  13 ++
 .../test-isoc99-scanf-ldbl-compat-template.c  | 119 ++++++++++++++++++
 .../test-isoc99-scanf-ldbl-compat.c           |  10 ++
 .../test-isoc99-scanf-ldbl-compat.sh          |  53 ++++++++
 .../test-isoc99-wscanf-ibm128.c               |  13 ++
 .../test-isoc99-wscanf-ieee128.c              |  13 ++
 .../test-isoc99-wscanf-ldbl-compat.c          |  10 ++
 .../test-scanf-ldbl-compat-template.c         |   4 +
 23 files changed, 711 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index ed0e2ec098..1f944806e7 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -6,6 +6,15 @@ ldbl-extra-routines += fwscanf \
 		       vwscanf
 endif
 
+ifeq ($(subdir),wcsmbs)
+ldbl-extra-routines += isoc99_fwscanf \
+		       isoc99_swscanf \
+		       isoc99_wscanf \
+		       isoc99_vfwscanf \
+		       isoc99_vswscanf \
+		       isoc99_vwscanf
+endif
+
 ifeq ($(subdir),stdio-common)
 ldbl-extra-routines += printf_size \
 		       asprintf \
@@ -32,7 +41,13 @@ ldbl-extra-routines += printf_size \
 		       vfscanf \
 		       vscanf \
 		       vsscanf \
-		       vfwscanf
+		       vfwscanf \
+		       isoc99_fscanf \
+		       isoc99_scanf \
+		       isoc99_sscanf \
+		       isoc99_vfscanf \
+		       isoc99_vscanf \
+		       isoc99_vsscanf
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -67,12 +82,30 @@ CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
 $(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link)
 
+tests-internal += test-isoc99-scanf-ieee128 test-isoc99-scanf-ibm128
+CFLAGS-test-isoc99-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c99
+CFLAGS-test-isoc99-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c99
+
+$(objpfx)test-isoc99-scanf-ieee128: gnulib-tests += $(f128-loader-link)
+
+tests-internal += test-isoc99-wscanf-ieee128 test-isoc99-wscanf-ibm128
+CFLAGS-test-isoc99-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c99
+CFLAGS-test-isoc99-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c99
+
+$(objpfx)test-isoc99-wscanf-ieee128: gnulib-tests += $(f128-loader-link)
+
 ifeq ($(run-built-tests),yes)
 tests-special += $(objpfx)test-scanf-ieee128.out
 tests-special += $(objpfx)test-scanf-ibm128.out
 
 tests-special += $(objpfx)test-wscanf-ieee128.out
 tests-special += $(objpfx)test-wscanf-ibm128.out
+
+tests-special += $(objpfx)test-isoc99-scanf-ieee128.out
+tests-special += $(objpfx)test-isoc99-scanf-ibm128.out
+
+tests-special += $(objpfx)test-isoc99-wscanf-ieee128.out
+tests-special += $(objpfx)test-isoc99-wscanf-ibm128.out
 endif
 
 $(objpfx)test-scanf-ieee128.out: \
@@ -99,6 +132,30 @@ $(objpfx)test-wscanf-ibm128.out: \
 	$(SHELL) $^ '$(test-program-prefix)' $@; \
 	$(evaluate-test)
 
+$(objpfx)test-isoc99-scanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \
+  $(objpfx)test-isoc99-scanf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-isoc99-scanf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \
+  $(objpfx)test-isoc99-scanf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-isoc99-wscanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \
+  $(objpfx)test-isoc99-wscanf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-isoc99-wscanf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \
+  $(objpfx)test-isoc99-wscanf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
 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 dead38cdcb..23c2fd9793 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -181,6 +181,22 @@ libc {
     __vswscanfieee128;
     __vwscanfieee128;
 
+    __isoc99_fscanfieee128;
+    __isoc99_scanfieee128;
+    __isoc99_sscanfieee128;
+
+    __isoc99_vfscanfieee128;
+    __isoc99_vscanfieee128;
+    __isoc99_vsscanfieee128;
+
+    __isoc99_fwscanfieee128;
+    __isoc99_swscanfieee128;
+    __isoc99_wscanfieee128;
+
+    __isoc99_vfwscanfieee128;
+    __isoc99_vswscanfieee128;
+    __isoc99_vwscanfieee128;
+
     __argp_errorieee128;
     __argp_failureieee128;
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c
new file mode 100644
index 0000000000..3930170878
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_fscanf.  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_isoc99_fscanf (FILE *fp, const char *format, ...)
+{
+  va_list arg;
+  int done;
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+
+  va_start (arg, format);
+  done = __vfscanf_internal (fp, format, arg, mode_flags);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_isoc99_fscanf, __isoc99_fscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c
new file mode 100644
index 0000000000..d56ecfbaf2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_fwscanf.  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 <libioP.h>
+
+extern int
+___ieee128_isoc99_fwscanf (FILE *fp, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (fp, format, ap, mode_flags);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_isoc99_fwscanf, __isoc99_fwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c
new file mode 100644
index 0000000000..5b643fb108
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_scanf.  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_isoc99_scanf (const char *format, ...)
+{
+  va_list arg;
+  int done;
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+
+  va_start (arg, format);
+  done = __vfscanf_internal (stdin, format, arg, mode_flags);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_isoc99_scanf, __isoc99_scanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c
new file mode 100644
index 0000000000..480357ccd5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c
@@ -0,0 +1,39 @@
+/* Wrapper for __isoc99_sscanf.  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 <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_isoc99_sscanf (const char *string, const char *format, ...)
+{
+  va_list arg;
+  int done;
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+
+  _IO_strfile sf;
+  FILE *fp = _IO_strfile_read (&sf, string);
+
+  va_start (arg, format);
+  done = __vfscanf_internal (fp, format, arg, mode_flags);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_isoc99_sscanf, __isoc99_sscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c
new file mode 100644
index 0000000000..e18779a986
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c
@@ -0,0 +1,40 @@
+/* Wrapper for __isoc99_swscanf.  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 <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_isoc99_swscanf (const wchar_t *string, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+  FILE *fp = _IO_strfile_readw (&sf, &wd, string);
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (fp, format, ap, mode_flags);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_isoc99_swscanf, __isoc99_swscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c
new file mode 100644
index 0000000000..2d131f7fee
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vfscanf.  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_isoc99_vfscanf (FILE *fp, const char *format, va_list ap)
+{
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+  return __vfscanf_internal (fp, format, ap, mode_flags);
+}
+strong_alias (___ieee128_isoc99_vfscanf, __isoc99_vfscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c
new file mode 100644
index 0000000000..a281ecc451
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vfwscanf.  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 <libioP.h>
+
+extern int
+___ieee128_isoc99_vfwscanf (FILE *fp, const wchar_t *format, va_list ap)
+{
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+  return __vfwscanf_internal (fp, format, ap, mode_flags);
+}
+strong_alias (___ieee128_isoc99_vfwscanf, __isoc99_vfwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c
new file mode 100644
index 0000000000..6ec60d5dc0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vscanf.  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_isoc99_vscanf (const char *format, va_list ap)
+{
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+  return __vfscanf_internal (stdin, format, ap, mode_flags);
+}
+strong_alias (___ieee128_isoc99_vscanf, __isoc99_vscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c
new file mode 100644
index 0000000000..599e86820d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c
@@ -0,0 +1,30 @@
+/* Wrapper for __isoc99_vsscanf.  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 <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_isoc99_vsscanf (const char *string, const char *format, va_list ap)
+{
+  _IO_strfile sf;
+  FILE *fp = _IO_strfile_read (&sf, string);
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+  return __vfscanf_internal (fp, format, ap, mode_flags);
+}
+strong_alias (___ieee128_isoc99_vsscanf, __isoc99_vsscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c
new file mode 100644
index 0000000000..3a28616c26
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c
@@ -0,0 +1,32 @@
+/* Wrapper for __isoc99_vswscanf.  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 <libioP.h>
+#include <wchar.h>
+#include <strfile.h>
+
+extern int
+___ieee128_isoc99_vswscanf (wchar_t *string, const wchar_t *format, va_list ap)
+{
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+  FILE *fp = _IO_strfile_readw (&sf, &wd, string);
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+  return __vfwscanf_internal (fp, format, ap, mode_flags);
+}
+strong_alias (___ieee128_isoc99_vswscanf, __isoc99_vswscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c
new file mode 100644
index 0000000000..b9bd4a78f0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vwscanf.  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 <libioP.h>
+
+extern int
+___ieee128_isoc99_vwscanf (const wchar_t *format, va_list ap)
+{
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+  return __vfwscanf_internal (stdin, format, ap, mode_flags);
+}
+strong_alias (___ieee128_isoc99_vwscanf, __isoc99_vwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c
new file mode 100644
index 0000000000..e78b4a3143
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_wscanf.  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 <libioP.h>
+
+extern int
+___ieee128_isoc99_wscanf (const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+  int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128;
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (stdin, format, ap, mode_flags);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_isoc99_wscanf, __isoc99_wscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
new file mode 100644
index 0000000000..70688ac2bb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
@@ -0,0 +1,13 @@
+#undef _GNU_SOURCE
+/* The following macro definitions are a hack.  They word around disabling
+   the GNU extension while still using a few internal headers.  */
+#define u_char unsigned char
+#define u_short unsigned short
+#define u_int unsigned int
+#define u_long unsigned long
+#include <libio/stdio.h>
+#include <stdlib/stdlib.h>
+#include <string/string.h>
+#include <wcsmbs/wchar.h>
+
+#include <test-isoc99-scanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
new file mode 100644
index 0000000000..70688ac2bb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
@@ -0,0 +1,13 @@
+#undef _GNU_SOURCE
+/* The following macro definitions are a hack.  They word around disabling
+   the GNU extension while still using a few internal headers.  */
+#define u_char unsigned char
+#define u_short unsigned short
+#define u_int unsigned int
+#define u_long unsigned long
+#include <libio/stdio.h>
+#include <stdlib/stdlib.h>
+#include <string/string.h>
+#include <wcsmbs/wchar.h>
+
+#include <test-isoc99-scanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
new file mode 100644
index 0000000000..ffc7ca2aaa
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
@@ -0,0 +1,119 @@
+/* Test for the long double variants of __isoc99_*scanf 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 <string.h>
+#include <wchar.h>
+
+#include <support/check.h>
+
+#define CLEAR_VARGS							\
+  va_start (args, format);						\
+  ldptr = va_arg (args, long double *);					\
+  fptr = va_arg (args, float *);					\
+  *ldptr = 0;								\
+  *fptr = 0;								\
+  va_end (args);
+
+#define CHECK_VARGS							\
+  va_start (args, format);						\
+  ldptr = va_arg (args, long double *);					\
+  fptr = va_arg (args, float *);					\
+  va_end (args);							\
+  if (*ldptr == -1 && *fptr == -2)					\
+    printf ("OK");							\
+  else									\
+    printf ("ERROR (%Lf %f)", *ldptr, *fptr);				\
+  printf ("\n");
+
+#define CLEAR_VALUE							\
+  ld = 0;								\
+  f = 0;
+
+#define CHECK_VALUE							\
+  if (ld == -1 && f == -2)						\
+    printf ("OK");							\
+  else									\
+    printf ("ERROR (%Lf %f)", ld, f);					\
+  printf ("\n");
+
+static void
+do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
+{
+  float *fptr;
+  float f;
+  long double *ldptr;
+  long double ld;
+  va_list args;
+
+  CLEAR_VALUE
+  printf ("fscanf: ");
+  FSCANF (stream, format, &ld, &f);
+  CHECK_VALUE
+
+  CLEAR_VALUE
+  printf ("scanf: ");
+  SCANF (format, &ld, &f);
+  CHECK_VALUE
+
+  CLEAR_VALUE
+  printf ("sscanf: ");
+  SSCANF (string, format, &ld, &f);
+  CHECK_VALUE
+
+  CLEAR_VARGS
+  printf ("vfscanf: ");
+  va_start (args, format);
+  VFSCANF (stream, format, args);
+  va_end (args);
+  CHECK_VARGS
+
+  CLEAR_VARGS
+  printf ("vscanf: ");
+  va_start (args, format);
+  VSCANF (format, args);
+  va_end (args);
+  CHECK_VARGS
+
+  CLEAR_VARGS
+  printf ("vsscanf: ");
+  va_start (args, format);
+  VSSCANF (string, format, args);
+  va_end (args);
+  CHECK_VARGS
+}
+
+static int
+do_test (void)
+{
+  CHAR string[256];
+  float f;
+  long double ld;
+
+  /* Scan floating-point value with '%as'.  */
+  STRCPY (string,
+	  L ("-0x1.0p+0 -0x2.0p+0\n")
+	  L ("-0x1.0p+0 -0x2.0p+0\n") );
+  do_test_call (stdin, string, L("%La %as"), &ld, &f);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c
new file mode 100644
index 0000000000..739b6bb479
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c
@@ -0,0 +1,10 @@
+#define CHAR char
+#define L(x) x
+#define FSCANF fscanf
+#define SSCANF sscanf
+#define SCANF scanf
+#define VFSCANF vfscanf
+#define VSSCANF vsscanf
+#define VSCANF vscanf
+#define STRCPY strcpy
+#include <test-isoc99-scanf-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh
new file mode 100644
index 0000000000..fc08beddc5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# Testing of __isoc99_*scanf.  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
+
+cat <<'EOF' |
+-0x1.0p+0 -0x2.0p+0
+-0x1.0p+0 -0x2.0p+0
+-0x1.0p+0 -0x2.0p+0
+-0x1.0p+0 -0x2.0p+0
+EOF
+${test_program_prefix} \
+  ${test_program} \
+  - \
+  > ${test_program_output} || status=1
+
+cat <<'EOF' |
+fscanf: OK
+scanf: OK
+sscanf: OK
+vfscanf: OK
+vscanf: OK
+vsscanf: OK
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+  status=1
+  echo "*** output comparison failed"
+}
+
+exit $status
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
new file mode 100644
index 0000000000..6be29624d9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
@@ -0,0 +1,13 @@
+#undef _GNU_SOURCE
+/* The following macro definitions are a hack.  They word around disabling
+   the GNU extension while still using a few internal headers.  */
+#define u_char unsigned char
+#define u_short unsigned short
+#define u_int unsigned int
+#define u_long unsigned long
+#include <libio/stdio.h>
+#include <stdlib/stdlib.h>
+#include <string/string.h>
+#include <wcsmbs/wchar.h>
+
+#include <test-isoc99-wscanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
new file mode 100644
index 0000000000..6be29624d9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
@@ -0,0 +1,13 @@
+#undef _GNU_SOURCE
+/* The following macro definitions are a hack.  They word around disabling
+   the GNU extension while still using a few internal headers.  */
+#define u_char unsigned char
+#define u_short unsigned short
+#define u_int unsigned int
+#define u_long unsigned long
+#include <libio/stdio.h>
+#include <stdlib/stdlib.h>
+#include <string/string.h>
+#include <wcsmbs/wchar.h>
+
+#include <test-isoc99-wscanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c
new file mode 100644
index 0000000000..3ad29645f6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c
@@ -0,0 +1,10 @@
+#define CHAR wchar_t
+#define L(x) L##x
+#define FSCANF fwscanf
+#define SSCANF swscanf
+#define SCANF wscanf
+#define VFSCANF vfwscanf
+#define VSSCANF vswscanf
+#define VSCANF vwscanf
+#define STRCPY wcscpy
+#include <test-isoc99-scanf-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
index 4590e9da96..aea4f0d358 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
@@ -53,8 +53,10 @@ static void
 do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
 {
   long double value;
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
   long double *ld;
   va_list args;
+#endif
 
   CLEAR_VALUE
   printf ("fscanf: ");
@@ -71,6 +73,7 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
   SSCANF (string, format, &value);
   CHECK_VALUE
 
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
   CLEAR
   printf ("vfscanf: ");
   va_start (args, format);
@@ -91,6 +94,7 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
   VSSCANF (string, format, args);
   va_end (args);
   CHECK
+#endif
 }
 
 static int
-- 
2.21.0

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

* [PATCH 16/31] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (18 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 21/31] Refactor *cvt functions implementation (2/5) Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 23/31] Refactor *cvt functions implementation (4/5) Gabriel F. T. Gomes
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>

Similarly to what has been done for printf-like functions, more
specifically to the internal implementation in __vfprintf_internal, this
patch extends __vstrfmon_l_internal to deal with long double values with
binary128 format (as a third format option and reusing the float128
implementation).

Tested for powerpc64le and x86_64.
---
 include/monetary.h                            |  1 +
 stdlib/strfmon_l.c                            | 31 +++++++++++++---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 12 +++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  3 ++
 .../ldbl-128ibm-compat/ieee128-strfmon.c      | 35 +++++++++++++++++++
 .../ldbl-128ibm-compat/ieee128-strfmon_l.c    | 35 +++++++++++++++++++
 6 files changed, 113 insertions(+), 4 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c

diff --git a/include/monetary.h b/include/monetary.h
index f59bdf9150..240925e87d 100644
--- a/include/monetary.h
+++ b/include/monetary.h
@@ -15,5 +15,6 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
    same format as double, in which case the flag should be set to one,
    or as another format, otherwise.  */
 #define STRFMON_LDBL_IS_DBL 0x0001
+#define STRFMON_LDBL_USES_FLOAT128  0x0002
 
 #endif
diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
index 134dad6963..b26cec24e2 100644
--- a/stdlib/strfmon_l.c
+++ b/stdlib/strfmon_l.c
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "../locale/localeinfo.h"
+#include <bits/floatn.h>
 
 
 #define out_char(Ch)							      \
@@ -96,6 +97,9 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       {
 	double dbl;
 	long double ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+      _Float128 f128;
+#endif
       }
       fpnum;
       int int_format;
@@ -106,6 +110,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       int group;
       char pad;
       int is_long_double;
+      int is_binary128;
       int p_sign_posn;
       int n_sign_posn;
       int sign_posn;
@@ -150,6 +155,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       group = 1;			/* Print digits grouped.  */
       pad = ' ';			/* Fill character is <SP>.  */
       is_long_double = 0;		/* Double argument by default.  */
+      is_binary128 = 0;		/* Long double argument by default.  */
       p_sign_posn = -2;			/* This indicates whether the */
       n_sign_posn = -2;			/* '(' flag is given.  */
       width = -1;			/* No width specified so far.  */
@@ -270,6 +276,10 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
 	  ++fmt;
 	  if (__glibc_likely ((flags & STRFMON_LDBL_IS_DBL) == 0))
 	    is_long_double = 1;
+#if __HAVE_DISTINCT_FLOAT128
+	  if (__glibc_likely ((flags & STRFMON_LDBL_USES_FLOAT128) != 0))
+	    is_binary128 = is_long_double;
+#endif
 	}
 
       /* Handle format specifier.  */
@@ -324,10 +334,22 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       /* Now it's time to get the value.  */
       if (is_long_double == 1)
 	{
-	  fpnum.ldbl = va_arg (ap, long double);
-	  is_negative = fpnum.ldbl < 0;
-	  if (is_negative)
-	    fpnum.ldbl = -fpnum.ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+	  if (is_binary128 == 1)
+	    {
+	      fpnum.f128 = va_arg (ap, _Float128);
+	      is_negative = fpnum.f128 < 0;
+	      if (is_negative)
+	        fpnum.f128 = -fpnum.f128;
+	    }
+	  else
+#endif
+	  {
+	    fpnum.ldbl = va_arg (ap, long double);
+	    is_negative = fpnum.ldbl < 0;
+	    if (is_negative)
+	      fpnum.ldbl = -fpnum.ldbl;
+	  }
 	}
       else
 	{
@@ -517,6 +539,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       info.width = left_prec + (right_prec ? (right_prec + 1) : 0);
       info.spec = 'f';
       info.is_long_double = is_long_double;
+      info.is_binary128 = is_binary128;
       info.group = group;
       info.pad = pad;
       info.extra = 1;		/* This means use values from LC_MONETARY.  */
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index c53d4ed766..550135847a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -271,6 +271,18 @@ CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
+ifeq ($(subdir),stdlib)
+ldbl-extra-routines += strfmon strfmon_l
+
+# 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 files, must have -mfloat128 passed to the compiler.
+# Also, guarantee that they are compiled in IBM long double mode.
+CFLAGS-strfmon.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-strfmon_l.c += -mfloat128 -mabi=ibmlongdouble
+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 b7aa9f7993..da8e0ce7ee 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -221,5 +221,8 @@ libc {
 
     __errorieee128;
     __error_at_lineieee128;
+
+    __strfmonieee128;
+    __strfmon_lieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
new file mode 100644
index 0000000000..743f7cdcf6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
@@ -0,0 +1,35 @@
+/* Wrapper for strfmon.  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 <monetary.h>
+#include <stdarg.h>
+#include <locale/localeinfo.h>
+
+ssize_t
+___ieee128_strfmon (char *s, size_t maxsize, const char *format, ...)
+{
+  va_list ap;
+  ssize_t res;
+
+  va_start (ap, format);
+  res = __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE,
+                                       format, ap, STRFMON_LDBL_USES_FLOAT128);
+  va_end (ap);
+  return res;
+}
+weak_alias (___ieee128_strfmon, __strfmonieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c
new file mode 100644
index 0000000000..2ad970af98
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c
@@ -0,0 +1,35 @@
+/* Wrapper for strfmon_l.  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 <monetary.h>
+#include <stdarg.h>
+#include <locale/localeinfo.h>
+
+ssize_t
+___ieee128_strfmon_l (char *s, size_t maxsize, locale_t loc, const char *format, ...)
+{
+  va_list ap;
+  ssize_t res;
+
+  va_start (ap, format);
+  res = __vstrfmon_l_internal (s, maxsize, loc,
+                                       format, ap, STRFMON_LDBL_USES_FLOAT128);
+  va_end (ap);
+  return res;
+}
+weak_alias (___ieee128_strfmon_l, __strfmon_lieee128)
-- 
2.21.0

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

* [PATCH 17/31] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (20 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 23/31] Refactor *cvt functions implementation (4/5) Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 20/31] Refactor *cvt functions implementation (1/5) Gabriel F. T. Gomes
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

This patch adds elementary tests to check that strfmon and strfmon_l
correctly evaluate long double values with IBM Extended Precision and
IEEE binary128 format.

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  6 ++
 .../ldbl-128ibm-compat/test-strfmon-ibm128.c  |  1 +
 .../ldbl-128ibm-compat/test-strfmon-ieee128.c |  1 +
 .../test-strfmon-ldbl-compat.c                | 59 +++++++++++++++++++
 4 files changed, 67 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 550135847a..955da1d1ee 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -281,6 +281,12 @@ ldbl-extra-routines += strfmon strfmon_l
 # Also, guarantee that they are compiled in IBM long double mode.
 CFLAGS-strfmon.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-strfmon_l.c += -mfloat128 -mabi=ibmlongdouble
+
+tests-internal += test-strfmon-ibm128 test-strfmon-ieee128
+CFLAGS-test-strfmon-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-test-strfmon-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+$(objpfx)tst-strfmon-ibm128.out: $(gen-locales)
+$(objpfx)tst-strfmon-ieee128.out: $(gen-locales)
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
new file mode 100644
index 0000000000..5d1def86af
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
@@ -0,0 +1 @@
+#include <test-strfmon-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
new file mode 100644
index 0000000000..5d1def86af
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
@@ -0,0 +1 @@
+#include <test-strfmon-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
new file mode 100644
index 0000000000..1338bd8493
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
@@ -0,0 +1,59 @@
+/* Test for the long double variants of strfmon* 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 <locale/locale.h>
+#include <monetary.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  size_t written;
+  char buffer[64];
+  char *bufptr = buffer;
+  locale_t loc;
+
+  /* Using the C locale is enough for the purpose of this test case,
+     i.e.: to test that strfmon correctly reads long double values with
+     binary128 format.  Grouping and currency are irrelevant, here.  */
+  setlocale (LC_MONETARY, "C");
+  loc = newlocale (LC_MONETARY_MASK, "C", (locale_t) 0);
+
+  /* Write to the buffer.  */
+  written = strfmon (bufptr, 32, "%.10i, %.10Li\n",
+                     (double) -2, (long double) -1);
+  if (written < 0)
+    support_record_failure ();
+  else
+    bufptr += written;
+  written = strfmon_l (bufptr, 32, loc, "%.10i, %.10Li\n",
+                       (double) -2, (long double) -1);
+  if (written < 0)
+    support_record_failure ();
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "-2.0000000000, -1.0000000000\n"
+    "-2.0000000000, -1.0000000000\n";
+  TEST_COMPARE_STRING (expected, buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.0

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

* [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (14 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 09/31] ldbl-128ibm-compat: Add argp_error and argp_failure Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 20:59   ` Joseph Myers
  2019-10-15 19:07 ` [PATCH 18/31] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Gabriel F. T. Gomes
                   ` (14 subsequent siblings)
  30 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

I'm using 'syslog (LOG_DEBUG, etc.);' and support_capture_subprocess in
the test case, which I believe will not print to the console, but I'm
not sure if changing some system setting to high verbosity will disturb
people's lives.  Please advise.  :)

-- 8< --
Similarly to __vfprintf_internal and __vfscanf_internal, the internal
implementation of syslog functions (__vsyslog_internal) takes a
'mode_flags' parameter used to select the format of long double
parameters.  This patch adds variants of the syslog functions that set
'mode_flags' to PRINTF_LDBL_USES_FLOAT128, thus enabling the correct
printing of long double values on powerpc64le, when long double has IEEE
binary128 format (-mabi=ieeelongdouble).

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 11 +++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  5 ++
 .../ldbl-128ibm-compat/ieee128-syslog.c       | 65 ++++++++++++++++++
 .../test-syslog-chk-ibm128.c                  |  1 +
 .../test-syslog-chk-ieee128.c                 |  1 +
 .../test-syslog-chk-ldbl-compat.c             |  6 ++
 .../ldbl-128ibm-compat/test-syslog-ibm128.c   |  1 +
 .../ldbl-128ibm-compat/test-syslog-ieee128.c  |  1 +
 .../test-syslog-ldbl-compat-template.c        | 66 +++++++++++++++++++
 .../test-syslog-ldbl-compat.c                 |  6 ++
 10 files changed, 162 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 9e8237d075..c53d4ed766 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -244,7 +244,8 @@ endif
 
 ifeq ($(subdir),misc)
 ldbl-extra-routines += err \
-		       error
+		       error \
+		       syslog
 
 tests-internal += tst-ibm128-warn tst-ieee128-warn
 tests-internal += tst-ibm128-error tst-ieee128-error
@@ -260,6 +261,14 @@ CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi
 
 CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+
+tests-internal += test-syslog-ieee128 test-syslog-ibm128
+CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-syslog-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-syslog-chk-ieee128 test-syslog-chk-ibm128
+CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 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 f59dfb59fe..b7aa9f7993 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -170,6 +170,11 @@ libc {
     __obstack_printf_chkieee128;
     __obstack_vprintf_chkieee128;
 
+    __syslogieee128;
+    __vsyslogieee128;
+    __syslog_chkieee128;
+    __vsyslog_chkieee128;
+
     __fscanfieee128;
     __scanfieee128;
     __sscanfieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c
new file mode 100644
index 0000000000..fa16cc9aaf
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c
@@ -0,0 +1,65 @@
+/* Wrapper for syslog.  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 <libioP.h>
+#include <syslog.h>
+
+void
+___ieee128_syslog (int pri, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+strong_alias (___ieee128_syslog, __syslogieee128)
+
+void
+___ieee128_vsyslog (int pri, const char *fmt, va_list ap)
+{
+  __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsyslog, __vsyslogieee128)
+
+void
+___ieee128_syslog_chk (int pri, int flag, const char *fmt, ...)
+{
+  va_list ap;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, fmt);
+  __vsyslog_internal (pri, fmt, ap, mode);
+  va_end (ap);
+}
+strong_alias (___ieee128_syslog_chk, __syslog_chkieee128)
+
+void
+___ieee128_vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  __vsyslog_internal (pri, fmt, ap, mode);
+}
+strong_alias (___ieee128_vsyslog_chk, __vsyslog_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
new file mode 100644
index 0000000000..bf42582687
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-syslog-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
new file mode 100644
index 0000000000..bf42582687
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-syslog-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
new file mode 100644
index 0000000000..513b2d2064
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 2
+#define SYSLOG_FUNCTION __syslog_chk
+#define SYSLOG_FUNCTION_PARAMS (LOG_DEBUG, 1, "%Lf\n", ld)
+#define VSYSLOG_FUNCTION __vsyslog_chk
+#define VSYSLOG_FUNCTION_PARAMS (LOG_DEBUG, 1, "%Lf\n", ap)
+#include <test-syslog-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
new file mode 100644
index 0000000000..8e64440e8c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
@@ -0,0 +1 @@
+#include <test-syslog-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
new file mode 100644
index 0000000000..8e64440e8c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
@@ -0,0 +1 @@
+#include <test-syslog-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
new file mode 100644
index 0000000000..05a9640236
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
@@ -0,0 +1,66 @@
+/* Test for the long double variants of *syslog* 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 <stddef.h>
+#include <syslog.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_one_call (void *last, ...)
+{
+  long double ld = -1;
+  va_list ap;
+
+  /* Make syslog functions write to stderr with LOG_PERROR.  */
+  openlog ("test-syslog", LOG_PERROR | LOG_ODELAY, LOG_USER);
+
+  /* Call syslog functions that take a format string.  */
+  SYSLOG_FUNCTION SYSLOG_FUNCTION_PARAMS;
+  va_start (ap, last);
+  VSYSLOG_FUNCTION VSYSLOG_FUNCTION_PARAMS;
+  va_end (ap);
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+  do_test_one_call (NULL, ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  do_test_call ();
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "test-syslog: -1.000000\n"
+    "test-syslog: -1.000000\n";
+  TEST_COMPARE_STRING (expected, result.err.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c
new file mode 100644
index 0000000000..ff0c0a5813
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 0
+#define SYSLOG_FUNCTION syslog
+#define SYSLOG_FUNCTION_PARAMS (LOG_DEBUG, "%Lf\n", ld)
+#define VSYSLOG_FUNCTION vsyslog
+#define VSYSLOG_FUNCTION_PARAMS (LOG_DEBUG, "%Lf\n", ap)
+#include <test-syslog-ldbl-compat-template.c>
-- 
2.21.0

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

* [PATCH 23/31] Refactor *cvt functions implementation (4/5)
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (19 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 16/31] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 17/31] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Gabriel F. T. Gomes
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

This patch is to be squashed with the other n/5 refactoring patches.

This patch splits the definition of the symbol names into separate files
for double and long double, which will make it easier to define new
symbol names for IEEE long double functions on powerpc64le.
---
 misc/efgcvt-template.c   | 23 -----------------------
 misc/efgcvt.c            | 31 +++++++++++++++++++++++++++++++
 misc/efgcvt_r-template.c | 24 ------------------------
 misc/efgcvt_r.c          | 30 ++++++++++++++++++++++++++++++
 misc/qefgcvt.c           | 11 +++++++++++
 misc/qefgcvt_r.c         | 10 ++++++++++
 6 files changed, 82 insertions(+), 47 deletions(-)
 create mode 100644 misc/efgcvt.c
 create mode 100644 misc/efgcvt_r.c

diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index f8650a934f..aeb4e1ea01 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -76,26 +76,3 @@ __APPEND (FUNC_PREFIX, gcvt) (FLOAT_TYPE value, int ndigit, char *buf)
   sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
   return buf;
 }
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# ifdef LONG_DOUBLE_CVT
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
-#  define cvt_symbol_1(lib, local, symbol, version) \
-    versioned_symbol (lib, local, symbol, version)
-# else
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (q, symbol), GLIBC_2_0); \
-  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(lib, local, symbol, version) \
-  compat_symbol (lib, local, symbol, version)
-# endif
-#else
-# define cvt_symbol(symbol) \
-  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#endif
-cvt_symbol(fcvt);
-cvt_symbol(ecvt);
-cvt_symbol(gcvt);
diff --git a/misc/efgcvt.c b/misc/efgcvt.c
new file mode 100644
index 0000000000..8e6bdbf358
--- /dev/null
+++ b/misc/efgcvt.c
@@ -0,0 +1,31 @@
+/* Double versions of *cvt_r 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 "efgcvt.c"
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol); \
+  compat_symbol (libc, local, q##symbol, GLIBC_2_0)
+#else
+# define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
+#endif
+cvt_symbol (__fcvt, fcvt);
+cvt_symbol (__ecvt, ecvt);
+cvt_symbol (__gcvt, gcvt);
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
index 2194093d9f..f215dbd345 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -200,27 +200,3 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
   *decpt += exponent;
   return 0;
 }
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# ifdef LONG_DOUBLE_CVT
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
-#  define cvt_symbol_1(lib, local, symbol, version) \
-    versioned_symbol (lib, local, symbol, version)
-# else
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (q, symbol), GLIBC_2_0); \
-  weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(lib, local, symbol, version) \
-  compat_symbol (lib, local, symbol, version)
-# endif
-#else
-# define cvt_symbol(symbol) \
-  cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(local, symbol) \
-  weak_alias (local, symbol)
-#endif
-cvt_symbol(fcvt_r);
-cvt_symbol(ecvt_r);
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
new file mode 100644
index 0000000000..f9066813e7
--- /dev/null
+++ b/misc/efgcvt_r.c
@@ -0,0 +1,30 @@
+/* Double versions of reentrant *cvt_r 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 "efgcvt_r.c"
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# define cvt_symbol(local, symbol) \
+  weak_alias (local, symbol); \
+  compat_symbol (libc, local, q##symbol, GLIBC_2_0)
+#else
+# define cvt_symbol(local, symbol) \
+  weak_alias (local, symbol)
+#endif
+cvt_symbol (__fcvt_r, fcvt_r);
+cvt_symbol (__ecvt_r, ecvt_r);
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index 6987fb0db1..cddad1c54b 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -17,3 +17,14 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include "efgcvt.c"
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# define cvt_symbol(local, symbol) \
+  versioned_symbol (lib, local, symbol, GLIBC_2_4)
+#else
+# define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
+#endif
+cvt_symbol (__qfcvt, qfcvt);
+cvt_symbol (__qecvt, qecvt);
+cvt_symbol (__qgcvt, qgcvt);
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index e1f074b49c..7293f1e125 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -18,3 +18,13 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include "efgcvt_r.c"
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# define cvt_symbol(local, symbol) \
+  versioned_symbol (libc, local, symbol, GLIBC_2_4)
+#else
+# define cvt_symbol(local, symbol) \
+  weak_alias (local, symbol)
+#endif
+cvt_symbol (__qfcvt_r, qfcvt_r);
+cvt_symbol (__qecvt_r, qecvt_r);
-- 
2.21.0

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

* [PATCH 19/31] Remove hidden_def and hidden_proto from cvt functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (12 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 13/31] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-21  1:55   ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 09/31] ldbl-128ibm-compat: Add argp_error and argp_failure Gabriel F. T. Gomes
                   ` (16 subsequent siblings)
  30 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

Some *cvt functions are not called from within libc, yet they use
hidden_def and hidden_proto.  This patch cleans this up and adds
attribute_hidden to the declarations, for architectures that need it.

Tested for powerpc64le and x86_64.
---
 include/stdlib.h | 16 ++++++++--------
 misc/efgcvt_r.c  |  3 ---
 2 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h
index 114e12d255..089607dbf9 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -260,12 +260,12 @@ extern char *__fcvt (double __value, int __ndigit, int *__restrict __decpt,
 extern char *__gcvt (double __value, int __ndigit, char *__buf);
 extern int __ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
 		     int *__restrict __sign, char *__restrict __buf,
-		     size_t __len);
-libc_hidden_proto (__ecvt_r)
+		     size_t __len)
+  attribute_hidden;
 extern int __fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
 		     int *__restrict __sign, char *__restrict __buf,
-		     size_t __len);
-libc_hidden_proto (__fcvt_r)
+		     size_t __len)
+  attribute_hidden;
 extern char *__qecvt (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign);
 extern char *__qfcvt (long double __value, int __ndigit,
@@ -273,12 +273,12 @@ extern char *__qfcvt (long double __value, int __ndigit,
 extern char *__qgcvt (long double __value, int __ndigit, char *__buf);
 extern int __qecvt_r (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign,
-		      char *__restrict __buf, size_t __len);
-libc_hidden_proto (__qecvt_r)
+		      char *__restrict __buf, size_t __len)
+  attribute_hidden;
 extern int __qfcvt_r (long double __value, int __ndigit,
 		      int *__restrict __decpt, int *__restrict __sign,
-		      char *__restrict __buf, size_t __len);
-libc_hidden_proto (__qfcvt_r)
+		      char *__restrict __buf, size_t __len)
+  attribute_hidden;
 
 # if IS_IN (libc)
 #  undef MB_CUR_MAX
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 981249850c..30d25ff114 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -240,7 +240,6 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
   cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
 	      APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
 #  define cvt_symbol_1(lib, local, symbol, version) \
-    libc_hidden_def (local) \
     versioned_symbol (lib, local, symbol, version)
 # else
 #  define cvt_symbol(symbol) \
@@ -248,14 +247,12 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
 	      APPEND (q, symbol), GLIBC_2_0); \
   weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
 #  define cvt_symbol_1(lib, local, symbol, version) \
-  libc_hidden_def (local) \
   compat_symbol (lib, local, symbol, version)
 # endif
 #else
 # define cvt_symbol(symbol) \
   cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
 #  define cvt_symbol_1(local, symbol) \
-  libc_hidden_def (local) \
   weak_alias (local, symbol)
 #endif
 cvt_symbol(fcvt_r);
-- 
2.21.0

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

* [PATCH 21/31] Refactor *cvt functions implementation (2/5)
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (17 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 22/31] Refactor *cvt functions implementation (3/5) Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 16/31] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Gabriel F. T. Gomes
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

This patch is to be squashed with the other n/5 refactoring patches.

This patch only moves and merges the contents of misc/efgcvt-template.c
and misc/efgcvt_r-template.c into misc/efgcvt-dbl-macros.h.
---
 misc/efgcvt-dbl-macros.h | 52 ++++++++++++++++++++++++++++++++++++++++
 misc/efgcvt-template.c   | 25 -------------------
 misc/efgcvt_r-template.c | 33 -------------------------
 3 files changed, 52 insertions(+), 58 deletions(-)
 create mode 100644 misc/efgcvt-dbl-macros.h

diff --git a/misc/efgcvt-dbl-macros.h b/misc/efgcvt-dbl-macros.h
new file mode 100644
index 0000000000..08640e9639
--- /dev/null
+++ b/misc/efgcvt-dbl-macros.h
@@ -0,0 +1,52 @@
+/* Macros for the implementation of *cvt functions, double 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 <float.h>
+
+#define FLOAT_TYPE double
+#define FUNC_PREFIX
+#define FLOAT_FMT_FLAG
+#define FLOAT_NAME_EXT
+#define FLOAT_MIN_10_EXP DBL_MIN_10_EXP
+/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we
+   don't have log10 available in the preprocessor.  */
+#define MAXDIG (NDIGIT_MAX + 3)
+#define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG)
+#if DBL_MANT_DIG == 53
+# define NDIGIT_MAX 17
+#elif DBL_MANT_DIG == 24
+# define NDIGIT_MAX 9
+#elif DBL_MANT_DIG == 56
+# define NDIGIT_MAX 18
+#else
+/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
+   compile time constant here, so we cannot use it.  */
+# error "NDIGIT_MAX must be precomputed"
+# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
+#endif
+#if DBL_MIN_10_EXP == -37
+# define FLOAT_MIN_10_NORM	1.0e-37
+#elif DBL_MIN_10_EXP == -307
+# define FLOAT_MIN_10_NORM	1.0e-307
+#elif DBL_MIN_10_EXP == -4931
+# define FLOAT_MIN_10_NORM	1.0e-4931
+#else
+/* libc can't depend on libm.  */
+# error "FLOAT_MIN_10_NORM must be precomputed"
+# define FLOAT_MIN_10_NORM	exp10 (DBL_MIN_10_EXP)
+#endif
diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index 492e4e8086..f8650a934f 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -20,34 +20,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/param.h>
-#include <float.h>
 #include <libc-lock.h>
 #include <math_ldbl_opt.h>
 
-#ifndef FLOAT_TYPE
-# define FLOAT_TYPE double
-# define FUNC_PREFIX
-# define FLOAT_FMT_FLAG
-/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we
-   don't have log10 available in the preprocessor.  */
-# define MAXDIG (NDIGIT_MAX + 3)
-# define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG)
-# if DBL_MANT_DIG == 53
-#  define NDIGIT_MAX 17
-# elif DBL_MANT_DIG == 24
-#  define NDIGIT_MAX 9
-# elif DBL_MANT_DIG == 56
-#  define NDIGIT_MAX 18
-# else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-#  error "NDIGIT_MAX must be precomputed"
-#  define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
-# endif
-#else
-# define LONG_DOUBLE_CVT
-#endif
-
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
 #define __APPEND(a, b) __APPEND2 (a, b)
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
index 30d25ff114..2194093d9f 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <float.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -26,38 +25,6 @@
 #include <sys/param.h>
 #include <math_ldbl_opt.h>
 
-#ifndef FLOAT_TYPE
-# define FLOAT_TYPE double
-# define FUNC_PREFIX
-# define FLOAT_FMT_FLAG
-# define FLOAT_NAME_EXT
-# define FLOAT_MIN_10_EXP DBL_MIN_10_EXP
-# if DBL_MANT_DIG == 53
-#  define NDIGIT_MAX 17
-# elif DBL_MANT_DIG == 24
-#  define NDIGIT_MAX 9
-# elif DBL_MANT_DIG == 56
-#  define NDIGIT_MAX 18
-# else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-#  error "NDIGIT_MAX must be precomputed"
-#  define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
-# endif
-# if DBL_MIN_10_EXP == -37
-#  define FLOAT_MIN_10_NORM	1.0e-37
-# elif DBL_MIN_10_EXP == -307
-#  define FLOAT_MIN_10_NORM	1.0e-307
-# elif DBL_MIN_10_EXP == -4931
-#  define FLOAT_MIN_10_NORM	1.0e-4931
-# else
-/* libc can't depend on libm.  */
-#  error "FLOAT_MIN_10_NORM must be precomputed"
-#  define FLOAT_MIN_10_NORM	exp10 (DBL_MIN_10_EXP)
-# endif
-#else
-# define LONG_DOUBLE_CVT
-#endif
 
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
-- 
2.21.0

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

* [PATCH 20/31] Refactor *cvt functions implementation (1/5)
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (21 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 17/31] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:08 ` [PATCH 24/31] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

This patch is to be squashed with the other n/5 refactoring patches.

I split it into these 5 patches, because even using -M<x> and -C<y>, the
patches looks as if a lot has changed, when it's basically just moving
code around.  The final commit will be the squashing of patches 1 to 5,
with the following commit message:

-- 8< --
This patch refactors the *cvt functions implementation in a way that
makes it easier to re-use them for implementing the IEEE long double on
powerpc64le.  By splitting the implementation per se in one file
(efgcvt-template.c) and the alias definitions in others (e.g. efgcvt.c),
the new code makes it easier to define new function names, such as
__qecvtieee128.
---
 misc/{efgcvt.c => efgcvt-template.c}     | 0
 misc/{efgcvt_r.c => efgcvt_r-template.c} | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename misc/{efgcvt.c => efgcvt-template.c} (100%)
 rename misc/{efgcvt_r.c => efgcvt_r-template.c} (100%)

diff --git a/misc/efgcvt.c b/misc/efgcvt-template.c
similarity index 100%
rename from misc/efgcvt.c
rename to misc/efgcvt-template.c
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r-template.c
similarity index 100%
rename from misc/efgcvt_r.c
rename to misc/efgcvt_r-template.c
-- 
2.21.0

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

* [PATCH 18/31] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (15 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 22/31] Refactor *cvt functions implementation (3/5) Gabriel F. T. Gomes
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

Since the commit

commit 86a0f56158bd9cbaf2d640e2e6c66539f4cbbcc1
Author: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Date:   Thu Jun 28 13:57:50 2018 +0530

    ldbl-128ibm-compat: Introduce ieee128 symbols

IEEE long double versions of strfroml, strtold, and wcstold have been
prepared, but not exposed (which will only happen when the full support
for IEEE long double is complete).  This patch adds tests for these
functions in both IBM and IEEE long double mode.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 12 +++++
 .../ldbl-128ibm-compat/test-strfrom-ibm128.c  |  1 +
 .../ldbl-128ibm-compat/test-strfrom-ieee128.c |  1 +
 .../test-strfrom-ldbl-compat.c                | 49 +++++++++++++++++++
 .../ldbl-128ibm-compat/test-wcstold-ibm128.c  |  1 +
 .../ldbl-128ibm-compat/test-wcstold-ieee128.c |  1 +
 .../test-wcstold-ldbl-compat.c                | 36 ++++++++++++++
 7 files changed, 101 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 955da1d1ee..fb7e119de7 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -13,6 +13,12 @@ ldbl-extra-routines += isoc99_fwscanf \
 		       isoc99_vfwscanf \
 		       isoc99_vswscanf \
 		       isoc99_vwscanf
+
+tests-internal += test-wcstold-ibm128 test-wcstold-ieee128
+CFLAGS-test-wcstold-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wcstold-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-wcstold-ieee128: gnulib-tests += $(f128-loader-link)
 endif
 
 ifeq ($(subdir),stdio-common)
@@ -287,6 +293,12 @@ CFLAGS-test-strfmon-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 CFLAGS-test-strfmon-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 $(objpfx)tst-strfmon-ibm128.out: $(gen-locales)
 $(objpfx)tst-strfmon-ieee128.out: $(gen-locales)
+
+tests-internal += test-strfrom-ibm128 test-strfrom-ieee128
+CFLAGS-test-strfrom-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-strfrom-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-strfrom-ieee128: gnulib-tests += $(f128-loader-link)
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
new file mode 100644
index 0000000000..93887706b9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
@@ -0,0 +1 @@
+#include <test-strfrom-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
new file mode 100644
index 0000000000..93887706b9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
@@ -0,0 +1 @@
+#include <test-strfrom-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
new file mode 100644
index 0000000000..f32548fe90
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
@@ -0,0 +1,49 @@
+/* Test for the long double variants of strfroml and strtold.
+   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 <stdlib.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  int written;
+  char buffer[64];
+  char *bufptr = buffer;
+  const char *expected = "-1.0000000000";
+  long double read;
+
+  /* Write to the buffer.  */
+  written = strfroml (bufptr, 64, "%.10f", (long double) -1);
+  if (written < 0)
+    support_record_failure ();
+
+  /* Compare against the expected output.  */
+  TEST_COMPARE_STRING (expected, buffer);
+
+  /* Read from the buffer.  */
+  read = strtold (expected, NULL);
+
+  if (read != (long double) -1)
+    support_record_failure ();
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
new file mode 100644
index 0000000000..4d60692eeb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
@@ -0,0 +1 @@
+#include <test-wcstold-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
new file mode 100644
index 0000000000..4d60692eeb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
@@ -0,0 +1 @@
+#include <test-wcstold-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
new file mode 100644
index 0000000000..8b9e300147
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
@@ -0,0 +1,36 @@
+/* Test for the long double variant of wcstold.
+   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 <wchar.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  const wchar_t *input = L"-1.0000000000";
+  long double read;
+
+  read = wcstold (input, NULL);
+  if (read != (long double) -1)
+    support_record_failure ();
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.0

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

* [PATCH 22/31] Refactor *cvt functions implementation (3/5)
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (16 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 18/31] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 21/31] Refactor *cvt functions implementation (2/5) Gabriel F. T. Gomes
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

This patch is to be squashed with the other n/5 refactoring patches.

This patch only moves and merges the contents of misc/qefgcvt.c and
misc/qefgcvt_r.c into misc/efgcvt-ldbl-macros.h.
---
 misc/efgcvt-ldbl-macros.h | 59 +++++++++++++++++++++++++++++++++++++++
 misc/qefgcvt.c            | 27 ------------------
 misc/qefgcvt_r.c          | 37 ------------------------
 3 files changed, 59 insertions(+), 64 deletions(-)
 create mode 100644 misc/efgcvt-ldbl-macros.h

diff --git a/misc/efgcvt-ldbl-macros.h b/misc/efgcvt-ldbl-macros.h
new file mode 100644
index 0000000000..ff97b13d7f
--- /dev/null
+++ b/misc/efgcvt-ldbl-macros.h
@@ -0,0 +1,59 @@
+/* Macros for the implementation of *cvt functions, long double 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 <float.h>
+
+#define FLOAT_TYPE long double
+#define FUNC_PREFIX q
+#define FLOAT_FMT_FLAG "L"
+#define FLOAT_NAME_EXT l
+#define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP
+/* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
+   we don't have log10 available in the preprocessor.  Since we cannot
+   assume anything on the used `long double' format be generous.  */
+#define MAXDIG (NDIGIT_MAX + 12)
+#define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG)
+#if LDBL_MANT_DIG == 64
+# define NDIGIT_MAX 21
+#elif LDBL_MANT_DIG == 53
+# define NDIGIT_MAX 17
+#elif LDBL_MANT_DIG == 113
+# define NDIGIT_MAX 36
+#elif LDBL_MANT_DIG == 106
+# define NDIGIT_MAX 34
+#elif LDBL_MANT_DIG == 56
+# define NDIGIT_MAX 18
+#else
+/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
+   compile time constant here, so we cannot use it.  */
+# error "NDIGIT_MAX must be precomputed"
+# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
+#endif
+#if LDBL_MIN_10_EXP == -37
+# define FLOAT_MIN_10_NORM	1.0e-37L
+#elif LDBL_MIN_10_EXP == -291
+# define FLOAT_MIN_10_NORM	1.0e-291L
+#elif LDBL_MIN_10_EXP == -307
+# define FLOAT_MIN_10_NORM	1.0e-307L
+#elif LDBL_MIN_10_EXP == -4931
+# define FLOAT_MIN_10_NORM	1.0e-4931L
+#else
+/* libc can't depend on libm.  */
+# error "FLOAT_MIN_10_NORM must be precomputed"
+# define FLOAT_MIN_10_NORM	exp10l (LDBL_MIN_10_EXP)
+#endif
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index 4fcadfcdc2..6987fb0db1 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -16,31 +16,4 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <float.h>
-
-#define FLOAT_TYPE long double
-#define FUNC_PREFIX q
-#define FLOAT_FMT_FLAG "L"
-/* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
-   we don't have log10 available in the preprocessor.  Since we cannot
-   assume anything on the used `long double' format be generous.  */
-#define MAXDIG (NDIGIT_MAX + 12)
-#define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG)
-#if LDBL_MANT_DIG == 64
-# define NDIGIT_MAX 21
-#elif LDBL_MANT_DIG == 53
-# define NDIGIT_MAX 17
-#elif LDBL_MANT_DIG == 113
-# define NDIGIT_MAX 36
-#elif LDBL_MANT_DIG == 106
-# define NDIGIT_MAX 34
-#elif LDBL_MANT_DIG == 56
-# define NDIGIT_MAX 18
-#else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-# error "NDIGIT_MAX must be precomputed"
-# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
-#endif
-
 #include "efgcvt.c"
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index 8f4d8b9f7a..e1f074b49c 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -17,41 +17,4 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <float.h>
-
-#define FLOAT_TYPE long double
-#define FUNC_PREFIX q
-#define FLOAT_FMT_FLAG "L"
-#define FLOAT_NAME_EXT l
-#define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP
-#if LDBL_MANT_DIG == 64
-# define NDIGIT_MAX 21
-#elif LDBL_MANT_DIG == 53
-# define NDIGIT_MAX 17
-#elif LDBL_MANT_DIG == 113
-# define NDIGIT_MAX 36
-#elif LDBL_MANT_DIG == 106
-# define NDIGIT_MAX 34
-#elif LDBL_MANT_DIG == 56
-# define NDIGIT_MAX 18
-#else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-# error "NDIGIT_MAX must be precomputed"
-# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
-#endif
-#if LDBL_MIN_10_EXP == -37
-# define FLOAT_MIN_10_NORM	1.0e-37L
-#elif LDBL_MIN_10_EXP == -291
-# define FLOAT_MIN_10_NORM	1.0e-291L
-#elif LDBL_MIN_10_EXP == -307
-# define FLOAT_MIN_10_NORM	1.0e-307L
-#elif LDBL_MIN_10_EXP == -4931
-# define FLOAT_MIN_10_NORM	1.0e-4931L
-#else
-/* libc can't depend on libm.  */
-# error "FLOAT_MIN_10_NORM must be precomputed"
-# define FLOAT_MIN_10_NORM	exp10l (LDBL_MIN_10_EXP)
-#endif
-
 #include "efgcvt_r.c"
-- 
2.21.0

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

* [PATCH 09/31] ldbl-128ibm-compat: Add argp_error and argp_failure
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (13 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 19/31] Remove hidden_def and hidden_proto from cvt functions Gabriel F. T. Gomes
@ 2019-10-15 19:07 ` Gabriel F. T. Gomes
  2019-10-15 19:07 ` [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:07 UTC (permalink / raw)
  To: libc-alpha

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

Use the recently added, internal functions, __argp_error_internal and
__argp_failure_internal, to provide argp_error and argp_failure that can
take long double arguments with IEEE binary128 format on platforms where
long double can also take double format or some non-IEEE format
(currently, this means powerpc64le).

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 14 +++++++
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  3 ++
 .../ldbl-128ibm-compat/ieee128-argp-help.c    | 42 +++++++++++++++++++
 3 files changed, 59 insertions(+)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 031ee0b38f..dc1ceaae7e 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -160,6 +160,20 @@ CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
 					  -Wno-unused-result
 endif
 
+ifeq ($(subdir),argp)
+ldbl-extra-routines += argp-help
+
+$(objpfx)tst-ieee128-argp.c: tst-ldbl-argp.c
+	cp $< $@
+
+$(objpfx)tst-ibm128-argp.c: tst-ldbl-argp.c
+	cp $< $@
+
+tests-internal += tst-ieee128-argp tst-ibm128-argp
+CFLAGS-tst-ieee128-argp.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi
+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 8b23fdf56f..8e80b2bade 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -180,5 +180,8 @@ libc {
     __vfwscanfieee128;
     __vswscanfieee128;
     __vwscanfieee128;
+
+    __argp_errorieee128;
+    __argp_failureieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c
new file mode 100644
index 0000000000..fe77e633df
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c
@@ -0,0 +1,42 @@
+/* Wrapper for argp_error and argp_failure.  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 <argp.h>
+#include <libio/libioP.h>
+
+void
+___ieee128_argp_error (const struct argp_state *state, const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  __argp_error_internal (state, fmt, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+strong_alias (___ieee128_argp_error, __argp_errorieee128)
+
+void
+___ieee128_argp_failure (const struct argp_state *state, int status,
+			int errnum, const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  __argp_failure_internal (state, status, errnum, fmt, ap,
+			   PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+strong_alias (___ieee128_argp_failure, __argp_failureieee128)
-- 
2.21.0

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

* [PATCH 24/31] Refactor *cvt functions implementation (5/5)
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (22 preceding siblings ...)
  2019-10-15 19:07 ` [PATCH 20/31] Refactor *cvt functions implementation (1/5) Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-15 19:08 ` [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

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

This patch is to be squashed with the other n/5 refactoring patches.

This patch replaces the use of the APPEND macro with one new macro being
defined for each of the cvt* functions.  This makes it easier to define
functions names for IEEE long double on powerpc64le, e.g. __ecvtieee128.
---
 misc/efgcvt-template.c   | 19 ++++++-------------
 misc/efgcvt.c            | 11 ++++++++++-
 misc/efgcvt_r-template.c | 23 ++++++-----------------
 misc/efgcvt_r.c          |  7 ++++++-
 misc/qefgcvt.c           | 11 ++++++++++-
 misc/qefgcvt_r.c         |  7 ++++++-
 6 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index aeb4e1ea01..7fabdf264d 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -25,8 +25,6 @@
 
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
-#define __APPEND(a, b) __APPEND2 (a, b)
-#define __APPEND2(a, b) __##a##b
 
 
 #define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer)
@@ -39,13 +37,11 @@ static char ECVT_BUFFER[MAXDIG];
 libc_freeres_ptr (static char *FCVT_BUFPTR);
 
 char *
-__APPEND (FUNC_PREFIX, fcvt) (FLOAT_TYPE value, int ndigit, int *decpt,
-			      int *sign)
+__FCVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign)
 {
   if (FCVT_BUFPTR == NULL)
     {
-      if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
-					  FCVT_BUFFER, MAXDIG) != -1)
+      if (__FCVT_R (value, ndigit, decpt, sign, FCVT_BUFFER, MAXDIG) != -1)
 	return FCVT_BUFFER;
 
       FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG);
@@ -53,25 +49,22 @@ __APPEND (FUNC_PREFIX, fcvt) (FLOAT_TYPE value, int ndigit, int *decpt,
 	return FCVT_BUFFER;
     }
 
-  (void) __APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
-					 FCVT_BUFPTR, FCVT_MAXDIG);
+  (void) __FCVT_R (value, ndigit, decpt, sign, FCVT_BUFPTR, FCVT_MAXDIG);
 
   return FCVT_BUFPTR;
 }
 
 
 char *
-__APPEND (FUNC_PREFIX, ecvt) (FLOAT_TYPE value, int ndigit, int *decpt,
-			      int *sign)
+__ECVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign)
 {
-  (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
-					 ECVT_BUFFER, MAXDIG);
+  (void) __ECVT_R (value, ndigit, decpt, sign, ECVT_BUFFER, MAXDIG);
 
   return ECVT_BUFFER;
 }
 
 char *
-__APPEND (FUNC_PREFIX, gcvt) (FLOAT_TYPE value, int ndigit, char *buf)
+__GCVT (FLOAT_TYPE value, int ndigit, char *buf)
 {
   sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
   return buf;
diff --git a/misc/efgcvt.c b/misc/efgcvt.c
index 8e6bdbf358..f49fdc270b 100644
--- a/misc/efgcvt.c
+++ b/misc/efgcvt.c
@@ -16,7 +16,16 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include "efgcvt.c"
+#define ECVT ecvt
+#define FCVT fcvt
+#define GCVT gcvt
+#define __ECVT __ecvt
+#define __FCVT __fcvt
+#define __GCVT __gcvt
+#define __ECVT_R __ecvt_r
+#define __FCVT_R __fcvt_r
+#include <efgcvt-dbl-macros.h>
+#include <efgcvt-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
 # define cvt_symbol(local, symbol) \
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
index f215dbd345..065ecd164c 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -26,20 +26,9 @@
 #include <math_ldbl_opt.h>
 
 
-#define APPEND(a, b) APPEND2 (a, b)
-#define APPEND2(a, b) a##b
-#define __APPEND(a, b) __APPEND2 (a, b)
-#define __APPEND2(a, b) __##a##b
-
-#define FLOOR APPEND(floor, FLOAT_NAME_EXT)
-#define FABS APPEND(fabs, FLOAT_NAME_EXT)
-#define LOG10 APPEND(log10, FLOAT_NAME_EXT)
-#define EXP APPEND(exp, FLOAT_NAME_EXT)
-
-
 int
-__APPEND (FUNC_PREFIX, fcvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
-				int *sign, char *buf, size_t len)
+__FCVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign,
+	  char *buf, size_t len)
 {
   ssize_t n;
   ssize_t i;
@@ -133,8 +122,8 @@ __APPEND (FUNC_PREFIX, fcvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
 }
 
 int
-__APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
-				int *sign, char *buf, size_t len)
+__ECVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign,
+	  char *buf, size_t len)
 {
   int exponent = 0;
 
@@ -193,8 +182,8 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
       *sign = isfinite (value) ? signbit (value) != 0 : 0;
     }
   else
-    if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
-					decpt, sign, buf, len))
+    if (__FCVT_R (value, MIN (ndigit, NDIGIT_MAX) - 1,
+		  decpt, sign, buf, len))
       return -1;
 
   *decpt += exponent;
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index f9066813e7..50075bb995 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -16,7 +16,12 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include "efgcvt_r.c"
+#define ECVT_R ecvt_r
+#define FCVT_R fcvt_r
+#define __ECVT_R __ecvt_r
+#define __FCVT_R __fcvt_r
+#include <efgcvt-dbl-macros.h>
+#include <efgcvt_r-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
 # define cvt_symbol(local, symbol) \
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index cddad1c54b..0ace26a67b 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -16,7 +16,16 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include "efgcvt.c"
+#define ECVT qecvt
+#define FCVT qfcvt
+#define GCVT qgcvt
+#define __ECVT __qecvt
+#define __FCVT __qfcvt
+#define __GCVT __qgcvt
+#define __ECVT_R __qecvt_r
+#define __FCVT_R __qfcvt_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
 # define cvt_symbol(local, symbol) \
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index 7293f1e125..5d8deed57d 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -17,7 +17,12 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include "efgcvt_r.c"
+#define ECVT_R qecvt_r
+#define FCVT_R qfcvt_r
+#define __ECVT_R __qecvt_r
+#define __FCVT_R __qfcvt_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt_r-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
 # define cvt_symbol(local, symbol) \
-- 
2.21.0

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

* [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (25 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 29/31] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-16  3:57   ` Florian Weimer
  2019-10-15 19:08 ` [PATCH 25/31] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
                   ` (3 subsequent siblings)
  30 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

On platforms where long double has IEEE binary128 format as a third
option (initially, only powerpc64le), many exported functions are
redirected to their __*ieee128 equivalents.  This redirection is
provided by installed headers such as stdio-ldbl.h, and is supposed to
work correctly with user code.

However, during the build of glibc, similar redirections are employed,
in internal headers such as include/stdio.h, in order to avoid extra PLT
entries.  These redirections conflict with the redirections to
__*ieee128, and must be avoided during the build.  This patch protects
the second redirections with a test for __LONG_DOUBLE_USES_FLOAT128.
---
 include/err.h        |  3 +++
 include/stdio.h      | 14 ++++++++++++--
 include/sys/syslog.h |  5 +++++
 include/wchar.h      |  3 +++
 4 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/include/err.h b/include/err.h
index 7c05cd1dbb..4bfd0f1769 100644
--- a/include/err.h
+++ b/include/err.h
@@ -12,12 +12,15 @@ __vwarn_internal (const char *format, __gnuc_va_list ap,
 
 # ifndef _ISOMAC
 
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
 libc_hidden_proto (warn)
 libc_hidden_proto (warnx)
 libc_hidden_proto (vwarn)
 libc_hidden_proto (vwarnx)
 libc_hidden_proto (verr)
 libc_hidden_proto (verrx)
+#  endif
 
 # endif /* !_ISOMAC */
 #endif /* err.h */
diff --git a/include/stdio.h b/include/stdio.h
index bea2066cd1..8ec801c989 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -13,7 +13,10 @@ extern int __fcloseall (void) attribute_hidden;
 extern int __snprintf (char *__restrict __s, size_t __maxlen,
 		       const char *__restrict __format, ...)
      __attribute__ ((__format__ (__printf__, 3, 4)));
+#  if !defined __LONG_DOUBLE_USES_FLOAT128 \
+  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
 libc_hidden_proto (__snprintf)
+#  endif
 extern int __vfscanf (FILE *__restrict __s,
 		      const char *__restrict __format,
 		      __gnuc_va_list __arg)
@@ -72,7 +75,8 @@ libc_hidden_proto (__isoc99_vfscanf)
    Unfortunately, symbol redirection is not transitive, so the
    __REDIRECT in the public header does not link up with the above
    libc_hidden_proto.  Bridge the gap with a macro.  */
-#  if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if !__GLIBC_USE (DEPRECATED_SCANF) \
+      && __LONG_DOUBLE_USES_FLOAT128 == 0
 #   undef sscanf
 #   define sscanf __isoc99_sscanf
 #  endif
@@ -150,7 +154,10 @@ libc_hidden_proto (__libc_readline_unlocked);
 extern const char *const _sys_errlist_internal[] attribute_hidden;
 extern int _sys_nerr_internal attribute_hidden;
 
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
 libc_hidden_proto (__asprintf)
+#endif
 #  if IS_IN (libc)
 extern FILE *_IO_new_fopen (const char*, const char*);
 #   define fopen(fname, mode) _IO_new_fopen (fname, mode)
@@ -171,13 +178,16 @@ extern int _IO_new_fgetpos (FILE *, __fpos_t *);
 #   define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp)
 #  endif
 
-libc_hidden_proto (dprintf)
 extern __typeof (dprintf) __dprintf
      __attribute__ ((__format__ (__printf__, 2, 3)));
 libc_hidden_proto (__dprintf)
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
+libc_hidden_proto (dprintf)
 libc_hidden_proto (fprintf)
 libc_hidden_proto (vfprintf)
 libc_hidden_proto (sprintf)
+#endif
 libc_hidden_proto (fwrite)
 libc_hidden_proto (perror)
 libc_hidden_proto (remove)
diff --git a/include/sys/syslog.h b/include/sys/syslog.h
index 89d3479ebc..e10c58f6ef 100644
--- a/include/sys/syslog.h
+++ b/include/sys/syslog.h
@@ -3,7 +3,12 @@
 #include <misc/sys/syslog.h>
 #ifndef _ISOMAC
 
+#include <bits/floatn.h>
+
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
 libc_hidden_proto (syslog)
+#endif
 
 /* __vsyslog_internal uses the same mode_flags bits as
    __v*printf_internal; see libio/libioP.h.  */
diff --git a/include/wchar.h b/include/wchar.h
index 2cb44954fc..4875c9e84c 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -114,7 +114,10 @@ libc_hidden_proto (fputws_unlocked)
 libc_hidden_proto (putwc_unlocked)
 libc_hidden_proto (putwc)
 
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
 libc_hidden_proto (vswscanf)
+#endif
 
 libc_hidden_proto (mbrtowc)
 libc_hidden_proto (wcrtomb)
-- 
2.21.0

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

* [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (23 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 24/31] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-15 21:08   ` Joseph Myers
  2019-10-15 19:08 ` [PATCH 29/31] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
                   ` (5 subsequent siblings)
  30 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

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

On powerpc64le, the libm_alias_float128_other_r_ldbl macro is
used to create an alias between totalorderf128 and __totalorderlieee128,
as well as between the totalordermagf128 and __totalordermaglieee128.

However, the totalorder* and totalordermag* functions changed their
parameter type since commit ID 42760d764649 and got compat symbols for
their old versions.  With this change, the aforementioned macro would
create two conflicting aliases for __totalorderlieee128 and
__totalordermaglieee128.

This patch avoids the creation of the alias between the IEEE long double
symbols (__totalorderl*ieee128) and the compat symbols, because the IEEE
long double functions have never been exported thus don't need such
compat symbol.
---
 sysdeps/ieee754/ldbl-128/s_totalorderl.c    | 2 ++
 sysdeps/ieee754/ldbl-128/s_totalordermagl.c | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/sysdeps/ieee754/ldbl-128/s_totalorderl.c b/sysdeps/ieee754/ldbl-128/s_totalorderl.c
index 098bd2bcab..7ed24e0928 100644
--- a/sysdeps/ieee754/ldbl-128/s_totalorderl.c
+++ b/sysdeps/ieee754/ldbl-128/s_totalorderl.c
@@ -74,6 +74,8 @@ __totalorder_compatl (_Float128 x, _Float128 y)
 {
   return __totalorderl (&x, &y);
 }
+#undef libm_alias_float128_other_r_ldbl
+#define libm_alias_float128_other_r_ldbl(from, to, r)
 #undef do_symbol
 #define do_symbol(orig_name, name, aliasname)			\
   strong_alias (orig_name, name)				\
diff --git a/sysdeps/ieee754/ldbl-128/s_totalordermagl.c b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
index b31788c77c..0afa178fcf 100644
--- a/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
+++ b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
@@ -68,6 +68,8 @@ __totalordermag_compatl (_Float128 x, _Float128 y)
 {
   return __totalordermagl (&x, &y);
 }
+#undef libm_alias_float128_other_r_ldbl
+#define libm_alias_float128_other_r_ldbl(from, to, r)
 #undef do_symbol
 #define do_symbol(orig_name, name, aliasname)			\
   strong_alias (orig_name, name)				\
-- 
2.21.0

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

* [PATCH 30/31] powerpc64le: Require a compiler with -mno-gnu-attribute
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (28 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 27/31] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-15 21:11   ` Joseph Myers
  2019-10-15 19:08 ` [PATCH 31/31] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
  30 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

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

On powerpc64le, a few files are built on IEEE long double mode
(-mabi=ieeelongdouble), whereas most are built on IBM long double mode
(-mabi=ibmlongdouble, the default for -mlong-double-128). Since binutils
2.31, linking object files with different long double modes causes
errors similar to:

  ld: libc_pic.a(s_isinfl.os) uses IBM long double,
      libc_pic.a(ieee128-qefgcvt.os) uses IEEE long double.
  collect2: error: ld returned 1 exit status
  make[2]: *** [../Makerules:649: libc_pic.os] Error 1

The warnings are fair and correct, but in order for glibc to have
support for both long double modes on powerpc64le, they have to be
ignored.  This can be accomplished with the use of -mno-gnu-attribute
option when building the few files that require IEEE long double mode.

However, -mno-gnu-attribute is not available in GCC 6, the minimum
version required to build glibc, so this patch adds a test for this
feature in powerpc64le builds, and fails early if it's not available.

Tested, on powerpc64le, that the build fails early with GCC 6 and that
it succeeds with GCC 7 or greater.
---
 sysdeps/powerpc/powerpc64/le/configure    | 29 +++++++++++++++++++++++
 sysdeps/powerpc/powerpc64/le/configure.ac | 15 ++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/sysdeps/powerpc/powerpc64/le/configure b/sysdeps/powerpc/powerpc64/le/configure
index bca80cec76..c8e01af4f2 100644
--- a/sysdeps/powerpc/powerpc64/le/configure
+++ b/sysdeps/powerpc/powerpc64/le/configure
@@ -32,4 +32,33 @@ if test "$libc_cv_target_power8_ok" != "yes"; then :
 fi
 CFLAGS="$OLD_CFLAGS"
 
+# Local configure fragment for sysdeps/powerpc/powerpc64le.
+
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -mno-gnu-attribute"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler supports -mno-gnu-attribute" >&5
+$as_echo_n "checking if the compiler supports -mno-gnu-attribute... " >&6; }
+if ${libc_cv_no_gnu_attr_ok+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_cv_no_gnu_attr_ok=yes
+else
+  libc_cv_no_gnu_attr_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_no_gnu_attr_ok" >&5
+$as_echo "$libc_cv_no_gnu_attr_ok" >&6; }
+if test "$libc_cv_no_gnu_attr_ok" != "yes"; then :
+  critic_missing="$critic_missing A compiler with -mno-gnu-attribute is required on powerpc64le."
+fi
+CFLAGS="$OLD_CFLAGS"
+
 test -n "$critic_missing" && as_fn_error $? "*** $critic_missing" "$LINENO" 5
diff --git a/sysdeps/powerpc/powerpc64/le/configure.ac b/sysdeps/powerpc/powerpc64/le/configure.ac
index 7f2c9fbf1f..fdec69603b 100644
--- a/sysdeps/powerpc/powerpc64/le/configure.ac
+++ b/sysdeps/powerpc/powerpc64/le/configure.ac
@@ -17,4 +17,19 @@ AS_IF([test "$libc_cv_target_power8_ok" != "yes"],
       [critic_missing="$critic_missing POWER8 or newer is required on powerpc64le."])
 CFLAGS="$OLD_CFLAGS"
 
+# Local configure fragment for sysdeps/powerpc/powerpc64le.
+
+dnl Require support for -mno-gnu-attribute
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -mno-gnu-attribute"
+AC_CACHE_CHECK([if the compiler supports -mno-gnu-attribute],
+	       libc_cv_no_gnu_attr_ok, [
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+]])],
+	       [libc_cv_no_gnu_attr_ok=yes],
+	       [libc_cv_no_gnu_attr_ok=no])])
+AS_IF([test "$libc_cv_no_gnu_attr_ok" != "yes"],
+      [critic_missing="$critic_missing A compiler with -mno-gnu-attribute is required on powerpc64le."])
+CFLAGS="$OLD_CFLAGS"
+
 test -n "$critic_missing" && AC_MSG_ERROR([*** $critic_missing])
-- 
2.21.0

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

* [PATCH 31/31] RFC: powerpc64le: Enable support for IEEE long double
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (29 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 30/31] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

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

DO NOT COMMIT!

On platforms where long double may have two different formats, i.e.: the
same format as double (64-bits) or something else (128-bits), building
with -mlong-double-128 is the default and function calls in the user
program match the name of the function in Glibc.  When building with
-mlong-double-64, Glibc installed headers redirect such calls to the
appropriate function.

This patch adds similar redirections to be used by user code builds in
IEEE long double mode (-mabi=ieeelongdouble).  It also skips some uses
of libc_hidden_proto in internal headers, because they also produce
redirections, causing a redirection conflict.

PS: Missing NEWS entry.
---
 argp/argp.h                                   |   4 +-
 include/stdlib.h                              |   4 +
 include/wchar.h                               |   4 +
 libio/bits/stdio-ldbl.h                       |  46 +++++---
 libio/stdio.h                                 |  19 +++-
 misc/bits/syslog-ldbl.h                       |   4 +-
 misc/err.h                                    |   4 +-
 misc/error.h                                  |   7 +-
 misc/sys/cdefs.h                              |  41 ++++++-
 misc/sys/syslog.h                             |   5 +-
 stdio-common/printf.h                         |   4 +-
 stdlib/bits/stdlib-ldbl.h                     |  22 ++++
 stdlib/monetary.h                             |   4 +-
 stdlib/stdlib.h                               |   5 +-
 .../ldbl-128ibm-compat/bits/long-double.h     |  25 +++++
 sysdeps/powerpc/powerpc64/le/Implies-before   |   1 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |  93 ++++++++++++++++
 .../linux/powerpc/powerpc64/le/libm.abilist   | 104 ++++++++++++++++++
 wcsmbs/bits/wchar-ldbl.h                      |  36 +++++-
 wcsmbs/wchar.h                                |  17 ++-
 20 files changed, 406 insertions(+), 43 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h

diff --git a/argp/argp.h b/argp/argp.h
index 07adec1895..e6eb77085f 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -554,7 +554,9 @@ __NTH (__option_is_end (const struct argp_option *__opt))
 # endif
 #endif /* Use extern inlines.  */
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/argp-ldbl.h>
 #endif
 
diff --git a/include/stdlib.h b/include/stdlib.h
index 089607dbf9..130ca84201 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -202,9 +202,13 @@ libc_hidden_proto (____strtoll_l_internal)
 libc_hidden_proto (____strtoul_l_internal)
 libc_hidden_proto (____strtoull_l_internal)
 
+#include <bits/floatn.h>
 libc_hidden_proto (strtof)
 libc_hidden_proto (strtod)
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+    || __LONG_DOUBLE_USES_FLOAT128 == 0
 libc_hidden_proto (strtold)
+#endif
 libc_hidden_proto (strtol)
 libc_hidden_proto (strtoll)
 libc_hidden_proto (strtoul)
diff --git a/include/wchar.h b/include/wchar.h
index 4875c9e84c..653a080373 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -55,6 +55,7 @@ extern unsigned long long int __wcstoull_internal (const wchar_t *
 extern unsigned long long int ____wcstoull_l_internal (const wchar_t *,
 						       wchar_t **, int, int,
 						       locale_t);
+#include <bits/floatn.h>
 libc_hidden_proto (__wcstof_internal)
 libc_hidden_proto (__wcstod_internal)
 libc_hidden_proto (__wcstold_internal)
@@ -64,7 +65,10 @@ libc_hidden_proto (__wcstoul_internal)
 libc_hidden_proto (__wcstoull_internal)
 libc_hidden_proto (wcstof)
 libc_hidden_proto (wcstod)
+#if !defined __LONG_DOUBLE_USES_FLOAT128 \
+    || __LONG_DOUBLE_USES_FLOAT128 == 0
 libc_hidden_proto (wcstold)
+#endif
 libc_hidden_proto (wcstol)
 libc_hidden_proto (wcstoll)
 libc_hidden_proto (wcstoul)
diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h
index 2f01a98384..bfa65e87dc 100644
--- a/libio/bits/stdio-ldbl.h
+++ b/libio/bits/stdio-ldbl.h
@@ -27,9 +27,17 @@ __LDBL_REDIR_DECL (vfprintf)
 __LDBL_REDIR_DECL (vprintf)
 __LDBL_REDIR_DECL (vsprintf)
 #if !__GLIBC_USE (DEPRECATED_SCANF)
+# if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf)
 __LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf)
 __LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf)
+# elif defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (fscanf, __isoc99_fscanfieee128)
+__LDBL_REDIR1_DECL (scanf, __isoc99_scanfieee128)
+__LDBL_REDIR1_DECL (sscanf, __isoc99_sscanfieee128)
+# else
+#  error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+# endif
 #else
 __LDBL_REDIR_DECL (fscanf)
 __LDBL_REDIR_DECL (scanf)
@@ -43,9 +51,17 @@ __LDBL_REDIR_DECL (vsnprintf)
 
 #ifdef	__USE_ISOC99
 # if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf)
 __LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf)
 __LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf)
+#  elif defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (vfscanf, __isoc99_vfscanfieee128)
+__LDBL_REDIR1_DECL (vscanf, __isoc99_vscanfieee128)
+__LDBL_REDIR1_DECL (vsscanf, __isoc99_vsscanfieee128)
+#  else
+#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+#  endif
 # else
 __LDBL_REDIR_DECL (vfscanf)
 __LDBL_REDIR_DECL (vsscanf)
@@ -60,33 +76,33 @@ __LDBL_REDIR_DECL (dprintf)
 
 #ifdef __USE_GNU
 __LDBL_REDIR_DECL (vasprintf)
-__LDBL_REDIR_DECL (__asprintf)
+__LDBL_REDIR2_DECL (asprintf)
 __LDBL_REDIR_DECL (asprintf)
 __LDBL_REDIR_DECL (obstack_printf)
 __LDBL_REDIR_DECL (obstack_vprintf)
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-__LDBL_REDIR_DECL (__sprintf_chk)
-__LDBL_REDIR_DECL (__vsprintf_chk)
+__LDBL_REDIR2_DECL (sprintf_chk)
+__LDBL_REDIR2_DECL (vsprintf_chk)
 # if defined __USE_ISOC99 || defined __USE_UNIX98
-__LDBL_REDIR_DECL (__snprintf_chk)
-__LDBL_REDIR_DECL (__vsnprintf_chk)
+__LDBL_REDIR2_DECL (snprintf_chk)
+__LDBL_REDIR2_DECL (vsnprintf_chk)
 # endif
 # if __USE_FORTIFY_LEVEL > 1
-__LDBL_REDIR_DECL (__fprintf_chk)
-__LDBL_REDIR_DECL (__printf_chk)
-__LDBL_REDIR_DECL (__vfprintf_chk)
-__LDBL_REDIR_DECL (__vprintf_chk)
+__LDBL_REDIR2_DECL (fprintf_chk)
+__LDBL_REDIR2_DECL (printf_chk)
+__LDBL_REDIR2_DECL (vfprintf_chk)
+__LDBL_REDIR2_DECL (vprintf_chk)
 #  ifdef __USE_XOPEN2K8
-__LDBL_REDIR_DECL (__dprintf_chk)
-__LDBL_REDIR_DECL (__vdprintf_chk)
+__LDBL_REDIR2_DECL (dprintf_chk)
+__LDBL_REDIR2_DECL (vdprintf_chk)
 #  endif
 #  ifdef __USE_GNU
-__LDBL_REDIR_DECL (__asprintf_chk)
-__LDBL_REDIR_DECL (__vasprintf_chk)
-__LDBL_REDIR_DECL (__obstack_printf_chk)
-__LDBL_REDIR_DECL (__obstack_vprintf_chk)
+__LDBL_REDIR2_DECL (asprintf_chk)
+__LDBL_REDIR2_DECL (vasprintf_chk)
+__LDBL_REDIR2_DECL (obstack_printf_chk)
+__LDBL_REDIR2_DECL (obstack_vprintf_chk)
 #  endif
 # endif
 #endif
diff --git a/libio/stdio.h b/libio/stdio.h
index 1abce9b3f1..7bbec4b60b 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -400,9 +400,13 @@ extern int sscanf (const char *__restrict __s,
 		   const char *__restrict __format, ...) __THROW;
 
 /* For historical reasons, the C99-compliant versions of the scanf
-   functions are at alternative names.  When __LDBL_COMPAT is in
-   effect, this is handled in bits/stdio-ldbl.h.  */
-#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
+   functions are at alternative names.  When __LDBL_COMPAT or
+   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
+   bits/stdio-ldbl.h.  */
+#include <bits/floatn.h>
+#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
+    && (!defined __LONG_DOUBLE_USES_FLOAT128 \
+	|| __LONG_DOUBLE_USES_FLOAT128 == 0)
 # ifdef __REDIRECT
 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
 				const char *__restrict __format, ...),
@@ -447,7 +451,9 @@ extern int vsscanf (const char *__restrict __s,
 
 /* Same redirection as above for the v*scanf family.  */
 # if !__GLIBC_USE (DEPRECATED_SCANF)
-#  if defined __REDIRECT && !defined __LDBL_COMPAT
+#  if defined __REDIRECT && !defined __LDBL_COMPAT \
+      && (!defined __LONG_DOUBLE_USES_FLOAT128 \
+	  || __LONG_DOUBLE_USES_FLOAT128 == 0)
 extern int __REDIRECT (vfscanf,
 		       (FILE *__restrict __s,
 			const char *__restrict __format, __gnuc_va_list __arg),
@@ -866,7 +872,10 @@ extern int __overflow (FILE *, int);
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
 # include <bits/stdio2.h>
 #endif
-#ifdef __LDBL_COMPAT
+
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/stdio-ldbl.h>
 #endif
 
diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h
index 8d60fb8e44..5075e50379 100644
--- a/misc/bits/syslog-ldbl.h
+++ b/misc/bits/syslog-ldbl.h
@@ -27,9 +27,9 @@ __LDBL_REDIR_DECL (vsyslog)
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-__LDBL_REDIR_DECL (__syslog_chk)
+__LDBL_REDIR2_DECL (syslog_chk)
 
 # ifdef __USE_MISC
-__LDBL_REDIR_DECL (__vsyslog_chk)
+__LDBL_REDIR2_DECL (vsyslog_chk)
 # endif
 #endif
diff --git a/misc/err.h b/misc/err.h
index a71b3fafe0..6ba1c7804f 100644
--- a/misc/err.h
+++ b/misc/err.h
@@ -52,7 +52,9 @@ extern void errx (int __status, const char *__format, ...)
 extern void verrx (int __status, const char *, __gnuc_va_list)
      __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0)));
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/err-ldbl.h>
 #endif
 
diff --git a/misc/error.h b/misc/error.h
index 79840bf0f7..69a284ea52 100644
--- a/misc/error.h
+++ b/misc/error.h
@@ -47,11 +47,14 @@ extern unsigned int error_message_count;
    variable controls whether this mode is selected or not.  */
 extern int error_one_per_line;
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/error-ldbl.h>
 #else
 /* Do not inline error and error_at_line when long double has the same
-   size of double, because that would invalidate the redirections to the
+   size of double, nor when long double reuses the float128
+   implementation, because that would invalidate the redirections to the
    compatibility functions.  */
 # if defined __extern_always_inline && defined __va_arg_pack
 #  include <bits/error.h>
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index abcb0d5e3c..f48f89f078 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -460,7 +460,38 @@
 #include <bits/wordsize.h>
 #include <bits/long-double.h>
 
-#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+#if defined __LONG_DOUBLE_USES_FLOAT128 \
+    && __LONG_DOUBLE_USES_FLOAT128 == 1
+# ifdef __REDIRECT
+
+/* Alias name defined automatically.  */
+#  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
+#  define __LDBL_REDIR_DECL(name) \
+  extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined automatically, with leading underscores.  */
+#  define __LDBL_REDIR2_DECL(name) \
+  extern __typeof (__##name) __##name \
+    __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined manually.  */
+#  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
+#  define __LDBL_REDIR1_DECL(name, alias) \
+  extern __typeof (name) name __asm (__ASMNAME (#alias));
+
+#  define __LDBL_REDIR1_NTH(name, proto, alias) \
+  __REDIRECT_NTH (name, proto, alias)
+#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
+  __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
+
+/* Unused.  */
+#  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
+#  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
+
+# else
+_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
+# endif
+#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
 # define __LDBL_COMPAT 1
 # ifdef __REDIRECT
 #  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -469,6 +500,8 @@
 #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
 #  define __LDBL_REDIR_NTH(name, proto) \
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+#  define __LDBL_REDIR2_DECL(name) \
+  extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
 #  define __LDBL_REDIR1_DECL(name, alias) \
   extern __typeof (name) name __asm (__ASMNAME (#alias));
 #  define __LDBL_REDIR_DECL(name) \
@@ -479,11 +512,15 @@
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
 # endif
 #endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT \
+     && (!defined __LONG_DOUBLE_USES_FLOAT128 \
+	 || __LONG_DOUBLE_USES_FLOAT128 == 0)) \
+    || !defined __REDIRECT
 # define __LDBL_REDIR1(name, proto, alias) name proto
 # define __LDBL_REDIR(name, proto) name proto
 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR2_DECL(name)
 # define __LDBL_REDIR_DECL(name)
 # ifdef __REDIRECT
 #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h
index ee01478c4b..56d3ce416c 100644
--- a/misc/sys/syslog.h
+++ b/misc/sys/syslog.h
@@ -206,7 +206,10 @@ extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap)
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
 # include <bits/syslog.h>
 #endif
-#ifdef __LDBL_COMPAT
+
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/syslog-ldbl.h>
 #endif
 
diff --git a/stdio-common/printf.h b/stdio-common/printf.h
index 2eb0b51382..ad1024572d 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -182,7 +182,9 @@ extern int printf_size_info (const struct printf_info *__restrict
 			     __info, size_t __n, int *__restrict __argtypes)
      __THROW;
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/printf-ldbl.h>
 #endif
 
diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h
index dcbf74a6dd..5b81394424 100644
--- a/stdlib/bits/stdlib-ldbl.h
+++ b/stdlib/bits/stdlib-ldbl.h
@@ -21,21 +21,43 @@
 #endif
 
 #ifdef	__USE_ISOC99
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (strtold, strtod)
+# else
+__LDBL_REDIR1_DECL (strtold, __strtoieee128)
+# endif
 #endif
 
 #ifdef __USE_GNU
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (strtold_l, strtod_l)
+# else
+__LDBL_REDIR1_DECL (strtold_l, __strtoieee128_l)
+# endif
 #endif
 
 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (strfroml, strfromd)
+# else
+__LDBL_REDIR1_DECL (strfroml, __strfromieee128)
+# endif
 #endif
 
 #ifdef __USE_MISC
+# if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (qecvt, ecvt)
 __LDBL_REDIR1_DECL (qfcvt, fcvt)
 __LDBL_REDIR1_DECL (qgcvt, gcvt)
 __LDBL_REDIR1_DECL (qecvt_r, ecvt_r)
 __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r)
+# elif defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (qecvt, __qecvtieee128)
+__LDBL_REDIR1_DECL (qfcvt, __qfcvtieee128)
+__LDBL_REDIR1_DECL (qgcvt, __qgcvtieee128)
+__LDBL_REDIR1_DECL (qecvt_r, __qecvtieee128_r)
+__LDBL_REDIR1_DECL (qfcvt_r, __qfcvtieee128_r)
+# else
+#  error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+# endif
 #endif
diff --git a/stdlib/monetary.h b/stdlib/monetary.h
index 40d3128b90..164e3a729b 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -50,7 +50,9 @@ extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize,
      __THROW __attribute_format_strfmon__ (4, 5);
 #endif
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/monetary-ldbl.h>
 #endif
 
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 4bd86ec84d..85046fb8fe 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -1016,7 +1016,10 @@ extern int ttyslot (void) __THROW;
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
 # include <bits/stdlib.h>
 #endif
-#ifdef __LDBL_COMPAT
+
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/stdlib-ldbl.h>
 #endif
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h
new file mode 100644
index 0000000000..32452b672d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h
@@ -0,0 +1,25 @@
+/* Properties of long double type.  ldbl-opt version.
+   Copyright (C) 2016-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  published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef __NO_LONG_DOUBLE_MATH
+# define __LONG_DOUBLE_MATH_OPTIONAL	1
+# ifndef __LONG_DOUBLE_128__
+#  define __NO_LONG_DOUBLE_MATH		1
+# endif
+#endif
+#define __LONG_DOUBLE_USES_FLOAT128 (__LDBL_MANT_DIG__ == 113)
diff --git a/sysdeps/powerpc/powerpc64/le/Implies-before b/sysdeps/powerpc/powerpc64/le/Implies-before
index 7c20db4e97..2139f4dae8 100644
--- a/sysdeps/powerpc/powerpc64/le/Implies-before
+++ b/sysdeps/powerpc/powerpc64/le/Implies-before
@@ -1,4 +1,5 @@
 # On PowerPC we use the IBM extended long double format.
+ieee754/ldbl-128ibm-compat
 ieee754/ldbl-128ibm
 ieee754/ldbl-opt
 ieee754/dbl-64
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index 2229a1dcc0..737c7c33e4 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2247,3 +2247,96 @@ GLIBC_2.30 getdents64 F
 GLIBC_2.30 gettid F
 GLIBC_2.30 tgkill F
 GLIBC_2.30 twalk_r F
+GLIBC_2.31 __argp_errorieee128 F
+GLIBC_2.31 __argp_failureieee128 F
+GLIBC_2.31 __asprintf_chkieee128 F
+GLIBC_2.31 __asprintfieee128 F
+GLIBC_2.31 __dprintf_chkieee128 F
+GLIBC_2.31 __dprintfieee128 F
+GLIBC_2.31 __errieee128 F
+GLIBC_2.31 __error_at_lineieee128 F
+GLIBC_2.31 __errorieee128 F
+GLIBC_2.31 __errxieee128 F
+GLIBC_2.31 __fprintf_chkieee128 F
+GLIBC_2.31 __fprintfieee128 F
+GLIBC_2.31 __fscanfieee128 F
+GLIBC_2.31 __fwprintf_chkieee128 F
+GLIBC_2.31 __fwprintfieee128 F
+GLIBC_2.31 __fwscanfieee128 F
+GLIBC_2.31 __isoc99_fscanfieee128 F
+GLIBC_2.31 __isoc99_fwscanfieee128 F
+GLIBC_2.31 __isoc99_scanfieee128 F
+GLIBC_2.31 __isoc99_sscanfieee128 F
+GLIBC_2.31 __isoc99_swscanfieee128 F
+GLIBC_2.31 __isoc99_vfscanfieee128 F
+GLIBC_2.31 __isoc99_vfwscanfieee128 F
+GLIBC_2.31 __isoc99_vscanfieee128 F
+GLIBC_2.31 __isoc99_vsscanfieee128 F
+GLIBC_2.31 __isoc99_vswscanfieee128 F
+GLIBC_2.31 __isoc99_vwscanfieee128 F
+GLIBC_2.31 __isoc99_wscanfieee128 F
+GLIBC_2.31 __obstack_printf_chkieee128 F
+GLIBC_2.31 __obstack_printfieee128 F
+GLIBC_2.31 __obstack_vprintf_chkieee128 F
+GLIBC_2.31 __obstack_vprintfieee128 F
+GLIBC_2.31 __printf_chkieee128 F
+GLIBC_2.31 __printf_sizeieee128 F
+GLIBC_2.31 __printfieee128 F
+GLIBC_2.31 __qecvtieee128 F
+GLIBC_2.31 __qecvtieee128_r F
+GLIBC_2.31 __qfcvtieee128 F
+GLIBC_2.31 __qfcvtieee128_r F
+GLIBC_2.31 __qgcvtieee128 F
+GLIBC_2.31 __scanfieee128 F
+GLIBC_2.31 __snprintf_chkieee128 F
+GLIBC_2.31 __snprintfieee128 F
+GLIBC_2.31 __sprintf_chkieee128 F
+GLIBC_2.31 __sprintfieee128 F
+GLIBC_2.31 __sscanfieee128 F
+GLIBC_2.31 __strfmon_lieee128 F
+GLIBC_2.31 __strfmonieee128 F
+GLIBC_2.31 __strfromieee128 F
+GLIBC_2.31 __strtoieee128 F
+GLIBC_2.31 __strtoieee128_l F
+GLIBC_2.31 __swprintf_chkieee128 F
+GLIBC_2.31 __swprintfieee128 F
+GLIBC_2.31 __swscanfieee128 F
+GLIBC_2.31 __syslog_chkieee128 F
+GLIBC_2.31 __syslogieee128 F
+GLIBC_2.31 __vasprintf_chkieee128 F
+GLIBC_2.31 __vasprintfieee128 F
+GLIBC_2.31 __vdprintf_chkieee128 F
+GLIBC_2.31 __vdprintfieee128 F
+GLIBC_2.31 __verrieee128 F
+GLIBC_2.31 __verrxieee128 F
+GLIBC_2.31 __vfprintf_chkieee128 F
+GLIBC_2.31 __vfprintfieee128 F
+GLIBC_2.31 __vfscanfieee128 F
+GLIBC_2.31 __vfwprintf_chkieee128 F
+GLIBC_2.31 __vfwprintfieee128 F
+GLIBC_2.31 __vfwscanfieee128 F
+GLIBC_2.31 __vprintf_chkieee128 F
+GLIBC_2.31 __vprintfieee128 F
+GLIBC_2.31 __vscanfieee128 F
+GLIBC_2.31 __vsnprintf_chkieee128 F
+GLIBC_2.31 __vsnprintfieee128 F
+GLIBC_2.31 __vsprintf_chkieee128 F
+GLIBC_2.31 __vsprintfieee128 F
+GLIBC_2.31 __vsscanfieee128 F
+GLIBC_2.31 __vswprintf_chkieee128 F
+GLIBC_2.31 __vswprintfieee128 F
+GLIBC_2.31 __vswscanfieee128 F
+GLIBC_2.31 __vsyslog_chkieee128 F
+GLIBC_2.31 __vsyslogieee128 F
+GLIBC_2.31 __vwarnieee128 F
+GLIBC_2.31 __vwarnxieee128 F
+GLIBC_2.31 __vwprintf_chkieee128 F
+GLIBC_2.31 __vwprintfieee128 F
+GLIBC_2.31 __vwscanfieee128 F
+GLIBC_2.31 __warnieee128 F
+GLIBC_2.31 __warnxieee128 F
+GLIBC_2.31 __wcstoieee128 F
+GLIBC_2.31 __wcstoieee128_l F
+GLIBC_2.31 __wprintf_chkieee128 F
+GLIBC_2.31 __wprintfieee128 F
+GLIBC_2.31 __wscanfieee128 F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist
index d479a64fca..60658729d0 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist
@@ -1081,6 +1081,110 @@ GLIBC_2.29 exp2 F
 GLIBC_2.29 log F
 GLIBC_2.29 log2 F
 GLIBC_2.29 pow F
+GLIBC_2.31 __acoshieee128 F
+GLIBC_2.31 __acosieee128 F
+GLIBC_2.31 __asinhieee128 F
+GLIBC_2.31 __asinieee128 F
+GLIBC_2.31 __atan2ieee128 F
+GLIBC_2.31 __atanhieee128 F
+GLIBC_2.31 __atanieee128 F
+GLIBC_2.31 __cabsieee128 F
+GLIBC_2.31 __cacoshieee128 F
+GLIBC_2.31 __cacosieee128 F
+GLIBC_2.31 __canonicalizeieee128 F
+GLIBC_2.31 __cargieee128 F
+GLIBC_2.31 __casinhieee128 F
+GLIBC_2.31 __casinieee128 F
+GLIBC_2.31 __catanhieee128 F
+GLIBC_2.31 __catanieee128 F
+GLIBC_2.31 __cbrtieee128 F
+GLIBC_2.31 __ccoshieee128 F
+GLIBC_2.31 __ccosieee128 F
+GLIBC_2.31 __ceilieee128 F
+GLIBC_2.31 __cexpieee128 F
+GLIBC_2.31 __cimagieee128 F
+GLIBC_2.31 __clog10ieee128 F
+GLIBC_2.31 __clogieee128 F
+GLIBC_2.31 __conjieee128 F
+GLIBC_2.31 __copysignieee128 F
+GLIBC_2.31 __coshieee128 F
+GLIBC_2.31 __cosieee128 F
+GLIBC_2.31 __cpowieee128 F
+GLIBC_2.31 __cprojieee128 F
+GLIBC_2.31 __crealieee128 F
+GLIBC_2.31 __csinhieee128 F
+GLIBC_2.31 __csinieee128 F
+GLIBC_2.31 __csqrtieee128 F
+GLIBC_2.31 __ctanhieee128 F
+GLIBC_2.31 __ctanieee128 F
+GLIBC_2.31 __erfcieee128 F
+GLIBC_2.31 __erfieee128 F
+GLIBC_2.31 __exp10ieee128 F
+GLIBC_2.31 __exp2ieee128 F
+GLIBC_2.31 __expieee128 F
+GLIBC_2.31 __expm1ieee128 F
+GLIBC_2.31 __fabsieee128 F
+GLIBC_2.31 __fdimieee128 F
+GLIBC_2.31 __floorieee128 F
+GLIBC_2.31 __fmaieee128 F
+GLIBC_2.31 __fmaxieee128 F
+GLIBC_2.31 __fmaxmagieee128 F
+GLIBC_2.31 __fminieee128 F
+GLIBC_2.31 __fminmagieee128 F
+GLIBC_2.31 __fmodieee128 F
+GLIBC_2.31 __frexpieee128 F
+GLIBC_2.31 __fromfpieee128 F
+GLIBC_2.31 __fromfpxieee128 F
+GLIBC_2.31 __getpayloadieee128 F
+GLIBC_2.31 __hypotieee128 F
+GLIBC_2.31 __ilogbieee128 F
+GLIBC_2.31 __j0ieee128 F
+GLIBC_2.31 __j1ieee128 F
+GLIBC_2.31 __jnieee128 F
+GLIBC_2.31 __ldexpieee128 F
+GLIBC_2.31 __lgammaieee128 F
+GLIBC_2.31 __lgammaieee128_r F
+GLIBC_2.31 __llogbieee128 F
+GLIBC_2.31 __llrintieee128 F
+GLIBC_2.31 __llroundieee128 F
+GLIBC_2.31 __log10ieee128 F
+GLIBC_2.31 __log1pieee128 F
+GLIBC_2.31 __log2ieee128 F
+GLIBC_2.31 __logbieee128 F
+GLIBC_2.31 __logieee128 F
+GLIBC_2.31 __lrintieee128 F
+GLIBC_2.31 __lroundieee128 F
+GLIBC_2.31 __modfieee128 F
+GLIBC_2.31 __nanieee128 F
+GLIBC_2.31 __nearbyintieee128 F
+GLIBC_2.31 __nextafterieee128 F
+GLIBC_2.31 __nextdownieee128 F
+GLIBC_2.31 __nextupieee128 F
+GLIBC_2.31 __powieee128 F
+GLIBC_2.31 __remainderieee128 F
+GLIBC_2.31 __remquoieee128 F
+GLIBC_2.31 __rintieee128 F
+GLIBC_2.31 __roundevenieee128 F
+GLIBC_2.31 __roundieee128 F
+GLIBC_2.31 __scalblnieee128 F
+GLIBC_2.31 __scalbnieee128 F
+GLIBC_2.31 __setpayloadieee128 F
+GLIBC_2.31 __setpayloadsigieee128 F
+GLIBC_2.31 __sincosieee128 F
+GLIBC_2.31 __sinhieee128 F
+GLIBC_2.31 __sinieee128 F
+GLIBC_2.31 __sqrtieee128 F
+GLIBC_2.31 __tanhieee128 F
+GLIBC_2.31 __tanieee128 F
+GLIBC_2.31 __tgammaieee128 F
+GLIBC_2.31 __totalorderieee128 F
+GLIBC_2.31 __totalordermagieee128 F
+GLIBC_2.31 __truncieee128 F
+GLIBC_2.31 __ufromfpieee128 F
+GLIBC_2.31 __ufromfpxieee128 F
+GLIBC_2.31 __y0ieee128 F
+GLIBC_2.31 __y1ieee128 F
+GLIBC_2.31 __ynieee128 F
 GLIBC_2.31 totalorder F
 GLIBC_2.31 totalorderf F
 GLIBC_2.31 totalorderf128 F
diff --git a/wcsmbs/bits/wchar-ldbl.h b/wcsmbs/bits/wchar-ldbl.h
index ae8f09800f..79df111c10 100644
--- a/wcsmbs/bits/wchar-ldbl.h
+++ b/wcsmbs/bits/wchar-ldbl.h
@@ -28,9 +28,17 @@ __LDBL_REDIR_DECL (vfwprintf);
 __LDBL_REDIR_DECL (vwprintf);
 __LDBL_REDIR_DECL (vswprintf);
 # if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf)
 __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf)
 __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf)
+#  elif defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (fwscanf, __isoc99_fwscanfieee128)
+__LDBL_REDIR1_DECL (wscanf, __isoc99_wscanfieee128)
+__LDBL_REDIR1_DECL (swscanf, __isoc99_swscanfieee128)
+#  else
+#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+#  endif
 # else
 __LDBL_REDIR_DECL (fwscanf);
 __LDBL_REDIR_DECL (wscanf);
@@ -39,11 +47,23 @@ __LDBL_REDIR_DECL (swscanf);
 #endif
 
 #ifdef __USE_ISOC99
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (wcstold, wcstod);
+# else
+__LDBL_REDIR1_DECL (wcstold, __wcstoieee128)
+# endif
 # if !__GLIBC_USE (DEPRECATED_SCANF)
+#  if defined __LDBL_COMPAT
 __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf)
 __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf)
 __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf)
+#  elif defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 1
+__LDBL_REDIR1_DECL (vfwscanf, __isoc99_vfwscanfieee128)
+__LDBL_REDIR1_DECL (vwscanf, __isoc99_vwscanfieee128)
+__LDBL_REDIR1_DECL (vswscanf, __isoc99_vswscanfieee128)
+#  else
+#   error bits/stdlib-ldbl.h included when no ldbl redirections are required.
+#  endif
 # else
 __LDBL_REDIR_DECL (vfwscanf);
 __LDBL_REDIR_DECL (vwscanf);
@@ -52,16 +72,20 @@ __LDBL_REDIR_DECL (vswscanf);
 #endif
 
 #ifdef __USE_GNU
+# ifdef __LDBL_COMPAT
 __LDBL_REDIR1_DECL (wcstold_l, wcstod_l);
+# else
+__LDBL_REDIR1_DECL (wcstold_l, __wcstoieee128_l)
+# endif
 #endif
 
 #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-__LDBL_REDIR_DECL (__swprintf_chk)
-__LDBL_REDIR_DECL (__vswprintf_chk)
+__LDBL_REDIR2_DECL (swprintf_chk)
+__LDBL_REDIR2_DECL (vswprintf_chk)
 # if __USE_FORTIFY_LEVEL > 1
-__LDBL_REDIR_DECL (__fwprintf_chk)
-__LDBL_REDIR_DECL (__wprintf_chk)
-__LDBL_REDIR_DECL (__vfwprintf_chk)
-__LDBL_REDIR_DECL (__vwprintf_chk)
+__LDBL_REDIR2_DECL (fwprintf_chk)
+__LDBL_REDIR2_DECL (wprintf_chk)
+__LDBL_REDIR2_DECL (vfwprintf_chk)
+__LDBL_REDIR2_DECL (vwprintf_chk)
 # endif
 #endif
diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h
index 4b731ebb51..c131d6a8c4 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -633,9 +633,12 @@ extern int swscanf (const wchar_t *__restrict __s,
      __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */;
 
 /* For historical reasons, the C99-compliant versions of the scanf
-   functions are at alternative names.  When __LDBL_COMPAT is in
-   effect, this is handled in bits/wchar-ldbl.h.  */
-#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT
+   functions are at alternative names.  When __LDBL_COMPAT or
+   __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in
+   bits/wchar-ldbl.h.  */
+#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \
+     && (!defined __LONG_DOUBLE_USES_FLOAT128 \
+	 || __LONG_DOUBLE_USES_FLOAT128 == 0)
 #  ifdef __REDIRECT
 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
 				 const wchar_t *__restrict __format, ...),
@@ -687,7 +690,9 @@ extern int vswscanf (const wchar_t *__restrict __s,
 
 # if !defined __USE_GNU \
      && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
-     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
+     && (!defined __LONG_DOUBLE_USES_FLOAT128 \
+	 || __LONG_DOUBLE_USES_FLOAT128 == 0)
 #  ifdef __REDIRECT
 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
 				  const wchar_t *__restrict __format,
@@ -848,7 +853,9 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize,
 # include <bits/wchar2.h>
 #endif
 
-#ifdef __LDBL_COMPAT
+#include <bits/floatn.h>
+#if defined __LDBL_COMPAT || (defined __LONG_DOUBLE_USES_FLOAT128 \
+			      && __LONG_DOUBLE_USES_FLOAT128 == 1)
 # include <bits/wchar-ldbl.h>
 #endif
 
-- 
2.21.0

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

* [PATCH 27/31] ldbl-128ibm-compat: Compiler flags for stdio functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (27 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 25/31] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-15 19:08 ` [PATCH 30/31] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
  2019-10-15 19:08 ` [PATCH 31/31] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

Some of the files that provide stdio.h and wchar.h functions have a
filename prefixed with 'io', such as 'iovsprintf.c'.  On platforms that
imply ldbl-128ibm-compat, these files must be compiled with the flag
-mabi=ibmlongdouble.  This patch adds this flag to their compilation.

Notice that this is not required for the other files that provide
similar functions, because filenames that are not prefixed with 'io'
have ldbl-128ibm-compat counterparts in the Makefile, which already adds
-mabi=ibmlongdouble to them.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 3c6314dce8..1489680d98 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -325,6 +325,12 @@ routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
 # 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^ \
+		     $(objpfx)iovdprintf^ \
+		     $(objpfx)iovsprintf^ \
+		     $(objpfx)iovsscanf^ \
+		     $(objpfx)iovswscanf^ \
+		     $(objpfx)iovfscanf^ \
+		     $(objpfx)iovfwscanf^ \
 		     $(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)))
-- 
2.21.0

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

* [PATCH 29/31] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (24 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-15 19:08 ` [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

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

Some compiler versions, e.g. GCC 7, complain when -mlong-double-128 is
used together with -mabi=ibmlongdouble or -mabi=ieeelongdouble,
producing the following error message:

  cc1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’

This patch removes -mlong-double-128 from the compilation lines that
explicitly request -mabi=*longdouble.

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 1489680d98..3a0060b9b2 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -258,6 +258,13 @@ ldbl-extra-routines += err \
 CFLAGS-ieee128-qefgcvt.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute
 CFLAGS-ieee128-qefgcvt_r.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute
 
+# Remove -mlong-double-128 because it does not work correctly with
+# -mabi=ibmlongdoule in some GCC versions, e.g. GCC 7.
+$(foreach o,$(all-object-suffixes),$(objpfx)ieee128-qefgcvt$(o)): \
+  sysdep-CFLAGS := $(filter-out -mlong-double-128, $(sysdep-CFLAGS))
+$(foreach o,$(all-object-suffixes),$(objpfx)ieee128-qefgcvt_r$(o)): \
+  sysdep-CFLAGS := $(filter-out -mlong-double-128, $(sysdep-CFLAGS))
+
 tests-internal += tst-ibm128-warn tst-ieee128-warn
 tests-internal += tst-ibm128-error tst-ieee128-error
 tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt
@@ -334,5 +341,17 @@ 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)))
+
+# Remove -mlong-double-128 because it does not work correctly with
+# -mabi=ibmlongdoule in some GCC versions, e.g. GCC 7.
+$(call obj-suf-foreach,$(ldbl-ibm128-files)): \
+  sysdep-CFLAGS := $(filter-out -mlong-double-128, $(sysdep-CFLAGS))
+
+# Removing -mabi=ieeelongdouble is not required, but helps when
+# analyzing the flags that were passed to the compiler.
+$(call obj-suf-foreach,$(ldbl-ibm128-files)): \
+  sysdep-CFLAGS := $(filter-out -mabi=ieeelongdouble, $(sysdep-CFLAGS))
+
+# Explicitly add -mabi=ibm-long-double to required files.
 $(call obj-suf-foreach,$(ldbl-ibm128-files)): \
   sysdep-CFLAGS += -mabi=ibmlongdouble
-- 
2.21.0

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

* [PATCH 25/31] ldbl-128ibm-compat: Add *cvt functions
  2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (26 preceding siblings ...)
  2019-10-15 19:08 ` [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
@ 2019-10-15 19:08 ` Gabriel F. T. Gomes
  2019-10-15 19:08 ` [PATCH 27/31] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-15 19:08 UTC (permalink / raw)
  To: libc-alpha

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

This patch adds IEEE long double versions of q*cvt* functions for
powerpc64le.  Unlike all other long double to/from string conversion
functions, these do not rely on internal functions that can take
floating-point numbers with different formats and act on them
accordingly, instead, the related files are rebuilt with the
-mabi=ieeelongdouble compiler flag set.

Having -mabi=ieeelongdouble passed to the compiler causes the object
files to be marked with a .gnu_attribute that is incompatible with the
.gnu_attribute in files built with -mabi=ibmlongdouble (the default).
The difference causes error messages similar to the following:

  ld: libc_pic.a(s_isinfl.os) uses IBM long double,
      libc_pic.a(ieee128-qefgcvt_r.os) uses IEEE long double.
  collect2: error: ld returned 1 exit status
  make[2]: *** [../Makerules:649: libc_pic.os] Error 1

Although this warning is useful in other situations, the library
actually needs to have functions with different long double formats, so
.gnu_attribute generation is explicitly disabled for these files with
the use of -mno-gnu-attribute.

Tested for powerpc64le on the branch that actually enables the
sysdeps/ieee754/ldbl-128ibm-compat for powerpc64le.
---
 misc/efgcvt-template.c                        |  6 ++-
 misc/efgcvt_r-template.c                      |  6 ++-
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 12 ++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  6 +++
 .../ldbl-128ibm-compat/ieee128-qefgcvt.c      | 52 +++++++++++++++++++
 .../ldbl-128ibm-compat/ieee128-qefgcvt_r.c    | 34 ++++++++++++
 6 files changed, 113 insertions(+), 3 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c

diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index 7fabdf264d..fe4c28bf0f 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -23,6 +23,10 @@
 #include <libc-lock.h>
 #include <math_ldbl_opt.h>
 
+#ifndef SPRINTF
+# define SPRINTF sprintf
+#endif
+
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
 
@@ -66,6 +70,6 @@ __ECVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign)
 char *
 __GCVT (FLOAT_TYPE value, int ndigit, char *buf)
 {
-  sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
+  SPRINTF (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
   return buf;
 }
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
index 065ecd164c..c08d752cc4 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -25,6 +25,10 @@
 #include <sys/param.h>
 #include <math_ldbl_opt.h>
 
+#ifndef SNPRINTF
+# define SNPRINTF __snprintf
+#endif
+
 
 int
 __FCVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign,
@@ -70,7 +74,7 @@ __FCVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign,
     /* Value is Inf or NaN.  */
     *sign = 0;
 
-  n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX),
+  n = SNPRINTF (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX),
 		  value);
   /* Check for a too small buffer.  */
   if (n >= (ssize_t) len)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index fb7e119de7..3c6314dce8 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -251,10 +251,18 @@ endif
 ifeq ($(subdir),misc)
 ldbl-extra-routines += err \
 		       error \
-		       syslog
+		       syslog \
+		       qefgcvt \
+		       qefgcvt_r
+
+CFLAGS-ieee128-qefgcvt.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute
+CFLAGS-ieee128-qefgcvt_r.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute
 
 tests-internal += tst-ibm128-warn tst-ieee128-warn
 tests-internal += tst-ibm128-error tst-ieee128-error
+tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt
+
+$(objpfx)tst-ieee128-efgcvt: gnulib-tests += $(f128-loader-link)
 
 $(objpfx)tst-ibm128-%.c: tst-ldbl-%.c
 	cp $< $@
@@ -264,9 +272,11 @@ $(objpfx)tst-ieee128-%.c: tst-ldbl-%.c
 
 CFLAGS-tst-ibm128-warn.c += -mabi=ibmlongdouble -Wno-psabi
 CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-tst-ibm128-efgcvt.c += -mabi=ibmlongdouble -Wno-psabi
 
 CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-tst-ieee128-efgcvt.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 
 tests-internal += test-syslog-ieee128 test-syslog-ibm128
 CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index da8e0ce7ee..b4609c99f7 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -224,5 +224,11 @@ libc {
 
     __strfmonieee128;
     __strfmon_lieee128;
+
+    __qecvtieee128;
+    __qfcvtieee128;
+    __qgcvtieee128;
+    __qecvtieee128_r;
+    __qfcvtieee128_r;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c
new file mode 100644
index 0000000000..8402bd358c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c
@@ -0,0 +1,52 @@
+/* IEEE binary128 versions of *cvt 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/>.  */
+
+/* When in IEEE long double mode, call ___ieee128_sprintf.  */
+#include <stdio.h>
+typeof (sprintf) ___ieee128_sprintf attribute_hidden;
+#define SPRINTF ___ieee128_sprintf
+
+/* Declare internal functions: ___qecvtieee128_r and ___qfcvtieee128_r,
+   built from a different compiling unit, and called from here.  */
+#include <stdlib.h>
+typeof (qecvt_r) ___qecvtieee128_r;
+typeof (qfcvt_r) ___qfcvtieee128_r;
+
+/* Rename the static buffers and pointer, otherwise the IEEE long double
+   variants of qecvt and qfcvt would reuse the same buffers and pointer
+   as their non-IEEE long double counterparts.  */
+#define qecvt_buffer qecvtieee128_buffer
+#define qfcvt_buffer qfcvtieee128_buffer
+#define qfcvt_bufptr qfcvtieee128_bufptr
+
+#define ECVT __qecvtieee128
+#define FCVT __qfcvtieee128
+#define GCVT __qgcvtieee128
+#define __ECVT ___qecvtieee128
+#define __FCVT ___qfcvtieee128
+#define __GCVT ___qgcvtieee128
+#define __ECVT_R ___qecvtieee128_r
+#define __FCVT_R ___qfcvtieee128_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt-template.c>
+
+#define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
+cvt_symbol (___qfcvtieee128, __qfcvtieee128);
+cvt_symbol (___qecvtieee128, __qecvtieee128);
+cvt_symbol (___qgcvtieee128, __qgcvtieee128);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c
new file mode 100644
index 0000000000..5eddeff4f5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c
@@ -0,0 +1,34 @@
+/* IEEE binary128 versions of reentrant *cvt_r 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/>.  */
+
+/* When in IEEE long double mode, call ___ieee128_snprintf.  */
+#include <stdio.h>
+typeof (snprintf) ___ieee128_snprintf attribute_hidden;
+#define SNPRINTF ___ieee128_snprintf
+
+#define ECVT_R __qecvtieee128_r
+#define FCVT_R __qfcvtieee128_r
+#define __ECVT_R ___qecvtieee128_r
+#define __FCVT_R ___qfcvtieee128_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt_r-template.c>
+
+#define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
+cvt_symbol (___qfcvtieee128_r, __qfcvtieee128_r);
+cvt_symbol (___qecvtieee128_r, __qecvtieee128_r);
-- 
2.21.0

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

* Re: [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions
  2019-10-15 19:07 ` [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
@ 2019-10-15 20:59   ` Joseph Myers
  2019-10-21  1:51     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 42+ messages in thread
From: Joseph Myers @ 2019-10-15 20:59 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Tue, 15 Oct 2019, Gabriel F. T. Gomes wrote:

> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> I'm using 'syslog (LOG_DEBUG, etc.);' and support_capture_subprocess in
> the test case, which I believe will not print to the console, but I'm
> not sure if changing some system setting to high verbosity will disturb
> people's lives.  Please advise.  :)

You need to avoid sending anything to the real system logs at all in 
syslog tests.  That is, if anything called by the test would end up 
calling the code in openlog_internal that connects to a socket at 
_PATH_LOG, you need a container test and need to ensure some suitable 
setup of _PATH_LOG within the container.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double
  2019-10-15 19:08 ` [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
@ 2019-10-15 21:08   ` Joseph Myers
  2019-10-21  1:50     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 42+ messages in thread
From: Joseph Myers @ 2019-10-15 21:08 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Tue, 15 Oct 2019, Gabriel F. T. Gomes wrote:

> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> On powerpc64le, the libm_alias_float128_other_r_ldbl macro is
> used to create an alias between totalorderf128 and __totalorderlieee128,
> as well as between the totalordermagf128 and __totalordermaglieee128.
> 
> However, the totalorder* and totalordermag* functions changed their
> parameter type since commit ID 42760d764649 and got compat symbols for
> their old versions.  With this change, the aforementioned macro would
> create two conflicting aliases for __totalorderlieee128 and
> __totalordermaglieee128.
> 
> This patch avoids the creation of the alias between the IEEE long double
> symbols (__totalorderl*ieee128) and the compat symbols, because the IEEE
> long double functions have never been exported thus don't need such
> compat symbol.

This needs more explanation (in a comment in the relevant files).  Are you 
saying that libm_alias_float128_other_r_ldbl is presently either unused, 
or used but expanding to empty, in all existing configurations using these 
files (so it's not needed to create any existing compat aliases in any 
configuration that has these functions either for long double or for 
_Float128)?

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 30/31] powerpc64le: Require a compiler with -mno-gnu-attribute
  2019-10-15 19:08 ` [PATCH 30/31] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
@ 2019-10-15 21:11   ` Joseph Myers
  0 siblings, 0 replies; 42+ messages in thread
From: Joseph Myers @ 2019-10-15 21:11 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Tue, 15 Oct 2019, Gabriel F. T. Gomes wrote:

> However, -mno-gnu-attribute is not available in GCC 6, the minimum
> version required to build glibc, so this patch adds a test for this
> feature in powerpc64le builds, and fails early if it's not available.
> 
> Tested, on powerpc64le, that the build fails early with GCC 6 and that
> it succeeds with GCC 7 or greater.

This seems like it needs install.texi (with INSTALL regenerated) and NEWS 
updates to document the increased compiler requirement for building glibc 
for this configuration.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128
  2019-10-15 19:08 ` [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
@ 2019-10-16  3:57   ` Florian Weimer
  2019-10-21  1:49     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 42+ messages in thread
From: Florian Weimer @ 2019-10-16  3:57 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

* Gabriel F. T. Gomes:

> From: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
>
> On platforms where long double has IEEE binary128 format as a third
> option (initially, only powerpc64le), many exported functions are
> redirected to their __*ieee128 equivalents.  This redirection is
> provided by installed headers such as stdio-ldbl.h, and is supposed to
> work correctly with user code.
>
> However, during the build of glibc, similar redirections are employed,
> in internal headers such as include/stdio.h, in order to avoid extra PLT
> entries.  These redirections conflict with the redirections to
> __*ieee128, and must be avoided during the build.  This patch protects
> the second redirections with a test for __LONG_DOUBLE_USES_FLOAT128.

Why don't we see this problem with the existing dual ABIs for long
double?

> diff --git a/include/stdio.h b/include/stdio.h
> index bea2066cd1..8ec801c989 100644
> --- a/include/stdio.h
> +++ b/include/stdio.h
> @@ -13,7 +13,10 @@ extern int __fcloseall (void) attribute_hidden;
>  extern int __snprintf (char *__restrict __s, size_t __maxlen,
>  		       const char *__restrict __format, ...)
>       __attribute__ ((__format__ (__printf__, 3, 4)));
> +#  if !defined __LONG_DOUBLE_USES_FLOAT128 \
> +  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
>  libc_hidden_proto (__snprintf)
> +#  endif
>  extern int __vfscanf (FILE *__restrict __s,
>  		      const char *__restrict __format,
>  		      __gnuc_va_list __arg)

This leads to a build failure on most architectures because
__LONG_DOUBLE_USES_FLOAT128 is not defined at this point.

(I tried the gabriel/powerpc-ieee128-printscan branch at commit
1c4f7fffc4f1cc186906dd47812e725e51bb036a.)

Thanks,
Florian

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

* Re: [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128
  2019-10-16  3:57   ` Florian Weimer
@ 2019-10-21  1:49     ` Gabriel F. T. Gomes
  2019-10-21 10:13       ` Florian Weimer
  0 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-21  1:49 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha

Hi, Florian,

On Wed, 16 Oct 2019, Florian Weimer wrote:

>Why don't we see this problem with the existing dual ABIs for long
>double?

That would be because, on the previous transition (from long double being
the same as double to long double with some other, whatever format), the
old format was the same as double, which meant that no files had to be
compiled in the old mode (-mlong-double-64).  The [at-the-time-]new compat
symbols got created during the compilation of the double-typed functions,
which could be built with -mlong-double-128.

For the new ABI, we rely on a lot of builds with -mlong-double-128 and
-mfloat128, which work fine without this patch.  However, we need a couple
of builds in -mabi=ieeelongdouble mode, and the use of this flag causes
build errors such as these:

  In file included from ../sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c:20:
  ../include/stdio.h:174:1: error: asm declaration ignored due to conflict with previous rename [-Werror=pragmas]
    174 | libc_hidden_proto (dprintf)
        | ^~~~~~~~~~~~~~~~~
  ../include/stdio.h:178:1: error: asm declaration ignored due to conflict with previous rename [-Werror=pragmas]
    178 | libc_hidden_proto (fprintf)
        | ^~~~~~~~~~~~~~~~~
  ../include/stdio.h:179:1: error: asm declaration ignored due to conflict with previous rename [-Werror=pragmas]
    179 | libc_hidden_proto (vfprintf)
        | ^~~~~~~~~~~~~~~~~
  ../include/stdio.h:180:1: error: asm declaration ignored due to conflict with previous rename [-Werror=pragmas]
    180 | libc_hidden_proto (sprintf)
        | ^~~~~~~~~~~~~~~~~
  cc1: all warnings being treated as errors
  make[2]: *** [/home/gabriel/build/powerpc64le/glibc/sysd-rules:1663: /home/gabriel/build/powerpc64le/glibc/misc/ieee128-qefgcvt.os] Error 1
  make[2]: Leaving directory '/home/gabriel/src/glibc/misc'

When we started working on this effort, we went on a path that led to a
lot more files being built with -mabi=ieeelongdouble, now it's just cvt*
functions, really.  So I'm updating this patch to touch less files.

>> +#  if !defined __LONG_DOUBLE_USES_FLOAT128 \
>> +  || (defined __LONG_DOUBLE_USES_FLOAT128 && __LONG_DOUBLE_USES_FLOAT128 == 0)
>>  libc_hidden_proto (__snprintf)
>> +#  endif
>>  extern int __vfscanf (FILE *__restrict __s,
>>  		      const char *__restrict __format,
>>  		      __gnuc_va_list __arg)  
>
>This leads to a build failure on most architectures because
>__LONG_DOUBLE_USES_FLOAT128 is not defined at this point.
>
>(I tried the gabriel/powerpc-ieee128-printscan branch at commit
>1c4f7fffc4f1cc186906dd47812e725e51bb036a.)

I'm sorry.  It is perfectly reasonable that I should have tested it on
other platforms before sending this patchset.  I'm fixing this and testing
on more platforms using build-many-glibcs.py (using b-m-g sent me on a
search for *other* problems with the patchset, so thanks for testing the
branch, much appreciated :).

The actual snippet that causes the problem is the following:

>@@ -72,7 +75,8 @@ libc_hidden_proto (__isoc99_vfscanf)
>    Unfortunately, symbol redirection is not transitive, so the
>    __REDIRECT in the public header does not link up with the above
>    libc_hidden_proto.  Bridge the gap with a macro.  */
>-#  if !__GLIBC_USE (DEPRECATED_SCANF)
>+#  if !__GLIBC_USE (DEPRECATED_SCANF) \
>+      && __LONG_DOUBLE_USES_FLOAT128 == 0
> #   undef sscanf
> #   define sscanf __isoc99_sscanf
> #  endif

It's missing the check for __LONG_DOUBLE_USES_FLOAT128 being defined.  I
have locally changed this to a check for the macro being defined, then for
a value (which solves the problem according to b-m-g), but I'm wondering if
I should switch to defining it to 0 (zero) on all other long-double.h
files (for all platforms), thus avoiding the problems with undefined
macros [1].  Do you have an opinion on that?

I'll send a v2, soon.

[1] https://sourceware.org/glibc/wiki/Wundef

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

* Re: [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double
  2019-10-15 21:08   ` Joseph Myers
@ 2019-10-21  1:50     ` Gabriel F. T. Gomes
  2019-10-21 14:59       ` Joseph Myers
  0 siblings, 1 reply; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-21  1:50 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

Hi, Joseph,

On Tue, 15 Oct 2019, Joseph Myers wrote:

>This needs more explanation (in a comment in the relevant files).

How about the following paragraph?

  /* On platforms that reuse the _Float128 implementation for IEEE long
     double (powerpc64le), the libm_alias_float128_other_r_ldbl macro
     (which is called by the libm_alias_ldouble macro) is used to create
     aliases between *f128 (_Float128 API) and __*ieee128 functions.
     However, this compat version of totalorderl is older than the
     availability of __ieee*128 symbols, thus, the compat alias is not
     required, nor desired.  */
  #undef libm_alias_float128_other_r_ldbl
  #define libm_alias_float128_other_r_ldbl(from, to, r)

Likewise for totalordermagl.

>Are you 
>saying that libm_alias_float128_other_r_ldbl is presently either unused, 
>or used but expanding to empty, in all existing configurations using these 
>files (so it's not needed to create any existing compat aliases in any 
>configuration that has these functions either for long double or for 
>_Float128)?

Currently, these macros are not used, because they are only defined on
sysdeps/ieee754/ldbl-128ibm-compat/libm-alias-float128.h, but
ldbl-128ibm-compat is not yet on the Implies files for powerpc64le.

No other platform has ldbl-128ibm-compat on their Implies files, so this
macro is not needed to create the existing compat aliases you mentioned
above (between parentheses), anywhere.  Also, on powerpc64le, the _Float128
aliases for the compat functions are still provided, even after this patch
and after adding ldbl-128ibm-compat to their Implies...  The _Float128
aliases get created by the libm_alias_float128_r macro, before it expands
libm_alias_float128_other_r_ldbl, whereas the __*ieee128 aliases get
created by libm_alias_float128_other_r_ldbl itself.

(it was a bit hard to find the words to write this answer and to
streamline it, let me know if it's confusing (or wrong, of course)).

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

* Re: [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions
  2019-10-15 20:59   ` Joseph Myers
@ 2019-10-21  1:51     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-21  1:51 UTC (permalink / raw)
  To: Joseph Myers; +Cc: libc-alpha

On Tue, 15 Oct 2019, Joseph Myers wrote:

>You need to avoid sending anything to the real system logs at all in 
>syslog tests.  That is, if anything called by the test would end up 
>calling the code in openlog_internal that connects to a socket at 
>_PATH_LOG, you need a container test and need to ensure some suitable 
>setup of _PATH_LOG within the container.

Thanks, Joseph.  I'm working on this for v2.

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

* Re: [PATCH 19/31] Remove hidden_def and hidden_proto from cvt functions
  2019-10-15 19:07 ` [PATCH 19/31] Remove hidden_def and hidden_proto from cvt functions Gabriel F. T. Gomes
@ 2019-10-21  1:55   ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 42+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-21  1:55 UTC (permalink / raw)
  To: libc-alpha

On Tue, 15 Oct 2019, Gabriel F. T. Gomes wrote:
>
>Some *cvt functions are not called from within libc, yet they use
>hidden_def and hidden_proto.  This patch cleans this up and adds
>attribute_hidden to the declarations, for architectures that need it.

As I mentioned on a reply to Florian, I tested this patchset with
build-many-glibcs.py and I found another error (besides the one that
Florian pointed out).  The error is caused by this patch (on at least
s390x and alpha), but the patch is actually not needed, at all. :/

I'll send v2 without it and adapted for its absence. :)

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

* Re: [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128
  2019-10-21  1:49     ` Gabriel F. T. Gomes
@ 2019-10-21 10:13       ` Florian Weimer
  0 siblings, 0 replies; 42+ messages in thread
From: Florian Weimer @ 2019-10-21 10:13 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

* Gabriel F. T. Gomes:

> It's missing the check for __LONG_DOUBLE_USES_FLOAT128 being defined.  I
> have locally changed this to a check for the macro being defined, then for
> a value (which solves the problem according to b-m-g), but I'm wondering if
> I should switch to defining it to 0 (zero) on all other long-double.h
> files (for all platforms), thus avoiding the problems with undefined
> macros [1].  Do you have an opinion on that?

Defining it everywhere is currently what we prefer.  We have many
exceptions (SHARED, the __ASSUME_* macros), but they are supposed to bhe
historic.

Thanks,
Florian

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

* Re: [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double
  2019-10-21  1:50     ` Gabriel F. T. Gomes
@ 2019-10-21 14:59       ` Joseph Myers
  0 siblings, 0 replies; 42+ messages in thread
From: Joseph Myers @ 2019-10-21 14:59 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

On Sun, 20 Oct 2019, Gabriel F. T. Gomes wrote:

> Hi, Joseph,
> 
> On Tue, 15 Oct 2019, Joseph Myers wrote:
> 
> >This needs more explanation (in a comment in the relevant files).
> 
> How about the following paragraph?
> 
>   /* On platforms that reuse the _Float128 implementation for IEEE long
>      double (powerpc64le), the libm_alias_float128_other_r_ldbl macro
>      (which is called by the libm_alias_ldouble macro) is used to create
>      aliases between *f128 (_Float128 API) and __*ieee128 functions.
>      However, this compat version of totalorderl is older than the
>      availability of __ieee*128 symbols, thus, the compat alias is not
>      required, nor desired.  */
>   #undef libm_alias_float128_other_r_ldbl
>   #define libm_alias_float128_other_r_ldbl(from, to, r)

Yes, that seems reasonable.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

end of thread, other threads:[~2019-10-21 14:59 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-15 19:05 [PATCH 00/31] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
2019-10-15 19:05 ` [PATCH 02/31] ldbl-128ibm-compat: Add wide character printing functions Gabriel F. T. Gomes
2019-10-15 19:05 ` [PATCH 01/31] ldbl-128ibm-compat: Add regular " Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 04/31] ldbl-128ibm-compat: Add wide character, fortified " Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 08/31] ldbl-128ibm-compat: Add wide character scanning functions Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 12/31] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 07/31] ldbl-128ibm-compat: Add regular character scanning functions Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 11/31] ldbl-128ibm-compat: Add error.h functions Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 06/31] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 10/31] ldbl-128ibm-compat: Add err.h functions Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 05/31] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
2019-10-15 19:06 ` [PATCH 03/31] ldbl-128ibm-compat: Add regular character, fortified printing functions Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 14/31] ldbl-128ibm-compat: Add obstack " Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 13/31] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 19/31] Remove hidden_def and hidden_proto from cvt functions Gabriel F. T. Gomes
2019-10-21  1:55   ` Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 09/31] ldbl-128ibm-compat: Add argp_error and argp_failure Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 15/31] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
2019-10-15 20:59   ` Joseph Myers
2019-10-21  1:51     ` Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 18/31] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 22/31] Refactor *cvt functions implementation (3/5) Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 21/31] Refactor *cvt functions implementation (2/5) Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 16/31] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 23/31] Refactor *cvt functions implementation (4/5) Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 17/31] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Gabriel F. T. Gomes
2019-10-15 19:07 ` [PATCH 20/31] Refactor *cvt functions implementation (1/5) Gabriel F. T. Gomes
2019-10-15 19:08 ` [PATCH 24/31] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
2019-10-15 19:08 ` [PATCH 28/31] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
2019-10-15 21:08   ` Joseph Myers
2019-10-21  1:50     ` Gabriel F. T. Gomes
2019-10-21 14:59       ` Joseph Myers
2019-10-15 19:08 ` [PATCH 29/31] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
2019-10-15 19:08 ` [PATCH 26/31] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
2019-10-16  3:57   ` Florian Weimer
2019-10-21  1:49     ` Gabriel F. T. Gomes
2019-10-21 10:13       ` Florian Weimer
2019-10-15 19:08 ` [PATCH 25/31] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
2019-10-15 19:08 ` [PATCH 27/31] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
2019-10-15 19:08 ` [PATCH 30/31] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
2019-10-15 21:11   ` Joseph Myers
2019-10-15 19:08 ` [PATCH 31/31] RFC: powerpc64le: Enable support for IEEE long double 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).