unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le
@ 2019-12-03 17:05 Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf Gabriel F. T. Gomes
                   ` (10 more replies)
  0 siblings, 11 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

Changes since v2:

  - 'Changes since v2' messages in each of the patches;
  - Patch 1/11 is new;
  - Branch updated at our git server [1].

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

Message for v2:

'Changes since v1' messages in each of the patches, except for patch v1
19/31, which has been dropped.  The updated tree can be found in the
repository [1] (commit ID d9fa17b4597a).

This patch set has been tested on powerpc64le, x86_64, and with
build-many-glibcs.py (sorry for not using b-m-g previously).

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

Message for v1:

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 (9):
  ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  Refactor *cvt functions implementation (1-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

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

 INSTALL                                       |   5 +
 NEWS                                          |   2 +-
 argp/argp.h                                   |   3 +-
 bits/long-double.h                            |   1 +
 include/stdio.h                               |  11 +-
 include/stdlib.h                              |   3 +
 libio/bits/stdio-ldbl.h                       |  46 ++--
 libio/stdio.h                                 |  16 +-
 manual/install.texi                           |   5 +
 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                                 | 124 ++-------
 misc/efgcvt_r-template.c                      | 198 ++++++++++++++
 misc/efgcvt_r.c                               | 251 +-----------------
 misc/err.h                                    |   3 +-
 misc/error.h                                  |   6 +-
 misc/qefgcvt.c                                |  43 ++-
 misc/qefgcvt_r.c                              |  50 ++--
 misc/sys/cdefs.h                              |  38 ++-
 misc/sys/syslog.h                             |   4 +-
 stdio-common/printf.h                         |   3 +-
 stdlib/bits/stdlib-ldbl.h                     |  22 ++
 stdlib/monetary.h                             |   3 +-
 stdlib/stdlib.h                               |   4 +-
 sysdeps/ieee754/ldbl-128/bits/long-double.h   |   1 +
 sysdeps/ieee754/ldbl-128/s_totalorderl.c      |   9 +
 sysdeps/ieee754/ldbl-128/s_totalordermagl.c   |   9 +
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  97 ++++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  22 ++
 .../ldbl-128ibm-compat/bits/long-double.h     |  29 ++
 .../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-qefgcvt.c      |  52 ++++
 .../ldbl-128ibm-compat/ieee128-qefgcvt_r.c    |  34 +++
 .../test-isoc99-scanf-ibm128.c                |   1 +
 .../test-isoc99-scanf-ieee128.c               |   1 +
 .../test-isoc99-wscanf-ibm128.c               |   1 +
 .../test-isoc99-wscanf-ieee128.c              |   1 +
 .../test-scanf-ldbl-compat-template.c         |  73 +++--
 .../test-scanf-ldbl-compat.c                  |   7 +-
 .../test-scanf-ldbl-compat.sh                 |  16 +-
 .../test-wscanf-ldbl-compat.c                 |   7 +-
 sysdeps/ieee754/ldbl-96/bits/long-double.h    |   1 +
 sysdeps/ieee754/ldbl-opt/bits/long-double.h   |   1 +
 sysdeps/mips/ieee754/bits/long-double.h       |   1 +
 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 ++++++++
 .../linux/sparc/sparc32/bits/long-double.h    |   1 +
 .../linux/sparc/sparc64/bits/long-double.h    |   1 +
 wcsmbs/bits/wchar-ldbl.h                      |  36 ++-
 wcsmbs/wchar.h                                |  14 +-
 67 files changed, 1594 insertions(+), 491 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 sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h
 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-qefgcvt.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.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-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h

-- 
2.21.0


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

* [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-09 16:45   ` Paul E Murphy
  2019-12-03 17:05 ` [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

New since v2.

-- 8< --
Since commit

commit 03992356e6fedc5a5e9d32df96c1a2c79ea28a8f
Author: Zack Weinberg <zackw@panix.com>
Date:   Sat Feb 10 11:58:35 2018 -0500

    Use C99-compliant scanf under _GNU_SOURCE with modern compilers.

the selection of the GNU versions of scanf functions requires both
_GNU_SOURCE and -std=c89.  This patch changes the tests in
ldbl-128ibm-compat so that they actually test the GNU versions (without
this change, the redirection to the ISO C99 version always happens, so
GNU versions of the new implementation (e.g. __scanfieee128) were left
untested).

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile               | 8 ++++----
 .../ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c   | 4 ++++
 .../ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c  | 4 ++++
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index b54eb04f22..21332bfbbb 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -75,14 +75,14 @@ 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
+CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c89 -D_GNU_SOURCE
+CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c89 -D_GNU_SOURCE
 
 $(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
+CFLAGS-test-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c89 -D_GNU_SOURCE
+CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c89 -D_GNU_SOURCE
 
 $(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link)
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
index 0759d8afab..116808dffd 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
@@ -1,3 +1,7 @@
+/* Include stdio.h from libio/, because include/stdio.h and -std=c89 do
+   not work together.  */
+#include <libio/stdio.h>
+
 #define CHAR char
 #define L(x) x
 #define FSCANF fscanf
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
index e93cf3b9bd..4b8fd1b442 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
@@ -1,3 +1,7 @@
+/* Include stdio.h from libio/, because include/stdio.h and -std=c89 do
+   not work together.  */
+#include <libio/stdio.h>
+
 #define CHAR wchar_t
 #define L(x) L##x
 #define FSCANF fwscanf
-- 
2.21.0


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

* [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-09 18:09   ` Paul E Murphy
  2019-12-03 17:05 ` [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5) Gabriel F. T. Gomes
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

Changes since v2:

  - Removed ugly hacks after rebase against commit ID 93486ba583ec.
  - Updated copyright years.
  - Unified test case for GNU and ISO C99 versions (got rid of many
    files in the process, including the new test template for C99).
  - Fixed http URLs.
  - Updated commit message.

No changes since v1.

-- 8< --
In the format string for *scanf functions, the '%as', '%aS', and '%a[]'
modifiers behave differently depending on ISO C99 compatibility.  When
_GNU_SOURCE is defined and -std=c89 is passed to the compiler, these
functions behave like ascanf, and the modifiers allocate memory for the
output.  Otherwise, the ISO C99 compliant version of these functions is
used, and the modifiers consume a floating-point argument.  This patch
adds the IEEE binary128 variant of ISO C99 compliant functions for the
third long double format on powerpc64le.

Tested for powerpc64le.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 57 ++++++++++++++-
 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                |  1 +
 .../test-isoc99-scanf-ieee128.c               |  1 +
 .../test-isoc99-wscanf-ibm128.c               |  1 +
 .../test-isoc99-wscanf-ieee128.c              |  1 +
 .../test-scanf-ldbl-compat-template.c         | 73 ++++++++++++-------
 .../test-scanf-ldbl-compat.c                  |  3 +-
 .../test-scanf-ldbl-compat.sh                 | 16 ++--
 .../test-wscanf-ldbl-compat.c                 |  3 +-
 22 files changed, 522 insertions(+), 39 deletions(-)
 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-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 21332bfbbb..6d5414c54a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -7,6 +7,13 @@ ldbl-extra-routines += fwscanf \
 endif
 
 ifeq ($(subdir),wcsmbs)
+ldbl-extra-routines += isoc99_fwscanf \
+		       isoc99_swscanf \
+		       isoc99_wscanf \
+		       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
@@ -43,7 +50,13 @@ ldbl-extra-routines += printf_size \
 		       vfwscanf \
 		       obprintf \
 		       obstack_chk \
-		       vobstack_chk
+		       vobstack_chk \
+		       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,
@@ -86,12 +99,30 @@ CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c89 -D_GNU_SO
 
 $(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: \
@@ -118,6 +149,30 @@ $(objpfx)test-wscanf-ibm128.out: \
 	$(SHELL) $^ '$(test-program-prefix)' $@; \
 	$(evaluate-test)
 
+$(objpfx)test-isoc99-scanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-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-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-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-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 1a774de76a..da8e0ce7ee 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -191,6 +191,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..fd086133c3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_fscanf.  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
+   <https://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..8d5ef810de
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_fwscanf.  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
+   <https://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..87c9416232
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_scanf.  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
+   <https://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..93be2f41cb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c
@@ -0,0 +1,39 @@
+/* Wrapper for __isoc99_sscanf.  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
+   <https://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..da48f7e0e1
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c
@@ -0,0 +1,40 @@
+/* Wrapper for __isoc99_swscanf.  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
+   <https://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..00a018cd66
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vfscanf.  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
+   <https://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..6c1fbe7d65
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vfwscanf.  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
+   <https://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..fa0b901fe3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vscanf.  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
+   <https://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..bd59419018
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c
@@ -0,0 +1,30 @@
+/* Wrapper for __isoc99_vsscanf.  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
+   <https://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..875ea1cfea
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c
@@ -0,0 +1,32 @@
+/* Wrapper for __isoc99_vswscanf.  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
+   <https://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..3bda9b314d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for __isoc99_vwscanf.  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
+   <https://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..734b0f13d8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for __isoc99_wscanf.  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
+   <https://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..8cdee601f2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
@@ -0,0 +1 @@
+#include <test-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..8cdee601f2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
@@ -0,0 +1 @@
+#include <test-scanf-ldbl-compat.c>
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..ef21fc4741
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
@@ -0,0 +1 @@
+#include <test-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..ef21fc4741
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
@@ -0,0 +1 @@
+#include <test-wscanf-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
index 3dbed79b68..9bdf6daa0b 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
@@ -24,92 +24,109 @@
 
 #include <support/check.h>
 
-#define CLEAR								\
+#define CLEAR_VARGS							\
   va_start (args, format);						\
-  ld = va_arg (args, long double *);					\
-  *ld = 0;								\
+  ldptr = va_arg (args, long double *);					\
+  fptr = va_arg (args, float *);					\
+  *ldptr = 0;								\
+  *fptr = 0;								\
   va_end (args);
 
-#define CLEAR_VALUE value = 0;
-
-#define CHECK								\
+#define CHECK_VARGS							\
   va_start (args, format);						\
-  ld = va_arg (args, long double *);					\
+  ldptr = va_arg (args, long double *);					\
+  fptr = va_arg (args, float *);					\
   va_end (args);							\
-  if (*ld == -1.0L)							\
+  if (*ldptr == -1 && *fptr == -2)					\
     printf ("OK");							\
   else									\
-    printf ("ERROR (%.60Lf)", *ld);					\
+    printf ("ERROR (%Lf %f)", *ldptr, *fptr);				\
   printf ("\n");
 
+#define CLEAR_VALUE							\
+  ld = 0;								\
+  f = 0;
+
 #define CHECK_VALUE							\
-  if (value == -1.0L)							\
+  if (ld == -1 && f == -2)						\
     printf ("OK");							\
   else									\
-    printf ("ERROR (%.60Lf)", value);					\
+    printf ("ERROR (%Lf %f)", ld, f);					\
   printf ("\n");
 
 static void
 do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
 {
-  long double value;
-  long double *ld;
+  float f;
+  long double ld;
+  float *fptr;
+  long double *ldptr;
   va_list args;
 
   CLEAR_VALUE
   printf ("fscanf: ");
-  FSCANF (stream, format, &value);
+  FSCANF (stream, format, &ld, &f);
   CHECK_VALUE
 
   CLEAR_VALUE
   printf ("scanf: ");
-  SCANF (format, &value);
+  SCANF (format, &ld, &f);
   CHECK_VALUE
 
   CLEAR_VALUE
   printf ("sscanf: ");
-  SSCANF (string, format, &value);
+  SSCANF (string, format, &ld, &f);
   CHECK_VALUE
 
-  CLEAR
+  CLEAR_VARGS
   printf ("vfscanf: ");
   va_start (args, format);
   VFSCANF (stream, format, args);
   va_end (args);
-  CHECK
+  CHECK_VARGS
 
-  CLEAR
+  CLEAR_VARGS
   printf ("vscanf: ");
   va_start (args, format);
   VSCANF (format, args);
   va_end (args);
-  CHECK
+  CHECK_VARGS
 
-  CLEAR
+  CLEAR_VARGS
   printf ("vsscanf: ");
   va_start (args, format);
   VSSCANF (string, format, args);
   va_end (args);
-  CHECK
+  CHECK_VARGS
 }
 
 static int
 do_test (void)
 {
   CHAR string[256];
+  float f;
   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);
+	  L ("-1.0 -2.0\n")
+	  L ("-1.0 -2.0\n") );
+  do_test_call (stdin, string, L("%Lf %f"), &ld, &f);
 
   /* Scan in hexadecimal notation.  */
   STRCPY (string,
-	  L ("-0x1.0p+0\n")
-	  L ("-0x1.0p+0\n") );
-  do_test_call (stdin, string, L("%La"), &ld);
+	  L ("-0x1.0p+0 -0x2.0p+0\n")
+	  L ("-0x1.0p+0 -0x2.0p+0\n") );
+  /* For ISO C99, scan the single-precision value with "%as" to test
+     that __isoc99_*scanf ignores the 's'.  For DEPRECATED_SCANF, do not
+     use "%as", because that would try to scan a string and allocate
+     space for it.  */
+#if __GLIBC_USE (DEPRECATED_SCANF)
+# define FMT "%La %a"
+#else
+# define FMT "%La %as"
+#endif
+  do_test_call (stdin, string, L(FMT), &ld, &f);
 
   return 0;
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
index 116808dffd..e25652c963 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
@@ -3,7 +3,8 @@
 #include <libio/stdio.h>
 
 #define CHAR char
-#define L(x) x
+#define Lx(x) x
+#define L(x) Lx (x)
 #define FSCANF fscanf
 #define SSCANF sscanf
 #define SCANF scanf
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
index 908c346ac8..e022120c8e 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
@@ -26,14 +26,14 @@ 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
+-0x1.0p+0 -0x2.0p+0
+-0x1.0p+0 -0x2.0p+0
+-0x1.0p+0 -0x2.0p+0
+-0x1.0p+0 -0x2.0p+0
+-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} \
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
index 4b8fd1b442..b8152aa2f2 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
@@ -3,7 +3,8 @@
 #include <libio/stdio.h>
 
 #define CHAR wchar_t
-#define L(x) L##x
+#define Lx(x) L##x
+#define L(x) Lx (x)
 #define FSCANF fwscanf
 #define SSCANF swscanf
 #define SCANF wscanf
-- 
2.21.0


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

* [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5)
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-09 21:25   ` Paul E Murphy
  2019-12-03 17:05 ` [PATCH v3 04/11] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

Changes since v2:

  - Squashed patches 1-4 and trivial bits of patch 5.
  - Replaced http with https (like the rest of glibc).
  - Updated copyright years.
  - Removed refactoring noise reported by Paul Murphy.

No changes since v1.

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

Below, the commit message to be used after the squashing...

-- 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.

Tested for powerpc64le and with build-many-glibcs.

Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>
---
 misc/efgcvt-dbl-macros.h  |  52 +++++++++
 misc/efgcvt-ldbl-macros.h |  59 ++++++++++
 misc/efgcvt-template.c    |  76 +++++++++++++
 misc/efgcvt.c             | 100 +---------------
 misc/efgcvt_r-template.c  | 194 +++++++++++++++++++++++++++++++
 misc/efgcvt_r.c           | 233 +-------------------------------------
 misc/qefgcvt.c            |  37 ++----
 misc/qefgcvt_r.c          |  50 +++-----
 8 files changed, 412 insertions(+), 389 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

diff --git a/misc/efgcvt-dbl-macros.h b/misc/efgcvt-dbl-macros.h
new file mode 100644
index 0000000000..17e01e77e3
--- /dev/null
+++ b/misc/efgcvt-dbl-macros.h
@@ -0,0 +1,52 @@
+/* Macros for the implementation of *cvt functions, double version.
+   Copyright (C) 1995-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
+   <https://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-ldbl-macros.h b/misc/efgcvt-ldbl-macros.h
new file mode 100644
index 0000000000..38470d93ab
--- /dev/null
+++ b/misc/efgcvt-ldbl-macros.h
@@ -0,0 +1,59 @@
+/* Macros for the implementation of *cvt functions, long double version.
+   Copyright (C) 1996-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
+   <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
+/* 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/efgcvt-template.c b/misc/efgcvt-template.c
new file mode 100644
index 0000000000..5eea9f6370
--- /dev/null
+++ b/misc/efgcvt-template.c
@@ -0,0 +1,76 @@
+/* Compatibility functions for floating point formatting.
+   Copyright (C) 1995-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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <libc-lock.h>
+#include <math_ldbl_opt.h>
+
+#define APPEND(a, b) APPEND2 (a, b)
+#define APPEND2(a, b) a##b
+
+
+#define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer)
+#define FCVT_BUFPTR APPEND (FUNC_PREFIX, fcvt_bufptr)
+#define ECVT_BUFFER APPEND (FUNC_PREFIX, ecvt_buffer)
+
+
+static char FCVT_BUFFER[MAXDIG];
+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)
+{
+  if (FCVT_BUFPTR == NULL)
+    {
+      if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
+					  FCVT_BUFFER, MAXDIG) != -1)
+	return FCVT_BUFFER;
+
+      FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG);
+      if (FCVT_BUFPTR == NULL)
+	return FCVT_BUFFER;
+    }
+
+  (void) __APPEND (FUNC_PREFIX, 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)
+{
+  (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
+					 ECVT_BUFFER, MAXDIG);
+
+  return ECVT_BUFFER;
+}
+
+char *
+__APPEND (FUNC_PREFIX, 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 492e4e8086..deb975b3ce 100644
--- a/misc/efgcvt.c
+++ b/misc/efgcvt.c
@@ -1,4 +1,4 @@
-/* Compatibility functions for floating point formatting.
+/* Double versions of *cvt_r functions.
    Copyright (C) 1995-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,107 +16,13 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <math.h>
-#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)
-#define __APPEND2(a, b) __##a##b
-
-
-#define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer)
-#define FCVT_BUFPTR APPEND (FUNC_PREFIX, fcvt_bufptr)
-#define ECVT_BUFFER APPEND (FUNC_PREFIX, ecvt_buffer)
-
-
-static char FCVT_BUFFER[MAXDIG];
-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)
-{
-  if (FCVT_BUFPTR == NULL)
-    {
-      if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
-					  FCVT_BUFFER, MAXDIG) != -1)
-	return FCVT_BUFFER;
-
-      FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG);
-      if (FCVT_BUFPTR == NULL)
-	return FCVT_BUFFER;
-    }
-
-  (void) __APPEND (FUNC_PREFIX, 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)
-{
-  (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
-					 ECVT_BUFFER, MAXDIG);
-
-  return ECVT_BUFFER;
-}
-
-char *
-__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) \
+# 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) \
+# 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))
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
new file mode 100644
index 0000000000..04457cd910
--- /dev/null
+++ b/misc/efgcvt_r-template.c
@@ -0,0 +1,194 @@
+/* Compatibility functions for floating point formatting, reentrant versions.
+   Copyright (C) 1995-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
+   <https://www.gnu.org/licenses/>.  */
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <math.h>
+#include <stdlib.h>
+#include <sys/param.h>
+#include <math_ldbl_opt.h>
+
+
+#define APPEND(a, b) APPEND2 (a, b)
+#define APPEND2(a, b) a##b
+
+int
+__APPEND (FUNC_PREFIX, fcvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
+				int *sign, char *buf, size_t len)
+{
+  ssize_t n;
+  ssize_t i;
+  int left;
+
+  if (buf == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  left = 0;
+  if (isfinite (value))
+    {
+      *sign = signbit (value) != 0;
+      if (*sign)
+	value = -value;
+
+      if (ndigit < 0)
+	{
+	  /* Rounding to the left of the decimal point.  */
+	  while (ndigit < 0)
+	    {
+	      FLOAT_TYPE new_value = value * 0.1;
+
+	      if (new_value < 1.0)
+		{
+		  ndigit = 0;
+		  break;
+		}
+
+	      value = new_value;
+	      ++left;
+	      ++ndigit;
+	    }
+	}
+    }
+  else
+    /* Value is Inf or NaN.  */
+    *sign = 0;
+
+  n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX),
+		  value);
+  /* Check for a too small buffer.  */
+  if (n >= (ssize_t) len)
+    return -1;
+
+  i = 0;
+  while (i < n && isdigit (buf[i]))
+    ++i;
+  *decpt = i;
+
+  if (i == 0)
+    /* Value is Inf or NaN.  */
+    return 0;
+
+  if (i < n)
+    {
+      do
+	++i;
+      while (i < n && !isdigit (buf[i]));
+
+      if (*decpt == 1 && buf[0] == '0' && value != 0.0)
+	{
+	  /* We must not have leading zeroes.  Strip them all out and
+	     adjust *DECPT if necessary.  */
+	  --*decpt;
+	  while (i < n && buf[i] == '0')
+	    {
+	      --*decpt;
+	      ++i;
+	    }
+	}
+
+      memmove (&buf[MAX (*decpt, 0)], &buf[i], n - i);
+      buf[n - (i - MAX (*decpt, 0))] = '\0';
+    }
+
+  if (left)
+    {
+      *decpt += left;
+      if ((ssize_t) --len > n)
+	{
+	  while (left-- > 0 && n < (ssize_t) len)
+	    buf[n++] = '0';
+	  buf[n] = '\0';
+	}
+    }
+
+  return 0;
+}
+
+int
+__APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
+				int *sign, char *buf, size_t len)
+{
+  int exponent = 0;
+
+  if (isfinite (value) && value != 0.0)
+    {
+      /* Slow code that doesn't require -lm functions.  */
+      FLOAT_TYPE d;
+      FLOAT_TYPE f = 1.0;
+      if (value < 0.0)
+	d = -value;
+      else
+	d = value;
+      /* For denormalized numbers the d < 1.0 case below won't work,
+	 as f can overflow to +Inf.  */
+      if (d < FLOAT_MIN_10_NORM)
+	{
+	  value /= FLOAT_MIN_10_NORM;
+	  if (value < 0.0)
+	    d = -value;
+	  else
+	    d = value;
+	  exponent += FLOAT_MIN_10_EXP;
+	}
+      if (d < 1.0)
+	{
+	  do
+	    {
+	      f *= 10.0;
+	      --exponent;
+	    }
+	  while (d * f < 1.0);
+
+	  value *= f;
+	}
+      else if (d >= 10.0)
+	{
+	  do
+	    {
+	      f *= 10;
+	      ++exponent;
+	    }
+	  while (d >= f * 10.0);
+
+	  value /= f;
+	}
+    }
+  else if (value == 0.0)
+    /* SUSv2 leaves it unspecified whether *DECPT is 0 or 1 for 0.0.
+       This could be changed to -1 if we want to return 0.  */
+    exponent = 0;
+
+  if (ndigit <= 0 && len > 0)
+    {
+      buf[0] = '\0';
+      *decpt = 1;
+      *sign = isfinite (value) ? signbit (value) != 0 : 0;
+    }
+  else
+    if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
+					decpt, sign, buf, len))
+      return -1;
+
+  *decpt += exponent;
+  return 0;
+}
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 981249850c..a9ea569299 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -1,4 +1,4 @@
-/* Compatibility functions for floating point formatting, reentrant versions.
+/* Double versions of reentrant *cvt_r functions.
    Copyright (C) 1995-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,241 +16,14 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <float.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <math.h>
-#include <stdlib.h>
-#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
-#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)
-{
-  ssize_t n;
-  ssize_t i;
-  int left;
-
-  if (buf == NULL)
-    {
-      __set_errno (EINVAL);
-      return -1;
-    }
-
-  left = 0;
-  if (isfinite (value))
-    {
-      *sign = signbit (value) != 0;
-      if (*sign)
-	value = -value;
-
-      if (ndigit < 0)
-	{
-	  /* Rounding to the left of the decimal point.  */
-	  while (ndigit < 0)
-	    {
-	      FLOAT_TYPE new_value = value * 0.1;
-
-	      if (new_value < 1.0)
-		{
-		  ndigit = 0;
-		  break;
-		}
-
-	      value = new_value;
-	      ++left;
-	      ++ndigit;
-	    }
-	}
-    }
-  else
-    /* Value is Inf or NaN.  */
-    *sign = 0;
-
-  n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX),
-		  value);
-  /* Check for a too small buffer.  */
-  if (n >= (ssize_t) len)
-    return -1;
-
-  i = 0;
-  while (i < n && isdigit (buf[i]))
-    ++i;
-  *decpt = i;
-
-  if (i == 0)
-    /* Value is Inf or NaN.  */
-    return 0;
-
-  if (i < n)
-    {
-      do
-	++i;
-      while (i < n && !isdigit (buf[i]));
-
-      if (*decpt == 1 && buf[0] == '0' && value != 0.0)
-	{
-	  /* We must not have leading zeroes.  Strip them all out and
-	     adjust *DECPT if necessary.  */
-	  --*decpt;
-	  while (i < n && buf[i] == '0')
-	    {
-	      --*decpt;
-	      ++i;
-	    }
-	}
-
-      memmove (&buf[MAX (*decpt, 0)], &buf[i], n - i);
-      buf[n - (i - MAX (*decpt, 0))] = '\0';
-    }
-
-  if (left)
-    {
-      *decpt += left;
-      if ((ssize_t) --len > n)
-	{
-	  while (left-- > 0 && n < (ssize_t) len)
-	    buf[n++] = '0';
-	  buf[n] = '\0';
-	}
-    }
-
-  return 0;
-}
-
-int
-__APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
-				int *sign, char *buf, size_t len)
-{
-  int exponent = 0;
-
-  if (isfinite (value) && value != 0.0)
-    {
-      /* Slow code that doesn't require -lm functions.  */
-      FLOAT_TYPE d;
-      FLOAT_TYPE f = 1.0;
-      if (value < 0.0)
-	d = -value;
-      else
-	d = value;
-      /* For denormalized numbers the d < 1.0 case below won't work,
-	 as f can overflow to +Inf.  */
-      if (d < FLOAT_MIN_10_NORM)
-	{
-	  value /= FLOAT_MIN_10_NORM;
-	  if (value < 0.0)
-	    d = -value;
-	  else
-	    d = value;
-	  exponent += FLOAT_MIN_10_EXP;
-	}
-      if (d < 1.0)
-	{
-	  do
-	    {
-	      f *= 10.0;
-	      --exponent;
-	    }
-	  while (d * f < 1.0);
-
-	  value *= f;
-	}
-      else if (d >= 10.0)
-	{
-	  do
-	    {
-	      f *= 10;
-	      ++exponent;
-	    }
-	  while (d >= f * 10.0);
-
-	  value /= f;
-	}
-    }
-  else if (value == 0.0)
-    /* SUSv2 leaves it unspecified whether *DECPT is 0 or 1 for 0.0.
-       This could be changed to -1 if we want to return 0.  */
-    exponent = 0;
-
-  if (ndigit <= 0 && len > 0)
-    {
-      buf[0] = '\0';
-      *decpt = 1;
-      *sign = isfinite (value) ? signbit (value) != 0 : 0;
-    }
-  else
-    if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1,
-					decpt, sign, buf, len))
-      return -1;
-
-  *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) \
-    libc_hidden_def (local) \
-    versioned_symbol (lib, local, symbol, version)
-# else
-#  define cvt_symbol(symbol) \
+# 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) \
+# 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))
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index 4fcadfcdc2..ed75a4f8ca 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -16,31 +16,16 @@
    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
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# 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
-/* 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)))
+# define cvt_symbol(symbol) \
+  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
 #endif
-
-#include "efgcvt.c"
+cvt_symbol(fcvt);
+cvt_symbol(ecvt);
+cvt_symbol(gcvt);
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index 8f4d8b9f7a..b8eb837fb5 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -17,41 +17,19 @@
    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
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# 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) \
+  libc_hidden_def (local) \
+  versioned_symbol (lib, local, symbol, version)
 #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)
+# 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
-
-#include "efgcvt_r.c"
+cvt_symbol(fcvt_r);
+cvt_symbol(ecvt_r);
-- 
2.21.0


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

* [PATCH v3 04/11] Refactor *cvt functions implementation (5/5)
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (2 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5) Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

Changes since v2:

  - Moved the removal of unused macros to a previous patch

Changes since v1:

  - Adapted after patch v1 19/31 (remove hidden_* uses) was dropped.
  - Fixed unintended removal of cvt* symbols on alpha and s390x
    (now tested with build-many-glibcs.py).

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.

The commit message is on patch 1-4/5.
---
 misc/efgcvt-template.c   | 17 ++++++-----------
 misc/efgcvt.c            | 28 +++++++++++++++++++---------
 misc/efgcvt_r-template.c | 12 ++++++------
 misc/efgcvt_r.c          | 22 +++++++++++++---------
 misc/qefgcvt.c           | 28 ++++++++++++++++++----------
 misc/qefgcvt_r.c         | 22 ++++++++++++----------
 6 files changed, 74 insertions(+), 55 deletions(-)

diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index 5eea9f6370..7fabdf264d 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -37,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);
@@ -51,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 deb975b3ce..ddf306941a 100644
--- a/misc/efgcvt.c
+++ b/misc/efgcvt.c
@@ -16,17 +16,27 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#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(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(local, symbol) \
+  cvt_symbol_1 (libc, local, APPEND (q, symbol), GLIBC_2_0); \
+  strong_alias (local, symbol)
 # define cvt_symbol_1(lib, local, symbol, version) \
   compat_symbol (lib, local, symbol, version)
 #else
-# define cvt_symbol(symbol) \
-  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+# define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
 #endif
-cvt_symbol(fcvt);
-cvt_symbol(ecvt);
-cvt_symbol(gcvt);
+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 04457cd910..977750118c 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -30,8 +30,8 @@
 #define APPEND2(a, b) a##b
 
 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;
@@ -125,8 +125,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;
 
@@ -185,8 +185,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 a9ea569299..5dabcad3c7 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -16,20 +16,24 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#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(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(local, symbol) \
+  cvt_symbol_1 (libc, local, APPEND (q, symbol), GLIBC_2_0); \
+  weak_alias (local, symbol)
 # define cvt_symbol_1(lib, local, symbol, version) \
   libc_hidden_def (local) \
   compat_symbol (lib, local, symbol, version)
 #else
-# define cvt_symbol(symbol) \
-  cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(local, symbol) \
+# define cvt_symbol(local, symbol) \
   libc_hidden_def (local) \
   weak_alias (local, symbol)
 #endif
-cvt_symbol(fcvt_r);
-cvt_symbol(ecvt_r);
+cvt_symbol (__fcvt_r, fcvt_r);
+cvt_symbol (__ecvt_r, ecvt_r);
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index ed75a4f8ca..903bf93aa4 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -16,16 +16,24 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#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(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)
+# define cvt_symbol(local, symbol) \
+  versioned_symbol (libc, local, symbol, GLIBC_2_4)
 #else
-# define cvt_symbol(symbol) \
-  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+# define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
 #endif
-cvt_symbol(fcvt);
-cvt_symbol(ecvt);
-cvt_symbol(gcvt);
+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 b8eb837fb5..b790bf7837 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -17,19 +17,21 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
+#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(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
-# define cvt_symbol_1(lib, local, symbol, version) \
+# define cvt_symbol(local, symbol) \
   libc_hidden_def (local) \
-  versioned_symbol (lib, local, symbol, version)
+  versioned_symbol (libc, local, symbol, GLIBC_2_4)
 #else
-# define cvt_symbol(symbol) \
-  cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(local, symbol) \
+# define cvt_symbol(local, symbol) \
   libc_hidden_def (local) \
   weak_alias (local, symbol)
 #endif
-cvt_symbol(fcvt_r);
-cvt_symbol(ecvt_r);
+cvt_symbol (__qfcvt_r, qfcvt_r);
+cvt_symbol (__qecvt_r, qecvt_r);
-- 
2.21.0


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

* [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (3 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 04/11] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-09 23:12   ` Paul E Murphy
  2019-12-03 17:05 ` [PATCH v3 06/11] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
                   ` (5 subsequent siblings)
  10 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

Changes since v2:

  - Fix http URLs.

No changes since v1.

-- 8< --
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 977750118c..bae2d30a77 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
+
 
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
@@ -73,7 +77,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 6d5414c54a..49d9af9fea 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-container += 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..1e9fd16db2
--- /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
+   <https://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..1a5e43972f
--- /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
+   <https://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 related	[flat|nested] 27+ messages in thread

* [PATCH v3 06/11] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (4 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 07/11] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

No changes since v2.

Changes since v1:

  - Reduced the number of changes to the minimum required to build *cvt
    files in -mabi=ieeelongdouble mode.
  - Added __LONG_DOUBLE_USES_FLOAT128 to all long-double.h files.

-- 8< --
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, a
new macro that is defined to 1 when functions that deal with long double
typed values reuses the _Float128 implementation (this is currently only
true for powerpc64le).

Tested for powerpc64le, x86_64, and with build-many-glibcs.py.

Co-authored-by: Gabriel F. T. Gomes <gabrielftg@linux.ibm.com>
Reviewed-by: Florian Weimer <fweimer@redhat.com>
---
 bits/long-double.h                            |  1 +
 include/stdio.h                               | 11 +++++--
 include/stdlib.h                              |  3 ++
 sysdeps/ieee754/ldbl-128/bits/long-double.h   |  1 +
 .../ldbl-128ibm-compat/bits/long-double.h     | 29 +++++++++++++++++++
 sysdeps/ieee754/ldbl-96/bits/long-double.h    |  1 +
 sysdeps/ieee754/ldbl-opt/bits/long-double.h   |  1 +
 sysdeps/mips/ieee754/bits/long-double.h       |  1 +
 .../linux/sparc/sparc32/bits/long-double.h    |  1 +
 .../linux/sparc/sparc64/bits/long-double.h    |  1 +
 10 files changed, 48 insertions(+), 2 deletions(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h

diff --git a/bits/long-double.h b/bits/long-double.h
index 8bfafe028a..7c2eed521b 100644
--- a/bits/long-double.h
+++ b/bits/long-double.h
@@ -37,3 +37,4 @@
 #ifndef __NO_LONG_DOUBLE_MATH
 # define __NO_LONG_DOUBLE_MATH	1
 #endif
+#define __LONG_DOUBLE_USES_FLOAT128 0
diff --git a/include/stdio.h b/include/stdio.h
index bea2066cd1..dffa7765dd 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -13,7 +13,9 @@ 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 __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 +74,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 +153,9 @@ libc_hidden_proto (__libc_readline_unlocked);
 extern const char *const _sys_errlist_internal[] attribute_hidden;
 extern int _sys_nerr_internal attribute_hidden;
 
+#if __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 +176,15 @@ 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 __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/stdlib.h b/include/stdlib.h
index 114e12d255..1fab78aa16 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -202,9 +202,12 @@ 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 __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/sysdeps/ieee754/ldbl-128/bits/long-double.h b/sysdeps/ieee754/ldbl-128/bits/long-double.h
index eac89e233a..17283d3065 100644
--- a/sysdeps/ieee754/ldbl-128/bits/long-double.h
+++ b/sysdeps/ieee754/ldbl-128/bits/long-double.h
@@ -18,3 +18,4 @@
 
 /* long double is distinct from double, so there is nothing to
    define here.  */
+#define __LONG_DOUBLE_USES_FLOAT128 0
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..02d1b40169
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h
@@ -0,0 +1,29 @@
+/* Properties of long double type.  ldbl-opt 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  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
+   <https://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
+/* On platforms that reuse the _Float128 implementation for IEEE long
+   double, access to the correct long double functions is selected based
+   on the long double mode being used during the compilation.  On
+   powerpc64le, this is true when -mabi=ieeelongdouble is in use.  */
+#define __LONG_DOUBLE_USES_FLOAT128 (__LDBL_MANT_DIG__ == 113)
diff --git a/sysdeps/ieee754/ldbl-96/bits/long-double.h b/sysdeps/ieee754/ldbl-96/bits/long-double.h
index 72d15da6c8..e55227b69a 100644
--- a/sysdeps/ieee754/ldbl-96/bits/long-double.h
+++ b/sysdeps/ieee754/ldbl-96/bits/long-double.h
@@ -18,3 +18,4 @@
 
 /* long double is distinct from double, so there is nothing to
    define here.  */
+#define __LONG_DOUBLE_USES_FLOAT128 0
diff --git a/sysdeps/ieee754/ldbl-opt/bits/long-double.h b/sysdeps/ieee754/ldbl-opt/bits/long-double.h
index 1e8fb5886e..8fa37a0e33 100644
--- a/sysdeps/ieee754/ldbl-opt/bits/long-double.h
+++ b/sysdeps/ieee754/ldbl-opt/bits/long-double.h
@@ -22,3 +22,4 @@
 #  define __NO_LONG_DOUBLE_MATH		1
 # endif
 #endif
+#define __LONG_DOUBLE_USES_FLOAT128 0
diff --git a/sysdeps/mips/ieee754/bits/long-double.h b/sysdeps/mips/ieee754/bits/long-double.h
index b52f3f860e..808f3e300c 100644
--- a/sysdeps/mips/ieee754/bits/long-double.h
+++ b/sysdeps/mips/ieee754/bits/long-double.h
@@ -21,3 +21,4 @@
 #if !defined __NO_LONG_DOUBLE_MATH && _MIPS_SIM == _ABIO32
 # define __NO_LONG_DOUBLE_MATH	1
 #endif
+#define __LONG_DOUBLE_USES_FLOAT128 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h b/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h
index aec2a86c96..bd403fba21 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h
@@ -24,3 +24,4 @@
 #  define __NO_LONG_DOUBLE_MATH        1
 # endif
 #endif
+#define __LONG_DOUBLE_USES_FLOAT128 0
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h
index aec2a86c96..bd403fba21 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h
@@ -24,3 +24,4 @@
 #  define __NO_LONG_DOUBLE_MATH        1
 # endif
 #endif
+#define __LONG_DOUBLE_USES_FLOAT128 0
-- 
2.21.0


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

* [PATCH v3 07/11] ldbl-128ibm-compat: Compiler flags for stdio functions
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (5 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 06/11] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 08/11] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

No changes since v2.

No changes since v1.

-- 8< --
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 49d9af9fea..8f6a09091a 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 related	[flat|nested] 27+ messages in thread

* [PATCH v3 08/11] Avoid compat symbols for totalorder in powerpc64le IEEE long double
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (6 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 07/11] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 09/11] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

No changes since v2.

Changes since v1:

  - Added comment on the redefinition of libm_alias_float128_other_r_ldbl.

-- 8< --
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.

Tested for powerpc64le.

Reviewed-by: Joseph Myers <joseph@codesourcery.com>
---
 sysdeps/ieee754/ldbl-128/s_totalorderl.c    | 9 +++++++++
 sysdeps/ieee754/ldbl-128/s_totalordermagl.c | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/sysdeps/ieee754/ldbl-128/s_totalorderl.c b/sysdeps/ieee754/ldbl-128/s_totalorderl.c
index 098bd2bcab..f9db06c025 100644
--- a/sysdeps/ieee754/ldbl-128/s_totalorderl.c
+++ b/sysdeps/ieee754/ldbl-128/s_totalorderl.c
@@ -74,6 +74,15 @@ __totalorder_compatl (_Float128 x, _Float128 y)
 {
   return __totalorderl (&x, &y);
 }
+/* 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)
 #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..45b17ed4dd 100644
--- a/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
+++ b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c
@@ -68,6 +68,15 @@ __totalordermag_compatl (_Float128 x, _Float128 y)
 {
   return __totalordermagl (&x, &y);
 }
+/* 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 totalordermagl 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)
 #undef do_symbol
 #define do_symbol(orig_name, name, aliasname)			\
   strong_alias (orig_name, name)				\
-- 
2.21.0


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

* [PATCH v3 09/11] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (7 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 08/11] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 10/11] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
  10 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

No changes since v2.

Changes since v1:

  - Do not try to remove -mabi=ieeelongdouble, since it hasn't been
    added.  The removal is a residue from our initial development.

-- 8< --
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 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 8f6a09091a..7efbd00089 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,12 @@ 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))
+
+# 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 related	[flat|nested] 27+ messages in thread

* [PATCH v3 10/11] powerpc64le: Require a compiler with -mno-gnu-attribute
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (8 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 09/11] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-03 17:05 ` [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
  10 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

No changes since v2.

Changes since v1:

  - Added mentions to the build requirement in manual/install.texi,
    INSTALL (regenerated) and NEWS.

-- 8< --
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.

Reviewed-by: Joseph Myers <joseph@codesourcery.com>
---
 INSTALL                                   |  5 ++++
 NEWS                                      |  2 +-
 manual/install.texi                       |  5 ++++
 sysdeps/powerpc/powerpc64/le/configure    | 29 +++++++++++++++++++++++
 sysdeps/powerpc/powerpc64/le/configure.ac | 15 ++++++++++++
 5 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/INSTALL b/INSTALL
index 392537cc5c..1baa99f304 100644
--- a/INSTALL
+++ b/INSTALL
@@ -467,6 +467,11 @@ build the GNU C Library:
      better code.  As of release time, GCC 9.1.1 is the newest compiler
      verified to work to build the GNU C Library.
 
+     For PowerPC 64-bits little-endian (powerpc64le), a GCC version with
+     support for -mno-gnu-attribute is required.  As of release time,
+     this means GCC 7 or higher.  The compiler option is required for
+     building the GNU C Library with support for IEEE long double.
+
      For multi-arch support it is recommended to use a GCC which has
      been built with support for GNU indirect functions.  This ensures
      that correct debugging information is generated for functions
diff --git a/NEWS b/NEWS
index 5a2d0a5b8b..a39d782274 100644
--- a/NEWS
+++ b/NEWS
@@ -101,7 +101,7 @@ Deprecated and removed features, and other changes affecting compatibility:
 
 Changes to build and runtime requirements:
 
-  [Add changes to build and runtime requirements here]
+* On powerpc64le, GCC 7 or later is required to build the GNU C Library.
 
 Security related changes:
 
diff --git a/manual/install.texi b/manual/install.texi
index b2d569ac5a..85767ebde3 100644
--- a/manual/install.texi
+++ b/manual/install.texi
@@ -507,6 +507,11 @@ the newest version of the compiler that is known to work for building
 release time, GCC 9.1.1 is the newest compiler verified to work to build
 @theglibc{}.
 
+For PowerPC 64-bits little-endian (powerpc64le), a GCC version with
+support for -mno-gnu-attribute is required.  As of release time, this
+means GCC 7 or higher. The compiler option is required for building the
+GNU C Library with support for IEEE long double.
+
 For multi-arch support it is recommended to use a GCC which has been built with
 support for GNU indirect functions.  This ensures that correct debugging
 information is generated for functions selected by IFUNC resolvers.  This
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 related	[flat|nested] 27+ messages in thread

* [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double
  2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (9 preceding siblings ...)
  2019-12-03 17:05 ` [PATCH v3 10/11] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
@ 2019-12-03 17:05 ` Gabriel F. T. Gomes
  2019-12-09 23:47   ` Paul E Murphy
  10 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 17:05 UTC (permalink / raw
  To: libc-alpha

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

DO NOT COMMIT!

Changes since v2:

  - Added definition of LDBL_IBM128_COMPAT_VERSION and
    LDBL_IBM128_VERSION (moved from a previous commit).

Changes since v1:

  - Use __LONG_DOUBLE_USES_FLOAT128 directly.

-- 8< --
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                                   |   3 +-
 libio/bits/stdio-ldbl.h                       |  46 +++++---
 libio/stdio.h                                 |  16 ++-
 misc/bits/syslog-ldbl.h                       |   4 +-
 misc/err.h                                    |   3 +-
 misc/error.h                                  |   6 +-
 misc/sys/cdefs.h                              |  38 ++++++-
 misc/sys/syslog.h                             |   4 +-
 stdio-common/printf.h                         |   3 +-
 stdlib/bits/stdlib-ldbl.h                     |  22 ++++
 stdlib/monetary.h                             |   3 +-
 stdlib/stdlib.h                               |   4 +-
 sysdeps/powerpc/powerpc64/le/Implies-before   |   1 +
 .../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                                |  14 ++-
 18 files changed, 365 insertions(+), 43 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h

diff --git a/argp/argp.h b/argp/argp.h
index 07adec1895..9d4d26370b 100644
--- a/argp/argp.h
+++ b/argp/argp.h
@@ -554,7 +554,8 @@ __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 || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/argp-ldbl.h>
 #endif
 
diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h
index 2f01a98384..6b90433616 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 __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 __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..819d0a6402 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -400,9 +400,12 @@ 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 \
+    && __LONG_DOUBLE_USES_FLOAT128 == 0
 # ifdef __REDIRECT
 extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
 				const char *__restrict __format, ...),
@@ -447,7 +450,8 @@ 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 \
+      && __LONG_DOUBLE_USES_FLOAT128 == 0
 extern int __REDIRECT (vfscanf,
 		       (FILE *__restrict __s,
 			const char *__restrict __format, __gnuc_va_list __arg),
@@ -866,7 +870,9 @@ 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 || __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..f3b39edfe8 100644
--- a/misc/err.h
+++ b/misc/err.h
@@ -52,7 +52,8 @@ 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 || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/err-ldbl.h>
 #endif
 
diff --git a/misc/error.h b/misc/error.h
index 79840bf0f7..0170d89b52 100644
--- a/misc/error.h
+++ b/misc/error.h
@@ -47,11 +47,13 @@ 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 || __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 467dbd9547..d449628bdb 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -452,7 +452,37 @@
 #include <bits/wordsize.h>
 #include <bits/long-double.h>
 
-#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+#if __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)
@@ -461,6 +491,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) \
@@ -471,11 +503,13 @@
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
 # endif
 #endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT && __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..c000b8e915 100644
--- a/misc/sys/syslog.h
+++ b/misc/sys/syslog.h
@@ -206,7 +206,9 @@ 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 || __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..e93a2bdebd 100644
--- a/stdio-common/printf.h
+++ b/stdio-common/printf.h
@@ -182,7 +182,8 @@ 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 || __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..615ee3131a 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 __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..6a680cc832 100644
--- a/stdlib/monetary.h
+++ b/stdlib/monetary.h
@@ -50,7 +50,8 @@ 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 || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/monetary-ldbl.h>
 #endif
 
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 4bd86ec84d..e527864cb7 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -1016,7 +1016,9 @@ 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 || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/stdlib-ldbl.h>
 #endif
 
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/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
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..ed8b746cb7 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 __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 __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 fc62fa3e26..4b168d1bc2 100644
--- a/wcsmbs/wchar.h
+++ b/wcsmbs/wchar.h
@@ -633,9 +633,11 @@ 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 \
+     && __LONG_DOUBLE_USES_FLOAT128 == 0
 #  ifdef __REDIRECT
 extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream,
 				 const wchar_t *__restrict __format, ...),
@@ -688,7 +690,8 @@ extern int vswscanf (const wchar_t *__restrict __s,
 /* Same redirection as above for the v*wscanf family.  */
 # if !__GLIBC_USE (DEPRECATED_SCANF) \
      && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
-     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
+     && __LONG_DOUBLE_USES_FLOAT128 == 0
 #  ifdef __REDIRECT
 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
 				  const wchar_t *__restrict __format,
@@ -849,7 +852,8 @@ 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 || __LONG_DOUBLE_USES_FLOAT128 == 1
 # include <bits/wchar-ldbl.h>
 #endif
 
-- 
2.21.0


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

* Re: [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-03 17:05 ` [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf Gabriel F. T. Gomes
@ 2019-12-09 16:45   ` Paul E Murphy
  2019-12-09 16:49     ` Zack Weinberg
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 16:45 UTC (permalink / raw
  To: Gabriel F. T. Gomes, libc-alpha



On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> New since v2.
> 
> -- 8< --
> Since commit
> 
> commit 03992356e6fedc5a5e9d32df96c1a2c79ea28a8f
> Author: Zack Weinberg <zackw@panix.com>
> Date:   Sat Feb 10 11:58:35 2018 -0500
> 
>      Use C99-compliant scanf under _GNU_SOURCE with modern compilers.
> 
> the selection of the GNU versions of scanf functions requires both
> _GNU_SOURCE and -std=c89.  This patch changes the tests in
> ldbl-128ibm-compat so that they actually test the GNU versions (without
> this change, the redirection to the ISO C99 version always happens, so
> GNU versions of the new implementation (e.g. __scanfieee128) were left
> untested).

Good catch Zach, thanks.  I wasn't aware of this behavior and verified 
it too.  LGTM.

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

* Re: [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-09 16:45   ` Paul E Murphy
@ 2019-12-09 16:49     ` Zack Weinberg
  2019-12-09 17:08       ` Paul E Murphy
  0 siblings, 1 reply; 27+ messages in thread
From: Zack Weinberg @ 2019-12-09 16:49 UTC (permalink / raw
  To: Paul E Murphy; +Cc: Gabriel F. T. Gomes, GNU C Library

On Mon, Dec 9, 2019 at 11:46 AM Paul E Murphy <murphyp@linux.ibm.com> wrote:
> On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
> > From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> >
> > New since v2.
> >
> > -- 8< --
> > Since commit
> >
> > commit 03992356e6fedc5a5e9d32df96c1a2c79ea28a8f
> > Author: Zack Weinberg <zackw@panix.com>
> > Date:   Sat Feb 10 11:58:35 2018 -0500
> >
> >      Use C99-compliant scanf under _GNU_SOURCE with modern compilers.
> >
> > the selection of the GNU versions of scanf functions requires both
> > _GNU_SOURCE and -std=c89.  This patch changes the tests in
> > ldbl-128ibm-compat so that they actually test the GNU versions (without
> > this change, the redirection to the ISO C99 version always happens, so
> > GNU versions of the new implementation (e.g. __scanfieee128) were left
> > untested).
>
> Good catch Zach, thanks.

Credit is actually due to Gabriel; if I understand correctly, I
_introduced_ a bug here!

zw

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

* Re: [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-09 16:49     ` Zack Weinberg
@ 2019-12-09 17:08       ` Paul E Murphy
  2019-12-09 18:16         ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 17:08 UTC (permalink / raw
  To: Zack Weinberg; +Cc: Gabriel F. T. Gomes, GNU C Library



On 12/9/19 10:49 AM, Zack Weinberg wrote:
> On Mon, Dec 9, 2019 at 11:46 AM Paul E Murphy <murphyp@linux.ibm.com> wrote:
>> On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
>>> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>>>
>>> New since v2.
>>>
>>> -- 8< --
>>> Since commit
>>>
>>> commit 03992356e6fedc5a5e9d32df96c1a2c79ea28a8f
>>> Author: Zack Weinberg <zackw@panix.com>
>>> Date:   Sat Feb 10 11:58:35 2018 -0500
>>>
>>>       Use C99-compliant scanf under _GNU_SOURCE with modern compilers.
>>>
>>> the selection of the GNU versions of scanf functions requires both
>>> _GNU_SOURCE and -std=c89.  This patch changes the tests in
>>> ldbl-128ibm-compat so that they actually test the GNU versions (without
>>> this change, the redirection to the ISO C99 version always happens, so
>>> GNU versions of the new implementation (e.g. __scanfieee128) were left
>>> untested).
>>
>> Good catch Zach, thanks.
> 
> Credit is actually due to Gabriel; if I understand correctly, I
> _introduced_ a bug here!
> 
> zw
> 

I stand corrected.  I wonder how frail some of these tests might become 
as they age.  Is framework available today to verify tests are linking 
against the desired variants of a symbol?

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

* Re: [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-12-03 17:05 ` [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
@ 2019-12-09 18:09   ` Paul E Murphy
  2019-12-13 21:13     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 18:09 UTC (permalink / raw
  To: Gabriel F. T. Gomes, libc-alpha



On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> Changes since v2:
> 
>    - Removed ugly hacks after rebase against commit ID 93486ba583ec.
>    - Updated copyright years.
>    - Unified test case for GNU and ISO C99 versions (got rid of many
>      files in the process, including the new test template for C99).
>    - Fixed http URLs.
>    - Updated commit message.
> 
> No changes since v1.
> 
> -- 8< --
> In the format string for *scanf functions, the '%as', '%aS', and '%a[]'
> modifiers behave differently depending on ISO C99 compatibility.  When
> _GNU_SOURCE is defined and -std=c89 is passed to the compiler, these
> functions behave like ascanf, and the modifiers allocate memory for the
> output.  Otherwise, the ISO C99 compliant version of these functions is
> used, and the modifiers consume a floating-point argument.  This patch
> adds the IEEE binary128 variant of ISO C99 compliant functions for the
> third long double format on powerpc64le.
> 
> Tested for powerpc64le.
> 
> Reviewed-by: Paul E. Murphy <murphyp@linux.ibm.com>


> 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 3dbed79b68..9bdf6daa0b 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

...

> +  /* For ISO C99, scan the single-precision value with "%as" to test
> +     that __isoc99_*scanf ignores the 's'.  For DEPRECATED_SCANF, do not
> +     use "%as", because that would try to scan a string and allocate
> +     space for it.  */
> +#if __GLIBC_USE (DEPRECATED_SCANF)
> +# define FMT "%La %a"
> +#else
> +# define FMT "%La %as"
> +#endif

That does simplify the patch nicely.  LGTM.

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

* Re: [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-09 17:08       ` Paul E Murphy
@ 2019-12-09 18:16         ` Gabriel F. T. Gomes
  2019-12-09 20:31           ` Paul E Murphy
  0 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-09 18:16 UTC (permalink / raw
  To: Paul E Murphy; +Cc: Zack Weinberg, GNU C Library

On Mon, 09 Dec 2019, Paul E Murphy wrote:
>
>On 12/9/19 10:49 AM, Zack Weinberg wrote:
>>
>> Credit is actually due to Gabriel; if I understand correctly, I
>> _introduced_ a bug here!

Zack's patch did the right thing...  However, I started working on
powerpc's IEEE long double implementation before his patch landed on
master and I didn't notice the change in default behaviour.  The potential
bug never really showed up, because ldbl-128ibm-compat is not yet in the
Implies file, so the __*ieee128 functions were never really exposed.

>I stand corrected.  I wonder how frail some of these tests might become 
>as they age.  Is framework available today to verify tests are linking 
>against the desired variants of a symbol?

The tests in the subsequent patch (2/11) try to make that better, by
trying to read a long double value with %as when in ISO C99 mode.  Now I'm
wondering that it should try to read a string (and allocate it
automatically) in the -D_GNU_SOURCE -std=c89 case, i.e.: also use %as, but
expect a different output.

Since each case should produce different outputs (even if the input is the
same), I think that will help verify that the correct symbol gets selected.

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

* Re: [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-09 18:16         ` Gabriel F. T. Gomes
@ 2019-12-09 20:31           ` Paul E Murphy
  2019-12-12 13:42             ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 20:31 UTC (permalink / raw
  To: Gabriel F. T. Gomes; +Cc: Zack Weinberg, GNU C Library



On 12/9/19 12:16 PM, Gabriel F. T. Gomes wrote:
> On Mon, 09 Dec 2019, Paul E Murphy wrote:
>>
>> On 12/9/19 10:49 AM, Zack Weinberg wrote:
>>>
>>> Credit is actually due to Gabriel; if I understand correctly, I
>>> _introduced_ a bug here!
> 
> Zack's patch did the right thing...  However, I started working on
> powerpc's IEEE long double implementation before his patch landed on
> master and I didn't notice the change in default behaviour.  The potential
> bug never really showed up, because ldbl-128ibm-compat is not yet in the
> Implies file, so the __*ieee128 functions were never really exposed.
> 
>> I stand corrected.  I wonder how frail some of these tests might become
>> as they age.  Is framework available today to verify tests are linking
>> against the desired variants of a symbol?
> 
> The tests in the subsequent patch (2/11) try to make that better, by
> trying to read a long double value with %as when in ISO C99 mode.  Now I'm
> wondering that it should try to read a string (and allocate it
> automatically) in the -D_GNU_SOURCE -std=c89 case, i.e.: also use %as, but
> expect a different output.
> 
> Since each case should produce different outputs (even if the input is the
> same), I think that will help verify that the correct symbol gets selected.
> 

There are two tests wrapped in each: One to verify the headers select 
the appropriate variant, secondly verifying the long double 
implementation is correct.  The former is sometimes more complicated 
than ibm128 or ieee128.

I am not suggesting this work be included in this patchset, but would it 
be approaching something like `assert (&(scanf) == &FPTR_EXPECTED 
(scanf))` to this and similar printf tests (e.g fortified printf)?  Such 
could quickly tell us if we need to update our tests.

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

* Re: [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5)
  2019-12-03 17:05 ` [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5) Gabriel F. T. Gomes
@ 2019-12-09 21:25   ` Paul E Murphy
  2019-12-13 20:19     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 21:25 UTC (permalink / raw
  To: Gabriel F. T. Gomes, libc-alpha



On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> Changes since v2:
> 
>    - Squashed patches 1-4 and trivial bits of patch 5.
>    - Replaced http with https (like the rest of glibc).
>    - Updated copyright years.
>    - Removed refactoring noise reported by Paul Murphy.
> 
> No changes since v1.
> 
> This patch is to be squashed with the other n/5 refactoring patches.
> 
> Below, the commit message to be used after the squashing...
> 
> -- 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.
> 
> Tested for powerpc64le and with build-many-glibcs.

Is it still your intent to squash the two remaining commits?  This 
refactoring patch is still missing some changes included in the 
followup.  I still think two self-sufficient patches read better than 
squashing these two.  Otherwise, this patch is much improved over 4.

...

> --- a/misc/qefgcvt_r.c
> +++ b/misc/qefgcvt_r.c
> @@ -17,41 +17,19 @@
>      License along with the GNU C Library; if not, see
>      <https://www.gnu.org/licenses/>.  */

This seems to be missing at least the following:

#include <efgcvt-ldbl-macros.h>
#include <efgcvt_r-template.c>

Similarly for some others.

> 
> -#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
> +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
> +# 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) \
> +  libc_hidden_def (local) \
> +  versioned_symbol (lib, local, symbol, version)
>   #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)
> +# 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
> -
> -#include "efgcvt_r.c"
> +cvt_symbol(fcvt_r);
> +cvt_symbol(ecvt_r);
> 

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

* Re: [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions
  2019-12-03 17:05 ` [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
@ 2019-12-09 23:12   ` Paul E Murphy
  2019-12-13 20:02     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 23:12 UTC (permalink / raw
  To: Gabriel F. T. Gomes, libc-alpha



On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> Changes since v2:
> 
>    - Fix http URLs.
> 
> No changes since v1.
> 
> -- 8< --
> 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.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index 6d5414c54a..49d9af9fea 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile

...

> +tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt

Are these tests generated?  I don't see tst-{ibm128,ieee128}-efgcvt.c in 
this patch.  The patch looks otherwise OK to me.

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

* Re: [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double
  2019-12-03 17:05 ` [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
@ 2019-12-09 23:47   ` Paul E Murphy
  2019-12-13 22:41     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 27+ messages in thread
From: Paul E Murphy @ 2019-12-09 23:47 UTC (permalink / raw
  To: Gabriel F. T. Gomes, libc-alpha



On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> DO NOT COMMIT!
> 
> Changes since v2:
> 
>    - Added definition of LDBL_IBM128_COMPAT_VERSION and
>      LDBL_IBM128_VERSION (moved from a previous commit).
> 
> Changes since v1:
> 
>    - Use __LONG_DOUBLE_USES_FLOAT128 directly.
> 
> -- 8< --
> 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                                   |   3 +-
>   libio/bits/stdio-ldbl.h                       |  46 +++++---
>   libio/stdio.h                                 |  16 ++-
>   misc/bits/syslog-ldbl.h                       |   4 +-
>   misc/err.h                                    |   3 +-
>   misc/error.h                                  |   6 +-
>   misc/sys/cdefs.h                              |  38 ++++++-
>   misc/sys/syslog.h                             |   4 +-
>   stdio-common/printf.h                         |   3 +-
>   stdlib/bits/stdlib-ldbl.h                     |  22 ++++
>   stdlib/monetary.h                             |   3 +-
>   stdlib/stdlib.h                               |   4 +-
>   sysdeps/powerpc/powerpc64/le/Implies-before   |   1 +
>   .../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                                |  14 ++-

Nearly all of the previous patches seem to be in good standing and touch 
little outside ldbl-ibm128-compat, and reviewed by those both more 
capable and qualified than myself.  Let's jump to this one.

Ignoring the individual files for a moment, is it appropriate to split 
this into one or more patches to introduce the 
__LONG_DOUBLE_USE_FLOAT128 usage into the various user headers?  Most of 
these changes look fairly straightforward, however the cdefs.h changes 
seem a bit more complicated.  These seem like they could be committed 
before any switches are flipped.

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

* Re: [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf
  2019-12-09 20:31           ` Paul E Murphy
@ 2019-12-12 13:42             ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-12 13:42 UTC (permalink / raw
  To: Paul E Murphy; +Cc: Zack Weinberg, GNU C Library

On Mon, 09 Dec 2019, Paul E Murphy wrote:

>There are two tests wrapped in each: One to verify the headers select 
>the appropriate variant, secondly verifying the long double 
>implementation is correct.  The former is sometimes more complicated 
>than ibm128 or ieee128.

Right.

>I am not suggesting this work be included in this patchset, but would it 
>be approaching something like `assert (&(scanf) == &FPTR_EXPECTED 
>(scanf))` to this and similar printf tests (e.g fortified printf)?  Such 
>could quickly tell us if we need to update our tests.

Sounds good, maybe we could write something similar to elf/tst-addr1.c [1],
with hardcoded function names.

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=elf/tst-addr1.c;h=68ff74aabd4dbe5b4dc1c98ebd2df2f66e080890;hb=HEAD

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

* Re: [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions
  2019-12-09 23:12   ` Paul E Murphy
@ 2019-12-13 20:02     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-13 20:02 UTC (permalink / raw
  To: Paul E Murphy; +Cc: libc-alpha

On Mon, 09 Dec 2019, Paul E Murphy wrote:

>On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
>> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>> 
>> +tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt  
>
>Are these tests generated?  I don't see tst-{ibm128,ieee128}-efgcvt.c in 
>this patch.  The patch looks otherwise OK to me.

Yes, ldbl-128ibm-compat's Makefile copies them [1] from misc/ [2].

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/ldbl-128ibm-compat/Makefile;h=b54eb04f2223c9db3b72b46c3fa20df10f498bf9;hb=HEAD#l204
[2] https://sourceware.org/git/?p=glibc.git;a=blob;f=misc/tst-ldbl-efgcvt.c;h=da1703f9ef7f01a5cf4bd8ecb0fcf4f0f99bb8d8;hb=HEAD


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

* Re: [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5)
  2019-12-09 21:25   ` Paul E Murphy
@ 2019-12-13 20:19     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-13 20:19 UTC (permalink / raw
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

On Mon, 09 Dec 2019, Paul E Murphy wrote:

>Is it still your intent to squash the two remaining commits?

It was, but I changed my mind after reading your message.

>This refactoring patch is still missing some changes included in the 
>followup.  I still think two self-sufficient patches read better than 
>squashing these two.

I wrote a new version where the 2 refactoring patches stand alone and
checked that they produce the same [stripped] binaries as master.  I'll
send v4.  Thanks for insisting on them being standalone (I hadn't
understood that that was your suggestion), I agree they read better.

>This seems to be missing at least the following:
>
>#include <efgcvt-ldbl-macros.h>
>#include <efgcvt_r-template.c>
>
>Similarly for some others.

Fixed (required for standalone patches).

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

* Re: [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-12-09 18:09   ` Paul E Murphy
@ 2019-12-13 21:13     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-13 21:13 UTC (permalink / raw
  To: Paul E Murphy; +Cc: libc-alpha

On Mon, 09 Dec 2019, Paul E Murphy wrote:

>On 12/3/19 11:05 AM, Gabriel F. T. Gomes wrote:
>> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>> 
>> +  /* For ISO C99, scan the single-precision value with "%as" to test
>> +     that __isoc99_*scanf ignores the 's'.  For DEPRECATED_SCANF, do not
>> +     use "%as", because that would try to scan a string and allocate
>> +     space for it.  */
>> +#if __GLIBC_USE (DEPRECATED_SCANF)
>> +# define FMT "%La %a"
>> +#else
>> +# define FMT "%La %as"
>> +#endif  
>
>That does simplify the patch nicely.  LGTM.

Thanks, this and the preceding patch are now committed.

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

* Re: [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double
  2019-12-09 23:47   ` Paul E Murphy
@ 2019-12-13 22:41     ` Gabriel F. T. Gomes
  2019-12-13 23:46       ` Paul E Murphy
  0 siblings, 1 reply; 27+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-13 22:41 UTC (permalink / raw
  To: Paul E Murphy; +Cc: libc-alpha

On Mon, 09 Dec 2019, Paul E Murphy wrote:

>Nearly all of the previous patches seem to be in good standing and touch 
>little outside ldbl-ibm128-compat, and reviewed by those both more 
>capable and qualified than myself.  Let's jump to this one.
>
>Ignoring the individual files for a moment, is it appropriate to split 
>this into one or more patches to introduce the 
>__LONG_DOUBLE_USE_FLOAT128 usage into the various user headers?

Since __LONG_DOUBLE_USES_FLOAT128 is only defined to 1 in
ldbl-ibm128-compat's bits/long-double.h, I suppose this could work.  It's
always defined to 0 by all other bits/long-double.h headers (as suggested
by Florian [1]), including what's currently installed for powerpc64le.

Let me check if I got your suggestion right.  Are you suggesting that all
the changes to installed headers in this patch be split into a separate
patch that can be integrated to master?  Then, this patch (the last one)
would only touch the Implies, .abilist, and ldbl-128ibm-compat-abi.h
files...

I.e.:

>>   sysdeps/powerpc/powerpc64/le/Implies-before   |   1 +
>>   .../powerpc64/le/ldbl-128ibm-compat-abi.h     |   8 ++
>>   .../linux/powerpc/powerpc64/le/libc.abilist   |  93 ++++++++++++++++
>>   .../linux/powerpc/powerpc64/le/libm.abilist   | 104 ++++++++++++++++++

^ these?

[1] https://sourceware.org/ml/libc-alpha/2019-10/msg00610.html

>Most of 
>these changes look fairly straightforward, however the cdefs.h changes 
>seem a bit more complicated.  These seem like they could be committed 
>before any switches are flipped.

You are absolutely right.  I'll work on better comments for cdefs.h.

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

* Re: [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double
  2019-12-13 22:41     ` Gabriel F. T. Gomes
@ 2019-12-13 23:46       ` Paul E Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Paul E Murphy @ 2019-12-13 23:46 UTC (permalink / raw
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 12/13/19 4:41 PM, Gabriel F. T. Gomes wrote:
> On Mon, 09 Dec 2019, Paul E Murphy wrote:

>> Ignoring the individual files for a moment, is it appropriate to split
>> this into one or more patches to introduce the
>> __LONG_DOUBLE_USE_FLOAT128 usage into the various user headers?
> 
> Since __LONG_DOUBLE_USES_FLOAT128 is only defined to 1 in
> ldbl-ibm128-compat's bits/long-double.h, I suppose this could work.  It's
> always defined to 0 by all other bits/long-double.h headers (as suggested
> by Florian [1]), including what's currently installed for powerpc64le.
> 
> Let me check if I got your suggestion right.  Are you suggesting that all
> the changes to installed headers in this patch be split into a separate
> patch that can be integrated to master?  Then, this patch (the last one)
> would only touch the Implies, .abilist, and ldbl-128ibm-compat-abi.h
> files...
> 
> I.e.:
> 
>>>    sysdeps/powerpc/powerpc64/le/Implies-before   |   1 +
>>>    .../powerpc64/le/ldbl-128ibm-compat-abi.h     |   8 ++
>>>    .../linux/powerpc/powerpc64/le/libc.abilist   |  93 ++++++++++++++++
>>>    .../linux/powerpc/powerpc64/le/libm.abilist   | 104 ++++++++++++++++++
> 
> ^ these?

Exactly.  They can remain inert until the remaining support arrives and 
is enabled, while getting the benefit of any ancillary refactoring 
occuring while the remaining libm work is finalized.  Though, that is my 
opinion and may not represent a consensus.

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

end of thread, other threads:[~2019-12-13 23:46 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-03 17:05 [PATCH v3 00/11] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 01/11] ldbl-128ibm-compat: Fix selection of GNU and ISO C99 scanf Gabriel F. T. Gomes
2019-12-09 16:45   ` Paul E Murphy
2019-12-09 16:49     ` Zack Weinberg
2019-12-09 17:08       ` Paul E Murphy
2019-12-09 18:16         ` Gabriel F. T. Gomes
2019-12-09 20:31           ` Paul E Murphy
2019-12-12 13:42             ` Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 02/11] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
2019-12-09 18:09   ` Paul E Murphy
2019-12-13 21:13     ` Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 03/11] Refactor *cvt functions implementation (1-4/5) Gabriel F. T. Gomes
2019-12-09 21:25   ` Paul E Murphy
2019-12-13 20:19     ` Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 04/11] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 05/11] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
2019-12-09 23:12   ` Paul E Murphy
2019-12-13 20:02     ` Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 06/11] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 07/11] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 08/11] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 09/11] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 10/11] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
2019-12-03 17:05 ` [PATCH v3 11/11] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
2019-12-09 23:47   ` Paul E Murphy
2019-12-13 22:41     ` Gabriel F. T. Gomes
2019-12-13 23:46       ` Paul E Murphy

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).