unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le
@ 2019-10-25 15:33 Gabriel F. T. Gomes
  2019-10-25 15:33 ` [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
                   ` (29 more replies)
  0 siblings, 30 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

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

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

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

 INSTALL                                       |   5 +
 NEWS                                          |   2 +-
 argp/argp.h                                   |   3 +-
 bits/long-double.h                            |   1 +
 elf/tst-addr1.c                               |   7 +-
 include/monetary.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                                 | 130 ++-----
 misc/efgcvt_r-template.c                      | 198 +++++++++++
 misc/efgcvt_r.c                               | 255 +-------------
 misc/err.h                                    |   3 +-
 misc/errP.h                                   |  28 ++
 misc/error.h                                  |   6 +-
 misc/errorP.h                                 |  28 ++
 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 +-
 stdlib/strfmon_l.c                            |  31 +-
 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   | 332 +++++++++++++++++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   | 111 ++++++
 .../ldbl-128ibm-compat/bits/long-double.h     |  29 ++
 .../ldbl-128ibm-compat/ieee128-argp-help.c    |  42 +++
 .../ldbl-128ibm-compat/ieee128-asprintf.c     |  35 ++
 .../ldbl-128ibm-compat/ieee128-asprintf_chk.c |  38 ++
 .../ldbl-128ibm-compat/ieee128-dprintf.c      |  34 ++
 .../ldbl-128ibm-compat/ieee128-dprintf_chk.c  |  38 ++
 .../ieee754/ldbl-128ibm-compat/ieee128-err.c  |  93 +++++
 .../ldbl-128ibm-compat/ieee128-error.c        |  51 +++
 .../ldbl-128ibm-compat/ieee128-fprintf.c      |  34 ++
 .../ldbl-128ibm-compat/ieee128-fprintf_chk.c  |  38 ++
 .../ldbl-128ibm-compat/ieee128-fscanf.c       |  34 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf.c     |  35 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |  38 ++
 .../ldbl-128ibm-compat/ieee128-fwscanf.c      |  35 ++
 .../ieee128-isoc99_fscanf.c                   |  35 ++
 .../ieee128-isoc99_fwscanf.c                  |  35 ++
 .../ldbl-128ibm-compat/ieee128-isoc99_scanf.c |  35 ++
 .../ieee128-isoc99_sscanf.c                   |  39 ++
 .../ieee128-isoc99_swscanf.c                  |  40 +++
 .../ieee128-isoc99_vfscanf.c                  |  27 ++
 .../ieee128-isoc99_vfwscanf.c                 |  27 ++
 .../ieee128-isoc99_vscanf.c                   |  27 ++
 .../ieee128-isoc99_vsscanf.c                  |  30 ++
 .../ieee128-isoc99_vswscanf.c                 |  32 ++
 .../ieee128-isoc99_vwscanf.c                  |  27 ++
 .../ieee128-isoc99_wscanf.c                   |  35 ++
 .../ldbl-128ibm-compat/ieee128-obprintf.c     |  42 +++
 .../ldbl-128ibm-compat/ieee128-obstack_chk.c  |  39 ++
 .../ldbl-128ibm-compat/ieee128-printf.c       |  35 ++
 .../ldbl-128ibm-compat/ieee128-printf_chk.c   |  38 ++
 .../ldbl-128ibm-compat/ieee128-qefgcvt.c      |  52 +++
 .../ldbl-128ibm-compat/ieee128-qefgcvt_r.c    |  34 ++
 .../ldbl-128ibm-compat/ieee128-scanf.c        |  34 ++
 .../ldbl-128ibm-compat/ieee128-snprintf.c     |  35 ++
 .../ldbl-128ibm-compat/ieee128-snprintf_chk.c |  42 +++
 .../ldbl-128ibm-compat/ieee128-sprintf.c      |  35 ++
 .../ldbl-128ibm-compat/ieee128-sprintf_chk.c  |  42 +++
 .../ldbl-128ibm-compat/ieee128-sscanf.c       |  38 ++
 .../ldbl-128ibm-compat/ieee128-strfmon.c      |  35 ++
 .../ldbl-128ibm-compat/ieee128-strfmon_l.c    |  35 ++
 .../ldbl-128ibm-compat/ieee128-swprintf.c     |  36 ++
 .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |  42 +++
 .../ldbl-128ibm-compat/ieee128-swscanf.c      |  40 +++
 .../ldbl-128ibm-compat/ieee128-syslog.c       |  65 ++++
 .../ldbl-128ibm-compat/ieee128-vasprintf.c    |  27 ++
 .../ieee128-vasprintf_chk.c                   |  31 ++
 .../ldbl-128ibm-compat/ieee128-vdprintf.c     |  26 ++
 .../ldbl-128ibm-compat/ieee128-vdprintf_chk.c |  30 ++
 .../ldbl-128ibm-compat/ieee128-vfprintf.c     |  26 ++
 .../ldbl-128ibm-compat/ieee128-vfprintf_chk.c |  30 ++
 .../ldbl-128ibm-compat/ieee128-vfscanf.c      |  26 ++
 .../ldbl-128ibm-compat/ieee128-vfwprintf.c    |  27 ++
 .../ieee128-vfwprintf_chk.c                   |  31 ++
 .../ldbl-128ibm-compat/ieee128-vfwscanf.c     |  27 ++
 .../ldbl-128ibm-compat/ieee128-vobstack_chk.c |  31 ++
 .../ldbl-128ibm-compat/ieee128-vprintf.c      |  27 ++
 .../ldbl-128ibm-compat/ieee128-vprintf_chk.c  |  30 ++
 .../ldbl-128ibm-compat/ieee128-vscanf.c       |  26 ++
 .../ldbl-128ibm-compat/ieee128-vsnprintf.c    |  28 ++
 .../ieee128-vsnprintf_chk.c                   |  34 ++
 .../ldbl-128ibm-compat/ieee128-vsprintf.c     |  27 ++
 .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c |  34 ++
 .../ldbl-128ibm-compat/ieee128-vsscanf.c      |  29 ++
 .../ldbl-128ibm-compat/ieee128-vswprintf.c    |  28 ++
 .../ieee128-vswprintf_chk.c                   |  34 ++
 .../ldbl-128ibm-compat/ieee128-vswscanf.c     |  32 ++
 .../ldbl-128ibm-compat/ieee128-vwprintf.c     |  27 ++
 .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |  30 ++
 .../ldbl-128ibm-compat/ieee128-vwscanf.c      |  27 ++
 .../ldbl-128ibm-compat/ieee128-wprintf.c      |  35 ++
 .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |  38 ++
 .../ldbl-128ibm-compat/ieee128-wscanf.c       |  35 ++
 .../test-isoc99-scanf-ibm128.c                |  13 +
 .../test-isoc99-scanf-ieee128.c               |  13 +
 .../test-isoc99-scanf-ldbl-compat-template.c  | 119 +++++++
 .../test-isoc99-scanf-ldbl-compat.c           |  10 +
 .../test-isoc99-scanf-ldbl-compat.sh          |  53 +++
 .../test-isoc99-wscanf-ibm128.c               |  13 +
 .../test-isoc99-wscanf-ieee128.c              |  13 +
 .../test-isoc99-wscanf-ldbl-compat.c          |  10 +
 .../test-obstack-chk-ibm128.c                 |   1 +
 .../test-obstack-chk-ieee128.c                |   1 +
 .../test-obstack-chk-ldbl-compat.c            |   6 +
 .../ldbl-128ibm-compat/test-obstack-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-obstack-ieee128.c |   1 +
 .../test-obstack-ldbl-compat-template.c       |  64 ++++
 .../test-obstack-ldbl-compat.c                |   6 +
 .../test-printf-chk-ibm128.c                  |   1 +
 .../test-printf-chk-ieee128.c                 |   1 +
 .../test-printf-chk-ldbl-compat.c             | 191 ++++++++++
 .../test-printf-chk-redir-ibm128.c            |   2 +
 .../test-printf-chk-redir-ieee128.c           |   2 +
 .../ldbl-128ibm-compat/test-printf-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-printf-ieee128.c  |   1 +
 .../test-printf-ldbl-compat.c                 | 182 ++++++++++
 .../ldbl-128ibm-compat/test-scanf-ibm128.c    |   1 +
 .../ldbl-128ibm-compat/test-scanf-ieee128.c   |   1 +
 .../test-scanf-ldbl-compat-template.c         | 121 +++++++
 .../test-scanf-ldbl-compat.c                  |  10 +
 .../test-scanf-ldbl-compat.sh                 |  63 ++++
 .../ldbl-128ibm-compat/test-strfmon-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-strfmon-ieee128.c |   1 +
 .../test-strfmon-ldbl-compat.c                |  59 ++++
 .../ldbl-128ibm-compat/test-strfrom-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-strfrom-ieee128.c |   1 +
 .../test-strfrom-ldbl-compat.c                |  49 +++
 .../test-syslog-chk-ibm128.c                  |   1 +
 .../test-syslog-chk-ieee128.c                 |   1 +
 .../test-syslog-chk-ldbl-compat.c             |   6 +
 .../ldbl-128ibm-compat/test-syslog-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-syslog-ieee128.c  |   1 +
 .../test-syslog-ldbl-compat-template.c        |  67 ++++
 .../test-syslog-ldbl-compat.c                 |   6 +
 .../ldbl-128ibm-compat/test-wcstold-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-wcstold-ieee128.c |   1 +
 .../test-wcstold-ldbl-compat.c                |  36 ++
 .../test-wprintf-chk-ibm128.c                 |   1 +
 .../test-wprintf-chk-ieee128.c                |   1 +
 .../test-wprintf-chk-ldbl-compat.c            | 122 +++++++
 .../test-wprintf-chk-redir-ibm128.c           |   2 +
 .../test-wprintf-chk-redir-ieee128.c          |   2 +
 .../ldbl-128ibm-compat/test-wprintf-ibm128.c  |   1 +
 .../ldbl-128ibm-compat/test-wprintf-ieee128.c |   1 +
 .../test-wprintf-ldbl-compat.c                | 120 +++++++
 .../ldbl-128ibm-compat/test-wscanf-ibm128.c   |   1 +
 .../ldbl-128ibm-compat/test-wscanf-ieee128.c  |   1 +
 .../test-wscanf-ldbl-compat.c                 |  10 +
 sysdeps/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 +-
 176 files changed, 5356 insertions(+), 458 deletions(-)
 create mode 100644 misc/efgcvt-dbl-macros.h
 create mode 100644 misc/efgcvt-ldbl-macros.h
 create mode 100644 misc/efgcvt-template.c
 create mode 100644 misc/efgcvt_r-template.c
 create mode 100644 misc/errP.h
 create mode 100644 misc/errorP.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h

-- 
2.21.0


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

* [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-10-29 15:42   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 02/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
                   ` (28 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

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

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

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


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

* [PATCH v2 02/30] ldbl-128ibm-compat: Add wide character printing functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
  2019-10-25 15:33 ` [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-04 15:08   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified " Gabriel F. T. Gomes
                   ` (27 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 89059f37e2..0f2f58d5b9 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -11,7 +11,13 @@ ldbl-extra-routines += printf_size \
 		       vfprintf \
 		       vprintf \
 		       vsnprintf \
-		       vsprintf
+		       vsprintf \
+		       fwprintf \
+		       swprintf \
+		       wprintf \
+		       vfwprintf \
+		       vswprintf \
+		       vwprintf
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -19,6 +25,7 @@ ldbl-extra-routines += printf_size \
 # the following functions, must have -mfloat128 and -mabi=ibmlongdouble
 # passed to the compiler.
 CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 
 # Basic tests for the implementation of long double with IEEE binary128
 # format and for the related redirections in installed headers.
@@ -26,6 +33,10 @@ tests-internal += test-printf-ieee128 test-printf-ibm128
 CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
+tests-internal += test-wprintf-ieee128 test-wprintf-ibm128
+CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
 tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 6a27befed2..0485a2b5d4 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -134,5 +134,13 @@ libc {
     __vprintfieee128;
     __vsnprintfieee128;
     __vsprintfieee128;
+
+    __fwprintfieee128;
+    __swprintfieee128;
+    __wprintfieee128;
+
+    __vfwprintfieee128;
+    __vswprintfieee128;
+    __vwprintfieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
new file mode 100644
index 0000000000..4b350a6e0b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for fwprintf.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fwprintf (FILE *fp, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (fp, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fwprintf, __fwprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
new file mode 100644
index 0000000000..4fb40e3c42
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
@@ -0,0 +1,36 @@
+/* Wrapper for swprintf.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_swprintf (wchar_t *string, size_t maxlen,
+		    const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vswprintf_internal (string, maxlen, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_swprintf, __swprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
new file mode 100644
index 0000000000..757f4b31a8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vfwprintf.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfwprintf (FILE *fp, const wchar_t *format, va_list ap)
+{
+  return __vfwprintf_internal (fp, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfwprintf, __vfwprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
new file mode 100644
index 0000000000..9bb36cfae9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
@@ -0,0 +1,28 @@
+/* Wrapper for vswprintf.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vswprintf (wchar_t *string, size_t maxlen,
+		     const wchar_t *format, va_list ap)
+{
+  return __vswprintf_internal (string, maxlen, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vswprintf, __vswprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
new file mode 100644
index 0000000000..44ec37e24f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vwprintf.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vwprintf (const wchar_t *format, va_list ap)
+{
+  return __vfwprintf_internal (stdout, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vwprintf, __vwprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
new file mode 100644
index 0000000000..c949f328c2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for wprintf.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_wprintf (const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (stdout, format, ap,
+			       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_wprintf, __wprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
new file mode 100644
index 0000000000..9e230cd6f8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
@@ -0,0 +1 @@
+#include <test-wprintf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
new file mode 100644
index 0000000000..9e230cd6f8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
@@ -0,0 +1 @@
+#include <test-wprintf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
new file mode 100644
index 0000000000..71edfec235
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -0,0 +1,111 @@
+/* Test for the long double variants of *w*printf functions.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const wchar_t *format, ...)
+{
+  wchar_t string[128];
+  va_list args;
+
+  wprintf (L"%15Ls", L"vfwprintf: ");
+  va_start (args, format);
+  vfwprintf (stream, format, args);
+  va_end (args);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"vswprintf: ");
+  va_start (args, format);
+  vswprintf (string, 127, format, args);
+  va_end (args);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"vwprintf: ");
+  va_start (args, format);
+  vwprintf (format, args);
+  va_end (args);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+{
+  wchar_t string[128];
+
+  wprintf (L"%15Ls", L"fwprintf: ");
+  fwprintf (stream, format, ld);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"swprintf: ");
+  swprintf (string, 127, format, ld);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%15Ls", L"wprintf: ");
+  wprintf (format, ld);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, L"%.10Lf", ld);
+  do_test_call_varg (stdout, L"%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, L"%.10La", ld);
+  do_test_call_varg (stdout, L"%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "     fwprintf: -1.0000000000\n"
+    "     swprintf: -1.0000000000\n"
+    "      wprintf: -1.0000000000\n"
+    "    vfwprintf: -1.0000000000\n"
+    "    vswprintf: -1.0000000000\n"
+    "     vwprintf: -1.0000000000\n"
+    "     fwprintf: -0x1.0000000000p+0\n"
+    "     swprintf: -0x1.0000000000p+0\n"
+    "      wprintf: -0x1.0000000000p+0\n"
+    "    vfwprintf: -0x1.0000000000p+0\n"
+    "    vswprintf: -0x1.0000000000p+0\n"
+    "     vwprintf: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.0


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

* [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified printing functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
  2019-10-25 15:33 ` [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
  2019-10-25 15:33 ` [PATCH v2 02/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-04 15:43   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 04/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
                   ` (26 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 0f2f58d5b9..21056e38da 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -57,6 +57,31 @@ $(objpfx)test-printf-size-ibm128.out: \
 	$(evaluate-test)
 endif
 
+ifeq ($(subdir),debug)
+ldbl-extra-routines += asprintf_chk \
+		       dprintf_chk \
+		       fprintf_chk \
+		       printf_chk \
+		       snprintf_chk \
+		       sprintf_chk \
+		       vasprintf_chk \
+		       vdprintf_chk \
+		       vfprintf_chk \
+		       vprintf_chk \
+		       vsnprintf_chk \
+		       vsprintf_chk
+
+tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128
+CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-printf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-printf-chk-redir-ieee128 test-printf-chk-redir-ibm128
+CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \
+					  -Wno-psabi -Wno-unused-result
+CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
+					 -Wno-unused-result
+endif
+
 # Add IEEE binary128 files as make targets.
 routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 0485a2b5d4..aac08a3ad3 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -142,5 +142,19 @@ libc {
     __vfwprintfieee128;
     __vswprintfieee128;
     __vwprintfieee128;
+
+    __asprintf_chkieee128;
+    __dprintf_chkieee128;
+    __fprintf_chkieee128;
+    __printf_chkieee128;
+    __snprintf_chkieee128;
+    __sprintf_chkieee128;
+
+    __vasprintf_chkieee128;
+    __vdprintf_chkieee128;
+    __vfprintf_chkieee128;
+    __vprintf_chkieee128;
+    __vsnprintf_chkieee128;
+    __vsprintf_chkieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
new file mode 100644
index 0000000000..149fc046b6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __asprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_asprintf_chk (char **string_ptr, int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vasprintf_internal (string_ptr, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_asprintf_chk, __asprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
new file mode 100644
index 0000000000..724fb0bd43
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __dprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_dprintf_chk (int d, int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vdprintf_internal (d, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_dprintf_chk, __dprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
new file mode 100644
index 0000000000..fc15b0bfbd
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __fprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fprintf_chk (FILE *fp, int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfprintf_internal (fp, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fprintf_chk, __fprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
new file mode 100644
index 0000000000..f3fe2900c3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __printf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_printf_chk (int flag, const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfprintf_internal (stdout, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_printf_chk, __printf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
new file mode 100644
index 0000000000..7f19962dd5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __snprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
+			const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  va_start (ap, format);
+  done = __vsnprintf_internal (s, maxlen, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_snprintf_chk, __snprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
new file mode 100644
index 0000000000..7cea1225c0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __sprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_sprintf_chk (char *s, int flag, size_t slen,
+		       const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (slen == 0)
+    __chk_fail ();
+
+  va_start (ap, format);
+  done = __vsprintf_internal (s, slen, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_sprintf_chk, __sprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
new file mode 100644
index 0000000000..c496ebe5a3
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __vasprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vasprintf_chk (char **result_ptr, int flag, const char *format,
+			 va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vasprintf_internal (result_ptr, format, ap, mode);
+}
+strong_alias (___ieee128_vasprintf_chk, __vasprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
new file mode 100644
index 0000000000..1b96f5fd21
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vdprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vdprintf_chk (int d, int flag, const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vdprintf_internal (d, format, ap, mode);
+}
+strong_alias (___ieee128_vdprintf_chk, __vdprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
new file mode 100644
index 0000000000..67b29b5e55
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vfprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfprintf_internal (fp, format, ap, mode);
+}
+strong_alias (___ieee128_vfprintf_chk, __vfprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
new file mode 100644
index 0000000000..15d3e82d76
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vprintf_chk (int flag, const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfprintf_internal (stdout, format, ap, mode);
+}
+strong_alias (___ieee128_vprintf_chk, __vprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
new file mode 100644
index 0000000000..8df93abf33
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vsnprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsnprintf_chk (char *string, size_t maxlen, int flag,
+			 size_t slen, const char *format, va_list ap)
+{
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vsnprintf_internal (string, maxlen, format, ap, mode);
+}
+strong_alias (___ieee128_vsnprintf_chk, __vsnprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
new file mode 100644
index 0000000000..3de4c12199
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vsprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsprintf_chk (char *string, int flag, size_t slen,
+			const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (slen == 0)
+    __chk_fail ();
+
+  return __vsprintf_internal (string, slen, format, ap, mode);
+}
+strong_alias (___ieee128_vsprintf_chk, __vsprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
new file mode 100644
index 0000000000..7d50284d9c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-printf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
new file mode 100644
index 0000000000..7d50284d9c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-printf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
new file mode 100644
index 0000000000..f3d18c92ec
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
@@ -0,0 +1,179 @@
+/* Test for the long double variants of *printf_chk functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define _FORTIFY_SOURCE 2
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const char *format, ...)
+{
+  char *buffer = NULL;
+  char string[128];
+  int res;
+  va_list args;
+
+  printf ("%20s", "__vasprintf_chk: ");
+  va_start (args, format);
+  res = __vasprintf_chk (&buffer, 1, format, args);
+  va_end (args);
+  if (res == -1)
+    printf ("Error using vasprintf\n");
+  if (buffer == NULL)
+    printf ("Error using vasprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%20s", "__vdprintf_chk: ");
+  va_start (args, format);
+  __vdprintf_chk (fileno (stream), 1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "__vfprintf_chk: ");
+  va_start (args, format);
+  __vfprintf_chk (stream, 1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "__vprintf_chk: ");
+  va_start (args, format);
+  __vprintf_chk (1, format, args);
+  va_end (args);
+  printf ("\n");
+
+  printf ("%20s", "__vsnprintf_chk: ");
+  va_start (args, format);
+  __vsnprintf_chk (string, 79, 1, 127, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%20s", "__vsprintf_chk: ");
+  va_start (args, format);
+  __vsprintf_chk (string, 1, 127, format, args);
+  va_end (args);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const char *format, long double ld)
+{
+  char *buffer = NULL;
+  char string[128];
+  int res;
+
+  printf ("%20s", "__asprintf_chk: ");
+  res = __asprintf_chk (&buffer, 1, format, ld);
+  if (res == -1)
+    printf ("Error using vasprintf\n");
+  if (buffer == NULL)
+    printf ("Error using asprintf\n");
+  else
+    {
+      printf ("%s", buffer);
+      free (buffer);
+    }
+  printf ("\n");
+
+  printf ("%20s", "__dprintf_chk: ");
+  __dprintf_chk (fileno (stream), 1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "__fprintf_chk: ");
+  __fprintf_chk (stdout, 1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "__printf_chk: ");
+  __printf_chk (1, format, ld);
+  printf ("\n");
+
+  printf ("%20s", "__snprintf_chk: ");
+  __snprintf_chk (string, 79, 1, 127, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+
+  printf ("%20s", "__sprintf_chk: ");
+  __sprintf_chk (string, 1, 127, format, ld);
+  printf ("%s", string);
+  printf ("\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, "%.10Lf", ld);
+  do_test_call_varg (stdout, "%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, "%.10La", ld);
+  do_test_call_varg (stdout, "%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "    __asprintf_chk: -1.0000000000\n"
+    "     __dprintf_chk: -1.0000000000\n"
+    "     __fprintf_chk: -1.0000000000\n"
+    "      __printf_chk: -1.0000000000\n"
+    "    __snprintf_chk: -1.0000000000\n"
+    "     __sprintf_chk: -1.0000000000\n"
+    "   __vasprintf_chk: -1.0000000000\n"
+    "    __vdprintf_chk: -1.0000000000\n"
+    "    __vfprintf_chk: -1.0000000000\n"
+    "     __vprintf_chk: -1.0000000000\n"
+    "   __vsnprintf_chk: -1.0000000000\n"
+    "    __vsprintf_chk: -1.0000000000\n"
+    "    __asprintf_chk: -0x1.0000000000p+0\n"
+    "     __dprintf_chk: -0x1.0000000000p+0\n"
+    "     __fprintf_chk: -0x1.0000000000p+0\n"
+    "      __printf_chk: -0x1.0000000000p+0\n"
+    "    __snprintf_chk: -0x1.0000000000p+0\n"
+    "     __sprintf_chk: -0x1.0000000000p+0\n"
+    "   __vasprintf_chk: -0x1.0000000000p+0\n"
+    "    __vdprintf_chk: -0x1.0000000000p+0\n"
+    "    __vfprintf_chk: -0x1.0000000000p+0\n"
+    "     __vprintf_chk: -0x1.0000000000p+0\n"
+    "   __vsnprintf_chk: -0x1.0000000000p+0\n"
+    "    __vsprintf_chk: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
new file mode 100644
index 0000000000..aeab22412b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
new file mode 100644
index 0000000000..aeab22412b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
-- 
2.21.0


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

* [PATCH v2 04/30] ldbl-128ibm-compat: Add wide character, fortified printing functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (2 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified " Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-04 16:07   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 05/30] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
                   ` (25 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

Tested for powerpc64le.
---
 sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  18 ++-
 sysdeps/ieee754/ldbl-128ibm-compat/Versions   |   8 ++
 .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |  38 ++++++
 .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |  42 +++++++
 .../ieee128-vfwprintf_chk.c                   |  31 +++++
 .../ieee128-vswprintf_chk.c                   |  34 ++++++
 .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |  30 +++++
 .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |  38 ++++++
 .../test-wprintf-chk-ibm128.c                 |   1 +
 .../test-wprintf-chk-ieee128.c                |   1 +
 .../test-wprintf-chk-ldbl-compat.c            | 113 ++++++++++++++++++
 .../test-wprintf-chk-redir-ibm128.c           |   2 +
 .../test-wprintf-chk-redir-ieee128.c          |   2 +
 13 files changed, 357 insertions(+), 1 deletion(-)
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
 create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 21056e38da..7217987aa5 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -69,7 +69,13 @@ ldbl-extra-routines += asprintf_chk \
 		       vfprintf_chk \
 		       vprintf_chk \
 		       vsnprintf_chk \
-		       vsprintf_chk
+		       vsprintf_chk \
+		       fwprintf_chk \
+		       swprintf_chk \
+		       wprintf_chk \
+		       vfwprintf_chk \
+		       vswprintf_chk \
+		       vwprintf_chk
 
 tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128
 CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
@@ -80,6 +86,16 @@ CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \
 					  -Wno-psabi -Wno-unused-result
 CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
 					 -Wno-unused-result
+
+tests-internal += test-wprintf-chk-ieee128 test-wprintf-chk-ibm128
+CFLAGS-test-wprintf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wprintf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-wprintf-chk-redir-ieee128 test-wprintf-chk-redir-ibm128
+CFLAGS-test-wprintf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \
+					   -Wno-psabi -Wno-unused-result
+CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
+					  -Wno-unused-result
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index aac08a3ad3..e438c7c306 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -156,5 +156,13 @@ libc {
     __vprintf_chkieee128;
     __vsnprintf_chkieee128;
     __vsprintf_chkieee128;
+
+    __fwprintf_chkieee128;
+    __swprintf_chkieee128;
+    __wprintf_chkieee128;
+
+    __vfwprintf_chkieee128;
+    __vswprintf_chkieee128;
+    __vwprintf_chkieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
new file mode 100644
index 0000000000..04d2632e6c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __fwprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fwprintf_chk (FILE *fp, int flag, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (fp, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fwprintf_chk, __fwprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
new file mode 100644
index 0000000000..854ff2ef2c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __swprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_swprintf_chk (wchar_t *string, size_t maxlen, int flag,
+			size_t slen, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  va_start (ap, format);
+  done = __vswprintf_internal (string, maxlen, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_swprintf_chk, __swprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
new file mode 100644
index 0000000000..2f880930ff
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __vfwprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfwprintf_chk (FILE *fp, int flag, const wchar_t *format,
+			 va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfwprintf_internal (fp, format, ap, mode);
+}
+strong_alias (___ieee128_vfwprintf_chk, __vfwprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
new file mode 100644
index 0000000000..0d995cacf4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vswprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vswprintf_chk (wchar_t *string, size_t maxlen, int flag,
+			 size_t slen, const wchar_t *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  if (__glibc_unlikely (slen < maxlen))
+    __chk_fail ();
+
+  return __vswprintf_internal (string, maxlen, format, ap, mode);
+}
+strong_alias (___ieee128_vswprintf_chk, __vswprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
new file mode 100644
index 0000000000..5e47dccc0d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vwprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vwprintf_chk (int flag, const wchar_t *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __vfwprintf_internal (stdout, format, ap, mode);
+}
+strong_alias (___ieee128_vwprintf_chk, __vwprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
new file mode 100644
index 0000000000..ba00b7be54
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __wprintf_chk.  IEEE128 version.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_wprintf_chk (int flag, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __vfwprintf_internal (stdout, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_wprintf_chk, __wprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
new file mode 100644
index 0000000000..5323df71e2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-wprintf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
new file mode 100644
index 0000000000..5323df71e2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-wprintf-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
new file mode 100644
index 0000000000..f614004f27
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
@@ -0,0 +1,113 @@
+/* Test for the long double variants of *w*printf_chk functions.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#define _FORTIFY_SOURCE 2
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const wchar_t *format, ...)
+{
+  wchar_t string[128];
+  va_list args;
+
+  wprintf (L"%20Ls", L"__vfwprintf_chk: ");
+  va_start (args, format);
+  __vfwprintf_chk (stream, 1, format, args);
+  va_end (args);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__vswprintf_chk: ");
+  va_start (args, format);
+  __vswprintf_chk (string, 79, 1, 127, format, args);
+  va_end (args);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__vwprintf_chk: ");
+  va_start (args, format);
+  __vwprintf_chk (1, format, args);
+  va_end (args);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
+{
+  wchar_t string[128];
+
+  wprintf (L"%20Ls", L"__fwprintf_chk: ");
+  __fwprintf_chk (stream, 1, format, ld);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__swprintf_chk: ");
+  __swprintf_chk (string, 79, 1, 127, format, ld);
+  wprintf (L"%Ls", string);
+  wprintf (L"\n");
+
+  wprintf (L"%20Ls", L"__wprintf_chk: ");
+  __wprintf_chk (1, format, ld);
+  wprintf (L"\n");
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+
+  /* Print in decimal notation.  */
+  do_test_call_rarg (stdout, L"%.10Lf", ld);
+  do_test_call_varg (stdout, L"%.10Lf", ld);
+
+  /* Print in hexadecimal notation.  */
+  do_test_call_rarg (stdout, L"%.10La", ld);
+  do_test_call_varg (stdout, L"%.10La", ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "    __fwprintf_chk: -1.0000000000\n"
+    "    __swprintf_chk: -1.0000000000\n"
+    "     __wprintf_chk: -1.0000000000\n"
+    "   __vfwprintf_chk: -1.0000000000\n"
+    "   __vswprintf_chk: -1.0000000000\n"
+    "    __vwprintf_chk: -1.0000000000\n"
+    "    __fwprintf_chk: -0x1.0000000000p+0\n"
+    "    __swprintf_chk: -0x1.0000000000p+0\n"
+    "     __wprintf_chk: -0x1.0000000000p+0\n"
+    "   __vfwprintf_chk: -0x1.0000000000p+0\n"
+    "   __vswprintf_chk: -0x1.0000000000p+0\n"
+    "    __vwprintf_chk: -0x1.0000000000p+0\n";
+  TEST_COMPARE_STRING (expected, result.out.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
new file mode 100644
index 0000000000..a12186a945
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
new file mode 100644
index 0000000000..a12186a945
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
@@ -0,0 +1,2 @@
+#define _FORTIFY_SOURCE 2
+#include <sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c>
-- 
2.21.0


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

* [PATCH v2 05/30] ldbl-128ibm-compat: Test double values
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (3 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 04/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-04 16:15   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
                   ` (24 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

Tested for powerpc64le.
---
 .../test-printf-chk-ldbl-compat.c             | 72 ++++++++++---------
 .../test-printf-ldbl-compat.c                 | 71 +++++++++---------
 .../test-wprintf-chk-ldbl-compat.c            | 42 +++++------
 .../test-wprintf-ldbl-compat.c                | 42 +++++------
 4 files changed, 117 insertions(+), 110 deletions(-)

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


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

* [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (4 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 05/30] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-04 16:55   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 07/30] ldbl-128ibm-compat: Add regular character scanning functions Gabriel F. T. Gomes
                   ` (23 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

Tested for powerpc64le.
---
 .../ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c | 12 +++++++++++-
 .../ldbl-128ibm-compat/test-printf-ldbl-compat.c     | 12 +++++++++++-
 .../test-wprintf-chk-ldbl-compat.c                   |  9 ++++++++-
 .../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c    |  9 ++++++++-
 4 files changed, 38 insertions(+), 4 deletions(-)

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


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

* [PATCH v2 07/30] ldbl-128ibm-compat: Add regular character scanning functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (5 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-14 21:36   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 08/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
                   ` (22 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

In preparation for the third option of long double format on
powerpc64le, this patch uses the new mode mask,
SCANF_LDBL_USES_FLOAT128, which tells __vfscanf_internal to call
__strtof128_internal, instead of __strtold_internal, and save the output
into a _Float128 variable.

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 7217987aa5..a1f0f7d74e 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -17,15 +17,23 @@ ldbl-extra-routines += printf_size \
 		       wprintf \
 		       vfwprintf \
 		       vswprintf \
-		       vwprintf
+		       vwprintf \
+		       fscanf \
+		       scanf \
+		       sscanf \
+		       vfscanf \
+		       vscanf \
+		       vsscanf
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
-# and __float128 variables and union members).  Thus, the compilation of
-# the following functions, must have -mfloat128 and -mabi=ibmlongdouble
+# and __float128 variables and union members).  Likewise, reading these
+# values reuses __strtof128_internal.  Thus, the compilation of the
+# following functions, must have -mfloat128 and -mabi=ibmlongdouble
 # passed to the compiler.
 CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-vfscanf-internal.c += -mfloat128 -mabi=ibmlongdouble
 
 # Basic tests for the implementation of long double with IEEE binary128
 # format and for the related redirections in installed headers.
@@ -37,6 +45,29 @@ tests-internal += test-wprintf-ieee128 test-wprintf-ibm128
 CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
+tests-internal += test-scanf-ieee128 test-scanf-ibm128
+CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link)
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)test-scanf-ieee128.out
+tests-special += $(objpfx)test-scanf-ibm128.out
+endif
+
+$(objpfx)test-scanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-scanf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-scanf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-scanf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
 tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index e438c7c306..7971c7a7d1 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -164,5 +164,13 @@ libc {
     __vfwprintf_chkieee128;
     __vswprintf_chkieee128;
     __vwprintf_chkieee128;
+
+    __fscanfieee128;
+    __scanfieee128;
+    __sscanfieee128;
+
+    __vfscanfieee128;
+    __vscanfieee128;
+    __vsscanfieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
new file mode 100644
index 0000000000..f51e822094
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
@@ -0,0 +1,34 @@
+/* Wrapper for fscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fscanf (FILE *fp, const char *format, ...)
+{
+  va_list arg;
+  int done;
+
+  va_start (arg, format);
+  done = __vfscanf_internal (fp, format, arg, SCANF_LDBL_USES_FLOAT128);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_fscanf, __fscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
new file mode 100644
index 0000000000..571cf7d75d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
@@ -0,0 +1,34 @@
+/* Wrapper for scanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_scanf (const char *format, ...)
+{
+  va_list arg;
+  int done;
+
+  va_start (arg, format);
+  done = __vfscanf_internal (stdin, format, arg, SCANF_LDBL_USES_FLOAT128);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_scanf, __scanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
new file mode 100644
index 0000000000..7c932955f6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
@@ -0,0 +1,38 @@
+/* Wrapper for sscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_sscanf (const char *string, const char *format, ...)
+{
+  va_list arg;
+  int done;
+
+  _IO_strfile sf;
+  FILE *fp = _IO_strfile_read (&sf, string);
+
+  va_start (arg, format);
+  done = __vfscanf_internal (fp, format, arg, SCANF_LDBL_USES_FLOAT128);
+  va_end (arg);
+
+  return done;
+}
+strong_alias (___ieee128_sscanf, __sscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
new file mode 100644
index 0000000000..d6654e05f5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vfscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfscanf (FILE *fp, const char *format, va_list ap)
+{
+  return __vfscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfscanf, __vfscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
new file mode 100644
index 0000000000..5780c062bb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vscanf (const char *format, va_list ap)
+{
+  return __vfscanf_internal (stdin, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vscanf, __vscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
new file mode 100644
index 0000000000..8ff43a95c2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
@@ -0,0 +1,29 @@
+/* Wrapper for vsscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_vsscanf (const char *string, const char *format, va_list ap)
+{
+  _IO_strfile sf;
+  FILE *fp = _IO_strfile_read (&sf, string);
+  return __vfscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsscanf, __vsscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
new file mode 100644
index 0000000000..8cdee601f2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
@@ -0,0 +1 @@
+#include <test-scanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
new file mode 100644
index 0000000000..8cdee601f2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c
@@ -0,0 +1 @@
+#include <test-scanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
new file mode 100644
index 0000000000..4590e9da96
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
@@ -0,0 +1,117 @@
+/* Test for the long double variants of *scanf functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <wchar.h>
+
+#include <support/check.h>
+
+#define CLEAR								\
+  va_start (args, format);						\
+  ld = va_arg (args, long double *);					\
+  *ld = 0;								\
+  va_end (args);
+
+#define CLEAR_VALUE value = 0;
+
+#define CHECK								\
+  va_start (args, format);						\
+  ld = va_arg (args, long double *);					\
+  va_end (args);							\
+  if (*ld == -1.0L)							\
+    printf ("OK");							\
+  else									\
+    printf ("ERROR (%.60Lf)", *ld);					\
+  printf ("\n");
+
+#define CHECK_VALUE							\
+  if (value == -1.0L)							\
+    printf ("OK");							\
+  else									\
+    printf ("ERROR (%.60Lf)", value);					\
+  printf ("\n");
+
+static void
+do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
+{
+  long double value;
+  long double *ld;
+  va_list args;
+
+  CLEAR_VALUE
+  printf ("fscanf: ");
+  FSCANF (stream, format, &value);
+  CHECK_VALUE
+
+  CLEAR_VALUE
+  printf ("scanf: ");
+  SCANF (format, &value);
+  CHECK_VALUE
+
+  CLEAR_VALUE
+  printf ("sscanf: ");
+  SSCANF (string, format, &value);
+  CHECK_VALUE
+
+  CLEAR
+  printf ("vfscanf: ");
+  va_start (args, format);
+  VFSCANF (stream, format, args);
+  va_end (args);
+  CHECK
+
+  CLEAR
+  printf ("vscanf: ");
+  va_start (args, format);
+  VSCANF (format, args);
+  va_end (args);
+  CHECK
+
+  CLEAR
+  printf ("vsscanf: ");
+  va_start (args, format);
+  VSSCANF (string, format, args);
+  va_end (args);
+  CHECK
+}
+
+static int
+do_test (void)
+{
+  CHAR string[256];
+  long double ld;
+
+  /* Scan in decimal notation.  */
+  STRCPY (string,
+	  L ("-1.0\n")
+	  L ("-1.0\n") );
+  do_test_call (stdin, string, L("%Lf"), &ld);
+
+  /* Scan in hexadecimal notation.  */
+  STRCPY (string,
+	  L ("-0x1.0p+0\n")
+	  L ("-0x1.0p+0\n") );
+  do_test_call (stdin, string, L("%La"), &ld);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
new file mode 100644
index 0000000000..0759d8afab
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c
@@ -0,0 +1,10 @@
+#define CHAR char
+#define L(x) x
+#define FSCANF fscanf
+#define SSCANF sscanf
+#define SCANF scanf
+#define VFSCANF vfscanf
+#define VSSCANF vsscanf
+#define VSCANF vscanf
+#define STRCPY strcpy
+#include <test-scanf-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
new file mode 100644
index 0000000000..822b4c3607
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+# Testing of *scanf.  IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+cat <<'EOF' |
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+${test_program_prefix} \
+  ${test_program} \
+  - \
+  > ${test_program_output} || status=1
+
+cat <<'EOF' |
+fscanf: OK
+scanf: OK
+sscanf: OK
+vfscanf: OK
+vscanf: OK
+vsscanf: OK
+fscanf: OK
+scanf: OK
+sscanf: OK
+vfscanf: OK
+vscanf: OK
+vsscanf: OK
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+  status=1
+  echo "*** output comparison failed"
+}
+
+exit $status
-- 
2.21.0


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

* [PATCH v2 08/30] ldbl-128ibm-compat: Add wide character scanning functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (6 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 07/30] ldbl-128ibm-compat: Add regular character scanning functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-04 17:46   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 09/30] ldbl-128ibm-compat: Add argp_error and argp_failure Gabriel F. T. Gomes
                   ` (21 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index a1f0f7d74e..031ee0b38f 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -1,3 +1,11 @@
+ifeq ($(subdir),libio)
+ldbl-extra-routines += fwscanf \
+		       swscanf \
+		       wscanf \
+		       vswscanf \
+		       vwscanf
+endif
+
 ifeq ($(subdir),stdio-common)
 ldbl-extra-routines += printf_size \
 		       asprintf \
@@ -23,7 +31,8 @@ ldbl-extra-routines += printf_size \
 		       sscanf \
 		       vfscanf \
 		       vscanf \
-		       vsscanf
+		       vsscanf \
+		       vfwscanf
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -34,6 +43,7 @@ ldbl-extra-routines += printf_size \
 CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-vfscanf-internal.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-vfwscanf-internal.c += -mfloat128 -mabi=ibmlongdouble
 
 # Basic tests for the implementation of long double with IEEE binary128
 # format and for the related redirections in installed headers.
@@ -51,9 +61,18 @@ CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
 $(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link)
 
+tests-internal += test-wscanf-ieee128 test-wscanf-ibm128
+CFLAGS-test-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link)
+
 ifeq ($(run-built-tests),yes)
 tests-special += $(objpfx)test-scanf-ieee128.out
 tests-special += $(objpfx)test-scanf-ibm128.out
+
+tests-special += $(objpfx)test-wscanf-ieee128.out
+tests-special += $(objpfx)test-wscanf-ibm128.out
 endif
 
 $(objpfx)test-scanf-ieee128.out: \
@@ -68,6 +87,18 @@ $(objpfx)test-scanf-ibm128.out: \
 	$(SHELL) $^ '$(test-program-prefix)' $@; \
 	$(evaluate-test)
 
+$(objpfx)test-wscanf-ieee128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-wscanf-ieee128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+$(objpfx)test-wscanf-ibm128.out: \
+  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
+  $(objpfx)test-wscanf-ibm128
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
 tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 7971c7a7d1..8b23fdf56f 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -172,5 +172,13 @@ libc {
     __vfscanfieee128;
     __vscanfieee128;
     __vsscanfieee128;
+
+    __fwscanfieee128;
+    __swscanfieee128;
+    __wscanfieee128;
+
+    __vfwscanfieee128;
+    __vswscanfieee128;
+    __vwscanfieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
new file mode 100644
index 0000000000..b4b10cf9f8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for fwscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libioP.h>
+
+extern int
+___ieee128_fwscanf (FILE *fp, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (fp, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_fwscanf, __fwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
new file mode 100644
index 0000000000..c7dfc24a9b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
@@ -0,0 +1,40 @@
+/* Wrapper for swscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <strfile.h>
+#include <libioP.h>
+
+extern int
+___ieee128_swscanf (const wchar_t *string, const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+  FILE *fp = _IO_strfile_readw (&sf, &wd, string);
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (fp, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_swscanf, __swscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
new file mode 100644
index 0000000000..de4918f536
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vfwscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libioP.h>
+
+extern int
+___ieee128_vfwscanf (FILE *fp, const wchar_t *format, va_list ap)
+{
+  return __vfwscanf_internal (fp, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfwscanf, __vfwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
new file mode 100644
index 0000000000..a241d6bd5e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
@@ -0,0 +1,32 @@
+/* Wrapper for vswscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libioP.h>
+#include <wchar.h>
+#include <strfile.h>
+
+extern int
+___ieee128_vswscanf (const wchar_t *string, const wchar_t *format,
+		     va_list ap)
+{
+  _IO_strfile sf;
+  struct _IO_wide_data wd;
+  FILE *fp = _IO_strfile_readw (&sf, &wd, string);
+  return __vfwscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vswscanf, __vswscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
new file mode 100644
index 0000000000..0944794ac5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vwscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libioP.h>
+
+extern int
+___ieee128_vwscanf (const wchar_t *format, va_list ap)
+{
+  return __vfwscanf_internal (stdin, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vwscanf, __vwscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
new file mode 100644
index 0000000000..417f326cb4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
@@ -0,0 +1,35 @@
+/* Wrapper for wscanf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libioP.h>
+
+extern int
+___ieee128_wscanf (const wchar_t *format, ...)
+{
+  va_list ap;
+  int done;
+
+  va_start (ap, format);
+  done = __vfwscanf_internal (stdin, format, ap,
+			      SCANF_LDBL_USES_FLOAT128);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_wscanf, __wscanfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
new file mode 100644
index 0000000000..ef21fc4741
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
@@ -0,0 +1 @@
+#include <test-wscanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
new file mode 100644
index 0000000000..ef21fc4741
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
@@ -0,0 +1 @@
+#include <test-wscanf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
new file mode 100644
index 0000000000..e93cf3b9bd
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
@@ -0,0 +1,10 @@
+#define CHAR wchar_t
+#define L(x) L##x
+#define FSCANF fwscanf
+#define SSCANF swscanf
+#define SCANF wscanf
+#define VFSCANF vfwscanf
+#define VSSCANF vswscanf
+#define VSCANF vwscanf
+#define STRCPY wcscpy
+#include <test-scanf-ldbl-compat-template.c>
-- 
2.21.0


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

* [PATCH v2 09/30] ldbl-128ibm-compat: Add argp_error and argp_failure
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (7 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 08/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-08 19:57   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions Gabriel F. T. Gomes
                   ` (20 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 031ee0b38f..dc1ceaae7e 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -160,6 +160,20 @@ CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \
 					  -Wno-unused-result
 endif
 
+ifeq ($(subdir),argp)
+ldbl-extra-routines += argp-help
+
+$(objpfx)tst-ieee128-argp.c: tst-ldbl-argp.c
+	cp $< $@
+
+$(objpfx)tst-ibm128-argp.c: tst-ldbl-argp.c
+	cp $< $@
+
+tests-internal += tst-ieee128-argp tst-ibm128-argp
+CFLAGS-tst-ieee128-argp.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi
+endif
+
 # Add IEEE binary128 files as make targets.
 routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 8b23fdf56f..8e80b2bade 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -180,5 +180,8 @@ libc {
     __vfwscanfieee128;
     __vswscanfieee128;
     __vwscanfieee128;
+
+    __argp_errorieee128;
+    __argp_failureieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c
new file mode 100644
index 0000000000..fe77e633df
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c
@@ -0,0 +1,42 @@
+/* Wrapper for argp_error and argp_failure.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <argp.h>
+#include <libio/libioP.h>
+
+void
+___ieee128_argp_error (const struct argp_state *state, const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  __argp_error_internal (state, fmt, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+strong_alias (___ieee128_argp_error, __argp_errorieee128)
+
+void
+___ieee128_argp_failure (const struct argp_state *state, int status,
+			int errnum, const char *fmt, ...)
+{
+  va_list ap;
+  va_start (ap, fmt);
+  __argp_failure_internal (state, status, errnum, fmt, ap,
+			   PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+strong_alias (___ieee128_argp_failure, __argp_failureieee128)
-- 
2.21.0


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

* [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (8 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 09/30] ldbl-128ibm-compat: Add argp_error and argp_failure Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-08 20:22   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 11/30] ldbl-128ibm-compat: Add error.h functions Gabriel F. T. Gomes
                   ` (19 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/misc/errP.h b/misc/errP.h
new file mode 100644
index 0000000000..09e1f72289
--- /dev/null
+++ b/misc/errP.h
@@ -0,0 +1,28 @@
+/* Prototypes for internal err.h functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <err.h>
+
+void
+__vwarnx_internal (const char *format, __gnuc_va_list ap,
+		   unsigned int mode_flags);
+
+void
+__vwarn_internal (const char *format, __gnuc_va_list ap,
+		   unsigned int mode_flags);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index dc1ceaae7e..6bb0bed2fc 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -174,6 +174,10 @@ CFLAGS-tst-ieee128-argp.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
+ifeq ($(subdir),misc)
+ldbl-extra-routines += err
+endif
+
 # Add IEEE binary128 files as make targets.
 routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 8e80b2bade..e2b3dda551 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -183,5 +183,14 @@ libc {
 
     __argp_errorieee128;
     __argp_failureieee128;
+
+    __warnieee128;
+    __warnxieee128;
+    __vwarnieee128;
+    __vwarnxieee128;
+    __errieee128;
+    __errxieee128;
+    __verrieee128;
+    __verrxieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
new file mode 100644
index 0000000000..8a34508e5e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
@@ -0,0 +1,93 @@
+/* Wrappers for err.h functions.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <misc/errP.h>
+#include <libio/libioP.h>
+
+#define VA(call)							\
+{									\
+  va_list ap;								\
+  va_start (ap, format);						\
+  IEEE128_CALL (call);							\
+  va_end (ap);								\
+}
+
+#define IEEE128_ALIAS(name) \
+  strong_alias (___ieee128_##name, __##name##ieee128)
+
+#define IEEE128_DECL(name) ___ieee128_##name
+#define IEEE128_CALL(name) ___ieee128_##name
+
+void
+IEEE128_DECL (vwarn) (const char *format, __gnuc_va_list ap)
+{
+  __vwarn_internal (format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+IEEE128_ALIAS (vwarn)
+
+void
+IEEE128_DECL (vwarnx) (const char *format, __gnuc_va_list ap)
+{
+  __vwarnx_internal (format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+IEEE128_ALIAS (vwarnx)
+
+void
+IEEE128_DECL (warn) (const char *format, ...)
+{
+  VA (vwarn (format, ap))
+}
+IEEE128_ALIAS (warn)
+
+void
+IEEE128_DECL (warnx) (const char *format, ...)
+{
+  VA (vwarnx (format, ap))
+}
+IEEE128_ALIAS (warnx)
+
+void
+IEEE128_DECL (verr) (int status, const char *format, __gnuc_va_list ap)
+{
+  IEEE128_CALL (vwarn) (format, ap);
+  exit (status);
+}
+IEEE128_ALIAS (verr)
+
+void
+IEEE128_DECL (verrx) (int status, const char *format, __gnuc_va_list ap)
+{
+  IEEE128_CALL (vwarnx) (format, ap);
+  exit (status);
+}
+IEEE128_ALIAS (verrx)
+
+void
+IEEE128_DECL (err) (int status, const char *format, ...)
+{
+  VA (verr (status, format, ap))
+}
+IEEE128_ALIAS (err)
+
+void
+IEEE128_DECL (errx) (int status, const char *format, ...)
+{
+  VA (verrx (status, format, ap))
+}
+IEEE128_ALIAS (errx)
-- 
2.21.0


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

* [PATCH v2 11/30] ldbl-128ibm-compat: Add error.h functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (9 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-08 22:21   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 12/30] ldbl-128ibm-compat: Reuse tests for err.h and " Gabriel F. T. Gomes
                   ` (18 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/misc/errorP.h b/misc/errorP.h
new file mode 100644
index 0000000000..c61c49cd61
--- /dev/null
+++ b/misc/errorP.h
@@ -0,0 +1,28 @@
+/* Prototypes for internal error.h functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+
+void
+__error_internal (int status, int errnum, const char *message,
+		  va_list args, unsigned int mode_flags);
+
+void
+__error_at_line_internal (int status, int errnum, const char *file_name,
+			  unsigned int line_number, const char *message,
+			  va_list args, unsigned int mode_flags);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 6bb0bed2fc..a09209a2dd 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -175,7 +175,8 @@ CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
 ifeq ($(subdir),misc)
-ldbl-extra-routines += err
+ldbl-extra-routines += err \
+		       error
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index e2b3dda551..dead38cdcb 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -192,5 +192,8 @@ libc {
     __errxieee128;
     __verrieee128;
     __verrxieee128;
+
+    __errorieee128;
+    __error_at_lineieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c
new file mode 100644
index 0000000000..9c74e060d7
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c
@@ -0,0 +1,51 @@
+/* Wrappers for error.h functions.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <misc/errorP.h>
+#include <libio/libioP.h>
+
+#define IEEE128_ALIAS(name) \
+  strong_alias (___ieee128_##name, __##name##ieee128)
+
+#define IEEE128_DECL(name) ___ieee128_##name
+
+void
+IEEE128_DECL (error) (int status, int errnum, const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  __error_internal (status, errnum, message, ap,
+		    PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+IEEE128_ALIAS (error)
+
+void
+IEEE128_DECL (error_at_line) (int status, int errnum,
+			      const char *file_name,
+			      unsigned int line_number,
+			      const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  __error_at_line_internal (status, errnum, file_name, line_number,
+			    message, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+IEEE128_ALIAS (error_at_line)
-- 
2.21.0


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

* [PATCH v2 12/30] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (10 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 11/30] ldbl-128ibm-compat: Add error.h functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-08 22:25   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
                   ` (17 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

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


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

* [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (11 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 12/30] ldbl-128ibm-compat: Reuse tests for err.h and " Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-08 23:25   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions Gabriel F. T. Gomes
                   ` (16 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

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 and on
_GNU_SOURCE.  When _GNU_SOURCE is not set and when in compatibility with
ISO C99, these modifiers consume a floating-point argument.  Otherwise,
they behave like ascanf, and allocate memory for the output.  This patch
adds the IEEE binary128 variant of these functions for the third long
double format on powerpc64le.

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

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


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

* [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (12 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-08 23:42   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
                   ` (15 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 1f944806e7..9e8237d075 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -47,7 +47,10 @@ ldbl-extra-routines += printf_size \
 		       isoc99_sscanf \
 		       isoc99_vfscanf \
 		       isoc99_vscanf \
-		       isoc99_vsscanf
+		       isoc99_vsscanf \
+		       obprintf \
+		       obstack_chk \
+		       vobstack_chk
 
 # Printing long double values with IEEE binary128 format reuses part
 # of the internal float128 implementation (__printf_fp, __printf_fphex,
@@ -70,6 +73,14 @@ tests-internal += test-wprintf-ieee128 test-wprintf-ibm128
 CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 
+tests-internal += test-obstack-ieee128 test-obstack-ibm128
+CFLAGS-test-obstack-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-obstack-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-obstack-chk-ieee128 test-obstack-chk-ibm128
+CFLAGS-test-obstack-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-obstack-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
 tests-internal += test-scanf-ieee128 test-scanf-ibm128
 CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 23c2fd9793..f59dfb59fe 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -165,6 +165,11 @@ libc {
     __vswprintf_chkieee128;
     __vwprintf_chkieee128;
 
+    __obstack_printfieee128;
+    __obstack_vprintfieee128;
+    __obstack_printf_chkieee128;
+    __obstack_vprintf_chkieee128;
+
     __fscanfieee128;
     __scanfieee128;
     __sscanfieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
new file mode 100644
index 0000000000..924838eed5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c
@@ -0,0 +1,42 @@
+/* Wrapper for obstack_vprintf and obstack_printf.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+int
+__ieee128_obstack_vprintf (struct obstack *obstack, const char *format,
+			   va_list ap)
+{
+  return __obstack_vprintf_internal (obstack, format, ap,
+				     PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (__ieee128_obstack_vprintf, __obstack_vprintfieee128)
+
+int
+__ieee128_obstack_printf (struct obstack *obstack, const char *format, ...)
+{
+  int result;
+  va_list ap;
+  va_start (ap, format);
+  result = __obstack_vprintf_internal (obstack, format, ap,
+				       PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+  return result;
+}
+strong_alias (__ieee128_obstack_printf, __obstack_printfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c
new file mode 100644
index 0000000000..194589ca26
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c
@@ -0,0 +1,39 @@
+/* Wrapper for __obstack_printf_chk.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_obstack_printf_chk (struct obstack *obstack, int flag,
+			       const char *format, ...)
+{
+  va_list ap;
+  int done;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, format);
+  done = __obstack_vprintf_internal (obstack, format, ap, mode);
+  va_end (ap);
+
+  return done;
+}
+strong_alias (___ieee128_obstack_printf_chk, __obstack_printf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c
new file mode 100644
index 0000000000..fa5182aac9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __obstack_vprintf_chk.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128__obstack_vprintf_chk  (struct obstack *obstack, int flag,
+				  const char *format, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  return __obstack_vprintf_internal (obstack, format, ap, mode);
+}
+strong_alias (___ieee128__obstack_vprintf_chk, __obstack_vprintf_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
new file mode 100644
index 0000000000..ca4c9f2d22
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-obstack-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
new file mode 100644
index 0000000000..ca4c9f2d22
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-obstack-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
new file mode 100644
index 0000000000..feae8f21c6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 2
+#define OBSTACK_FUNCTION __obstack_printf_chk
+#define OBSTACK_FUNCTION_PARAMS (&ob, 1, "%.30Lf", ld)
+#define VOBSTACK_FUNCTION __obstack_vprintf_chk
+#define VOBSTACK_FUNCTION_PARAMS (&ob, 1, "%.30Lf", ap)
+#include <test-obstack-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
new file mode 100644
index 0000000000..be88675030
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
@@ -0,0 +1 @@
+#include <test-obstack-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
new file mode 100644
index 0000000000..be88675030
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c
@@ -0,0 +1 @@
+#include <test-obstack-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
new file mode 100644
index 0000000000..c82ddc4355
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c
@@ -0,0 +1,64 @@
+/* Test for the long double variants of obstrack*printf functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <malloc.h>
+#include <obstack.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include <support/check.h>
+
+#define obstack_chunk_alloc malloc
+#define obstack_chunk_free free
+
+static void
+do_test_call (void *last, ...)
+{
+  const char *expected = "-1.000000000000000000000000000000";
+  char *actual = NULL;
+  long double ld = -1;
+  struct obstack ob;
+  va_list ap;
+
+  obstack_init (&ob);
+  OBSTACK_FUNCTION OBSTACK_FUNCTION_PARAMS;
+  actual = (char *) obstack_finish (&ob);
+  TEST_VERIFY (strncmp (expected, actual, 33) == 0);
+  obstack_free (&ob, NULL);
+  actual = NULL;
+
+  obstack_init (&ob);
+  va_start (ap, last);
+  VOBSTACK_FUNCTION VOBSTACK_FUNCTION_PARAMS;
+  va_end (ap);
+  actual = (char *) obstack_finish (&ob);
+  TEST_VERIFY (strncmp (expected, actual, 33) == 0);
+  obstack_free (&ob, NULL);
+  actual = NULL;
+}
+
+static int
+do_test (void)
+{
+  long double ld = -1;
+  do_test_call (NULL, ld);
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c
new file mode 100644
index 0000000000..3849d25ef1
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 0
+#define OBSTACK_FUNCTION obstack_printf
+#define OBSTACK_FUNCTION_PARAMS (&ob, "%.30Lf", ld)
+#define VOBSTACK_FUNCTION obstack_vprintf
+#define VOBSTACK_FUNCTION_PARAMS (&ob, "%.30Lf", ap)
+#include <test-obstack-ldbl-compat-template.c>
-- 
2.21.0


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

* [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (13 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-14 17:47   ` Paul E Murphy
  2019-11-14 18:25   ` Florian Weimer
  2019-10-25 15:33 ` [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Gabriel F. T. Gomes
                   ` (14 subsequent siblings)
  29 siblings, 2 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

Changes since v1:

  - Moved the test to a container, which stopped messages being written
    to the system log.

Comment from v1:

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

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 9e8237d075..d774c3b1d7 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -244,7 +244,8 @@ endif
 
 ifeq ($(subdir),misc)
 ldbl-extra-routines += err \
-		       error
+		       error \
+		       syslog
 
 tests-internal += tst-ibm128-warn tst-ieee128-warn
 tests-internal += tst-ibm128-error tst-ieee128-error
@@ -260,6 +261,14 @@ CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi
 
 CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+
+tests-container += test-syslog-ieee128 test-syslog-ibm128
+CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-syslog-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-container += test-syslog-chk-ieee128 test-syslog-chk-ibm128
+CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index f59dfb59fe..b7aa9f7993 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -170,6 +170,11 @@ libc {
     __obstack_printf_chkieee128;
     __obstack_vprintf_chkieee128;
 
+    __syslogieee128;
+    __vsyslogieee128;
+    __syslog_chkieee128;
+    __vsyslog_chkieee128;
+
     __fscanfieee128;
     __scanfieee128;
     __sscanfieee128;
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c
new file mode 100644
index 0000000000..fa16cc9aaf
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c
@@ -0,0 +1,65 @@
+/* Wrapper for syslog.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <libioP.h>
+#include <syslog.h>
+
+void
+___ieee128_syslog (int pri, const char *fmt, ...)
+{
+  va_list ap;
+
+  va_start (ap, fmt);
+  __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_USES_FLOAT128);
+  va_end (ap);
+}
+strong_alias (___ieee128_syslog, __syslogieee128)
+
+void
+___ieee128_vsyslog (int pri, const char *fmt, va_list ap)
+{
+  __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsyslog, __vsyslogieee128)
+
+void
+___ieee128_syslog_chk (int pri, int flag, const char *fmt, ...)
+{
+  va_list ap;
+
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  va_start (ap, fmt);
+  __vsyslog_internal (pri, fmt, ap, mode);
+  va_end (ap);
+}
+strong_alias (___ieee128_syslog_chk, __syslog_chkieee128)
+
+void
+___ieee128_vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
+{
+  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
+  if (flag > 0)
+    mode |= PRINTF_FORTIFY;
+
+  __vsyslog_internal (pri, fmt, ap, mode);
+}
+strong_alias (___ieee128_vsyslog_chk, __vsyslog_chkieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
new file mode 100644
index 0000000000..bf42582687
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c
@@ -0,0 +1 @@
+#include <test-syslog-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
new file mode 100644
index 0000000000..bf42582687
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c
@@ -0,0 +1 @@
+#include <test-syslog-chk-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
new file mode 100644
index 0000000000..513b2d2064
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 2
+#define SYSLOG_FUNCTION __syslog_chk
+#define SYSLOG_FUNCTION_PARAMS (LOG_DEBUG, 1, "%Lf\n", ld)
+#define VSYSLOG_FUNCTION __vsyslog_chk
+#define VSYSLOG_FUNCTION_PARAMS (LOG_DEBUG, 1, "%Lf\n", ap)
+#include <test-syslog-ldbl-compat-template.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
new file mode 100644
index 0000000000..8e64440e8c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c
@@ -0,0 +1 @@
+#include <test-syslog-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
new file mode 100644
index 0000000000..8e64440e8c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c
@@ -0,0 +1 @@
+#include <test-syslog-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
new file mode 100644
index 0000000000..11454a2245
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c
@@ -0,0 +1,67 @@
+/* Test for the long double variants of *syslog* functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdarg.h>
+#include <stddef.h>
+#include <syslog.h>
+
+#include <support/capture_subprocess.h>
+#include <support/check.h>
+
+static void
+do_test_one_call (void *last, ...)
+{
+  long double ld = -1;
+  va_list ap;
+
+  /* Make syslog functions write to stderr with LOG_PERROR, so that it
+     can be captured by support_capture_subprocess and verified.  */
+  openlog ("test-syslog", LOG_PERROR, LOG_USER);
+
+  /* Call syslog functions that take a format string.  */
+  SYSLOG_FUNCTION SYSLOG_FUNCTION_PARAMS;
+  va_start (ap, last);
+  VSYSLOG_FUNCTION VSYSLOG_FUNCTION_PARAMS;
+  va_end (ap);
+}
+
+static void
+do_test_call (void)
+{
+  long double ld = -1;
+  do_test_one_call (NULL, ld);
+}
+
+static int
+do_test (void)
+{
+  struct support_capture_subprocess result;
+  result = support_capture_subprocess ((void *) &do_test_call, NULL);
+
+  do_test_call ();
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "test-syslog: -1.000000\n"
+    "test-syslog: -1.000000\n";
+  TEST_COMPARE_STRING (expected, result.err.buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c
new file mode 100644
index 0000000000..ff0c0a5813
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c
@@ -0,0 +1,6 @@
+#define _FORTIFY_SOURCE 0
+#define SYSLOG_FUNCTION syslog
+#define SYSLOG_FUNCTION_PARAMS (LOG_DEBUG, "%Lf\n", ld)
+#define VSYSLOG_FUNCTION vsyslog
+#define VSYSLOG_FUNCTION_PARAMS (LOG_DEBUG, "%Lf\n", ap)
+#include <test-syslog-ldbl-compat-template.c>
-- 
2.21.0


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

* [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (14 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-14 18:03   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Gabriel F. T. Gomes
                   ` (13 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/include/monetary.h b/include/monetary.h
index f59bdf9150..240925e87d 100644
--- a/include/monetary.h
+++ b/include/monetary.h
@@ -15,5 +15,6 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
    same format as double, in which case the flag should be set to one,
    or as another format, otherwise.  */
 #define STRFMON_LDBL_IS_DBL 0x0001
+#define STRFMON_LDBL_USES_FLOAT128  0x0002
 
 #endif
diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
index 134dad6963..b26cec24e2 100644
--- a/stdlib/strfmon_l.c
+++ b/stdlib/strfmon_l.c
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <string.h>
 #include "../locale/localeinfo.h"
+#include <bits/floatn.h>
 
 
 #define out_char(Ch)							      \
@@ -96,6 +97,9 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       {
 	double dbl;
 	long double ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+      _Float128 f128;
+#endif
       }
       fpnum;
       int int_format;
@@ -106,6 +110,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       int group;
       char pad;
       int is_long_double;
+      int is_binary128;
       int p_sign_posn;
       int n_sign_posn;
       int sign_posn;
@@ -150,6 +155,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       group = 1;			/* Print digits grouped.  */
       pad = ' ';			/* Fill character is <SP>.  */
       is_long_double = 0;		/* Double argument by default.  */
+      is_binary128 = 0;		/* Long double argument by default.  */
       p_sign_posn = -2;			/* This indicates whether the */
       n_sign_posn = -2;			/* '(' flag is given.  */
       width = -1;			/* No width specified so far.  */
@@ -270,6 +276,10 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
 	  ++fmt;
 	  if (__glibc_likely ((flags & STRFMON_LDBL_IS_DBL) == 0))
 	    is_long_double = 1;
+#if __HAVE_DISTINCT_FLOAT128
+	  if (__glibc_likely ((flags & STRFMON_LDBL_USES_FLOAT128) != 0))
+	    is_binary128 = is_long_double;
+#endif
 	}
 
       /* Handle format specifier.  */
@@ -324,10 +334,22 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       /* Now it's time to get the value.  */
       if (is_long_double == 1)
 	{
-	  fpnum.ldbl = va_arg (ap, long double);
-	  is_negative = fpnum.ldbl < 0;
-	  if (is_negative)
-	    fpnum.ldbl = -fpnum.ldbl;
+#if __HAVE_DISTINCT_FLOAT128
+	  if (is_binary128 == 1)
+	    {
+	      fpnum.f128 = va_arg (ap, _Float128);
+	      is_negative = fpnum.f128 < 0;
+	      if (is_negative)
+	        fpnum.f128 = -fpnum.f128;
+	    }
+	  else
+#endif
+	  {
+	    fpnum.ldbl = va_arg (ap, long double);
+	    is_negative = fpnum.ldbl < 0;
+	    if (is_negative)
+	      fpnum.ldbl = -fpnum.ldbl;
+	  }
 	}
       else
 	{
@@ -517,6 +539,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
       info.width = left_prec + (right_prec ? (right_prec + 1) : 0);
       info.spec = 'f';
       info.is_long_double = is_long_double;
+      info.is_binary128 = is_binary128;
       info.group = group;
       info.pad = pad;
       info.extra = 1;		/* This means use values from LC_MONETARY.  */
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index d774c3b1d7..bea3823d1c 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -271,6 +271,18 @@ CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 endif
 
+ifeq ($(subdir),stdlib)
+ldbl-extra-routines += strfmon strfmon_l
+
+# Printing long double values with IEEE binary128 format reuses part
+# of the internal float128 implementation (__printf_fp, __printf_fphex,
+# and __float128 variables and union members).  Thus, the compilation of
+# the following files, must have -mfloat128 passed to the compiler.
+# Also, guarantee that they are compiled in IBM long double mode.
+CFLAGS-strfmon.c += -mfloat128 -mabi=ibmlongdouble
+CFLAGS-strfmon_l.c += -mfloat128 -mabi=ibmlongdouble
+endif
+
 # Add IEEE binary128 files as make targets.
 routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r))
 
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index b7aa9f7993..da8e0ce7ee 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -221,5 +221,8 @@ libc {
 
     __errorieee128;
     __error_at_lineieee128;
+
+    __strfmonieee128;
+    __strfmon_lieee128;
   }
 }
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
new file mode 100644
index 0000000000..743f7cdcf6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
@@ -0,0 +1,35 @@
+/* Wrapper for strfmon.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <monetary.h>
+#include <stdarg.h>
+#include <locale/localeinfo.h>
+
+ssize_t
+___ieee128_strfmon (char *s, size_t maxsize, const char *format, ...)
+{
+  va_list ap;
+  ssize_t res;
+
+  va_start (ap, format);
+  res = __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE,
+                                       format, ap, STRFMON_LDBL_USES_FLOAT128);
+  va_end (ap);
+  return res;
+}
+weak_alias (___ieee128_strfmon, __strfmonieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c
new file mode 100644
index 0000000000..2ad970af98
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c
@@ -0,0 +1,35 @@
+/* Wrapper for strfmon_l.  IEEE128 version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <monetary.h>
+#include <stdarg.h>
+#include <locale/localeinfo.h>
+
+ssize_t
+___ieee128_strfmon_l (char *s, size_t maxsize, locale_t loc, const char *format, ...)
+{
+  va_list ap;
+  ssize_t res;
+
+  va_start (ap, format);
+  res = __vstrfmon_l_internal (s, maxsize, loc,
+                                       format, ap, STRFMON_LDBL_USES_FLOAT128);
+  va_end (ap);
+  return res;
+}
+weak_alias (___ieee128_strfmon_l, __strfmon_lieee128)
-- 
2.21.0


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

* [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (15 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-14 18:11   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Gabriel F. T. Gomes
                   ` (12 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index bea3823d1c..83c2c43ea4 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -281,6 +281,12 @@ ldbl-extra-routines += strfmon strfmon_l
 # Also, guarantee that they are compiled in IBM long double mode.
 CFLAGS-strfmon.c += -mfloat128 -mabi=ibmlongdouble
 CFLAGS-strfmon_l.c += -mfloat128 -mabi=ibmlongdouble
+
+tests-internal += test-strfmon-ibm128 test-strfmon-ieee128
+CFLAGS-test-strfmon-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-test-strfmon-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+$(objpfx)tst-strfmon-ibm128.out: $(gen-locales)
+$(objpfx)tst-strfmon-ieee128.out: $(gen-locales)
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
new file mode 100644
index 0000000000..5d1def86af
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
@@ -0,0 +1 @@
+#include <test-strfmon-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
new file mode 100644
index 0000000000..5d1def86af
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
@@ -0,0 +1 @@
+#include <test-strfmon-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
new file mode 100644
index 0000000000..1338bd8493
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
@@ -0,0 +1,59 @@
+/* Test for the long double variants of strfmon* functions.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <locale/locale.h>
+#include <monetary.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  size_t written;
+  char buffer[64];
+  char *bufptr = buffer;
+  locale_t loc;
+
+  /* Using the C locale is enough for the purpose of this test case,
+     i.e.: to test that strfmon correctly reads long double values with
+     binary128 format.  Grouping and currency are irrelevant, here.  */
+  setlocale (LC_MONETARY, "C");
+  loc = newlocale (LC_MONETARY_MASK, "C", (locale_t) 0);
+
+  /* Write to the buffer.  */
+  written = strfmon (bufptr, 32, "%.10i, %.10Li\n",
+                     (double) -2, (long double) -1);
+  if (written < 0)
+    support_record_failure ();
+  else
+    bufptr += written;
+  written = strfmon_l (bufptr, 32, loc, "%.10i, %.10Li\n",
+                       (double) -2, (long double) -1);
+  if (written < 0)
+    support_record_failure ();
+
+  /* Compare against the expected output.  */
+  const char *expected =
+    "-2.0000000000, -1.0000000000\n"
+    "-2.0000000000, -1.0000000000\n";
+  TEST_COMPARE_STRING (expected, buffer);
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.0


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

* [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (16 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-11-14 18:25   ` Paul E Murphy
  2019-10-25 15:33 ` [PATCH v2 19/30] Refactor *cvt functions implementation (1/5) Gabriel F. T. Gomes
                   ` (11 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

-- 8< --
Since the commit

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

    ldbl-128ibm-compat: Introduce ieee128 symbols

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

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 83c2c43ea4..6f1794fac8 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -13,6 +13,12 @@ ldbl-extra-routines += isoc99_fwscanf \
 		       isoc99_vfwscanf \
 		       isoc99_vswscanf \
 		       isoc99_vwscanf
+
+tests-internal += test-wcstold-ibm128 test-wcstold-ieee128
+CFLAGS-test-wcstold-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-wcstold-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-wcstold-ieee128: gnulib-tests += $(f128-loader-link)
 endif
 
 ifeq ($(subdir),stdio-common)
@@ -287,6 +293,12 @@ CFLAGS-test-strfmon-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
 CFLAGS-test-strfmon-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
 $(objpfx)tst-strfmon-ibm128.out: $(gen-locales)
 $(objpfx)tst-strfmon-ieee128.out: $(gen-locales)
+
+tests-internal += test-strfrom-ibm128 test-strfrom-ieee128
+CFLAGS-test-strfrom-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-strfrom-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+$(objpfx)test-strfrom-ieee128: gnulib-tests += $(f128-loader-link)
 endif
 
 # Add IEEE binary128 files as make targets.
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
new file mode 100644
index 0000000000..93887706b9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
@@ -0,0 +1 @@
+#include <test-strfrom-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
new file mode 100644
index 0000000000..93887706b9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c
@@ -0,0 +1 @@
+#include <test-strfrom-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
new file mode 100644
index 0000000000..f32548fe90
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
@@ -0,0 +1,49 @@
+/* Test for the long double variants of strfroml and strtold.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdlib.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  int written;
+  char buffer[64];
+  char *bufptr = buffer;
+  const char *expected = "-1.0000000000";
+  long double read;
+
+  /* Write to the buffer.  */
+  written = strfroml (bufptr, 64, "%.10f", (long double) -1);
+  if (written < 0)
+    support_record_failure ();
+
+  /* Compare against the expected output.  */
+  TEST_COMPARE_STRING (expected, buffer);
+
+  /* Read from the buffer.  */
+  read = strtold (expected, NULL);
+
+  if (read != (long double) -1)
+    support_record_failure ();
+
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
new file mode 100644
index 0000000000..4d60692eeb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
@@ -0,0 +1 @@
+#include <test-wcstold-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
new file mode 100644
index 0000000000..4d60692eeb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c
@@ -0,0 +1 @@
+#include <test-wcstold-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
new file mode 100644
index 0000000000..8b9e300147
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
@@ -0,0 +1,36 @@
+/* Test for the long double variant of wcstold.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <wchar.h>
+
+#include <support/check.h>
+
+static int
+do_test (void)
+{
+  const wchar_t *input = L"-1.0000000000";
+  long double read;
+
+  read = wcstold (input, NULL);
+  if (read != (long double) -1)
+    support_record_failure ();
+
+  return 0;
+}
+
+#include <support/test-driver.c>
-- 
2.21.0


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

* [PATCH v2 19/30] Refactor *cvt functions implementation (1/5)
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (17 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Gabriel F. T. Gomes
@ 2019-10-25 15:33 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 20/30] Refactor *cvt functions implementation (2/5) Gabriel F. T. Gomes
                   ` (10 subsequent siblings)
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:33 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

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

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


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

* [PATCH v2 20/30] Refactor *cvt functions implementation (2/5)
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (18 preceding siblings ...)
  2019-10-25 15:33 ` [PATCH v2 19/30] Refactor *cvt functions implementation (1/5) Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 21/30] Refactor *cvt functions implementation (3/5) Gabriel F. T. Gomes
                   ` (9 subsequent siblings)
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/misc/efgcvt-dbl-macros.h b/misc/efgcvt-dbl-macros.h
new file mode 100644
index 0000000000..08640e9639
--- /dev/null
+++ b/misc/efgcvt-dbl-macros.h
@@ -0,0 +1,52 @@
+/* Macros for the implementation of *cvt functions, double version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <float.h>
+
+#define FLOAT_TYPE double
+#define FUNC_PREFIX
+#define FLOAT_FMT_FLAG
+#define FLOAT_NAME_EXT
+#define FLOAT_MIN_10_EXP DBL_MIN_10_EXP
+/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we
+   don't have log10 available in the preprocessor.  */
+#define MAXDIG (NDIGIT_MAX + 3)
+#define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG)
+#if DBL_MANT_DIG == 53
+# define NDIGIT_MAX 17
+#elif DBL_MANT_DIG == 24
+# define NDIGIT_MAX 9
+#elif DBL_MANT_DIG == 56
+# define NDIGIT_MAX 18
+#else
+/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
+   compile time constant here, so we cannot use it.  */
+# error "NDIGIT_MAX must be precomputed"
+# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
+#endif
+#if DBL_MIN_10_EXP == -37
+# define FLOAT_MIN_10_NORM	1.0e-37
+#elif DBL_MIN_10_EXP == -307
+# define FLOAT_MIN_10_NORM	1.0e-307
+#elif DBL_MIN_10_EXP == -4931
+# define FLOAT_MIN_10_NORM	1.0e-4931
+#else
+/* libc can't depend on libm.  */
+# error "FLOAT_MIN_10_NORM must be precomputed"
+# define FLOAT_MIN_10_NORM	exp10 (DBL_MIN_10_EXP)
+#endif
diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index 492e4e8086..f8650a934f 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -20,34 +20,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/param.h>
-#include <float.h>
 #include <libc-lock.h>
 #include <math_ldbl_opt.h>
 
-#ifndef FLOAT_TYPE
-# define FLOAT_TYPE double
-# define FUNC_PREFIX
-# define FLOAT_FMT_FLAG
-/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we
-   don't have log10 available in the preprocessor.  */
-# define MAXDIG (NDIGIT_MAX + 3)
-# define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG)
-# if DBL_MANT_DIG == 53
-#  define NDIGIT_MAX 17
-# elif DBL_MANT_DIG == 24
-#  define NDIGIT_MAX 9
-# elif DBL_MANT_DIG == 56
-#  define NDIGIT_MAX 18
-# else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-#  error "NDIGIT_MAX must be precomputed"
-#  define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
-# endif
-#else
-# define LONG_DOUBLE_CVT
-#endif
-
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
 #define __APPEND(a, b) __APPEND2 (a, b)
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
index 981249850c..74baad78a0 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -17,7 +17,6 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
-#include <float.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -26,38 +25,6 @@
 #include <sys/param.h>
 #include <math_ldbl_opt.h>
 
-#ifndef FLOAT_TYPE
-# define FLOAT_TYPE double
-# define FUNC_PREFIX
-# define FLOAT_FMT_FLAG
-# define FLOAT_NAME_EXT
-# define FLOAT_MIN_10_EXP DBL_MIN_10_EXP
-# if DBL_MANT_DIG == 53
-#  define NDIGIT_MAX 17
-# elif DBL_MANT_DIG == 24
-#  define NDIGIT_MAX 9
-# elif DBL_MANT_DIG == 56
-#  define NDIGIT_MAX 18
-# else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-#  error "NDIGIT_MAX must be precomputed"
-#  define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0)))
-# endif
-# if DBL_MIN_10_EXP == -37
-#  define FLOAT_MIN_10_NORM	1.0e-37
-# elif DBL_MIN_10_EXP == -307
-#  define FLOAT_MIN_10_NORM	1.0e-307
-# elif DBL_MIN_10_EXP == -4931
-#  define FLOAT_MIN_10_NORM	1.0e-4931
-# else
-/* libc can't depend on libm.  */
-#  error "FLOAT_MIN_10_NORM must be precomputed"
-#  define FLOAT_MIN_10_NORM	exp10 (DBL_MIN_10_EXP)
-# endif
-#else
-# define LONG_DOUBLE_CVT
-#endif
 
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
-- 
2.21.0


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

* [PATCH v2 21/30] Refactor *cvt functions implementation (3/5)
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (19 preceding siblings ...)
  2019-10-25 15:34 ` [PATCH v2 20/30] Refactor *cvt functions implementation (2/5) Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 22/30] Refactor *cvt functions implementation (4/5) Gabriel F. T. Gomes
                   ` (8 subsequent siblings)
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

No changes since v1.

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

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

diff --git a/misc/efgcvt-ldbl-macros.h b/misc/efgcvt-ldbl-macros.h
new file mode 100644
index 0000000000..ff97b13d7f
--- /dev/null
+++ b/misc/efgcvt-ldbl-macros.h
@@ -0,0 +1,59 @@
+/* Macros for the implementation of *cvt functions, long double version.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <float.h>
+
+#define FLOAT_TYPE long double
+#define FUNC_PREFIX q
+#define FLOAT_FMT_FLAG "L"
+#define FLOAT_NAME_EXT l
+#define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP
+/* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
+   we don't have log10 available in the preprocessor.  Since we cannot
+   assume anything on the used `long double' format be generous.  */
+#define MAXDIG (NDIGIT_MAX + 12)
+#define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG)
+#if LDBL_MANT_DIG == 64
+# define NDIGIT_MAX 21
+#elif LDBL_MANT_DIG == 53
+# define NDIGIT_MAX 17
+#elif LDBL_MANT_DIG == 113
+# define NDIGIT_MAX 36
+#elif LDBL_MANT_DIG == 106
+# define NDIGIT_MAX 34
+#elif LDBL_MANT_DIG == 56
+# define NDIGIT_MAX 18
+#else
+/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
+   compile time constant here, so we cannot use it.  */
+# error "NDIGIT_MAX must be precomputed"
+# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
+#endif
+#if LDBL_MIN_10_EXP == -37
+# define FLOAT_MIN_10_NORM	1.0e-37L
+#elif LDBL_MIN_10_EXP == -291
+# define FLOAT_MIN_10_NORM	1.0e-291L
+#elif LDBL_MIN_10_EXP == -307
+# define FLOAT_MIN_10_NORM	1.0e-307L
+#elif LDBL_MIN_10_EXP == -4931
+# define FLOAT_MIN_10_NORM	1.0e-4931L
+#else
+/* libc can't depend on libm.  */
+# error "FLOAT_MIN_10_NORM must be precomputed"
+# define FLOAT_MIN_10_NORM	exp10l (LDBL_MIN_10_EXP)
+#endif
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index 4fcadfcdc2..6987fb0db1 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -16,31 +16,4 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <float.h>
-
-#define FLOAT_TYPE long double
-#define FUNC_PREFIX q
-#define FLOAT_FMT_FLAG "L"
-/* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but
-   we don't have log10 available in the preprocessor.  Since we cannot
-   assume anything on the used `long double' format be generous.  */
-#define MAXDIG (NDIGIT_MAX + 12)
-#define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG)
-#if LDBL_MANT_DIG == 64
-# define NDIGIT_MAX 21
-#elif LDBL_MANT_DIG == 53
-# define NDIGIT_MAX 17
-#elif LDBL_MANT_DIG == 113
-# define NDIGIT_MAX 36
-#elif LDBL_MANT_DIG == 106
-# define NDIGIT_MAX 34
-#elif LDBL_MANT_DIG == 56
-# define NDIGIT_MAX 18
-#else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-# error "NDIGIT_MAX must be precomputed"
-# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
-#endif
-
 #include "efgcvt.c"
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index 8f4d8b9f7a..e1f074b49c 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -17,41 +17,4 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include <float.h>
-
-#define FLOAT_TYPE long double
-#define FUNC_PREFIX q
-#define FLOAT_FMT_FLAG "L"
-#define FLOAT_NAME_EXT l
-#define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP
-#if LDBL_MANT_DIG == 64
-# define NDIGIT_MAX 21
-#elif LDBL_MANT_DIG == 53
-# define NDIGIT_MAX 17
-#elif LDBL_MANT_DIG == 113
-# define NDIGIT_MAX 36
-#elif LDBL_MANT_DIG == 106
-# define NDIGIT_MAX 34
-#elif LDBL_MANT_DIG == 56
-# define NDIGIT_MAX 18
-#else
-/* See IEEE 854 5.6, table 2 for this formula.  Unfortunately we need a
-   compile time constant here, so we cannot use it.  */
-# error "NDIGIT_MAX must be precomputed"
-# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0)))
-#endif
-#if LDBL_MIN_10_EXP == -37
-# define FLOAT_MIN_10_NORM	1.0e-37L
-#elif LDBL_MIN_10_EXP == -291
-# define FLOAT_MIN_10_NORM	1.0e-291L
-#elif LDBL_MIN_10_EXP == -307
-# define FLOAT_MIN_10_NORM	1.0e-307L
-#elif LDBL_MIN_10_EXP == -4931
-# define FLOAT_MIN_10_NORM	1.0e-4931L
-#else
-/* libc can't depend on libm.  */
-# error "FLOAT_MIN_10_NORM must be precomputed"
-# define FLOAT_MIN_10_NORM	exp10l (LDBL_MIN_10_EXP)
-#endif
-
 #include "efgcvt_r.c"
-- 
2.21.0


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

* [PATCH v2 22/30] Refactor *cvt functions implementation (4/5)
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (20 preceding siblings ...)
  2019-10-25 15:34 ` [PATCH v2 21/30] Refactor *cvt functions implementation (3/5) Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 23/30] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
                   ` (7 subsequent siblings)
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

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

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

This patch splits the definition of the symbol names into separate files
for double and long double, which will make it easier to define new
symbol names for IEEE long double functions on powerpc64le.
---
 misc/efgcvt-template.c   | 23 -----------------------
 misc/efgcvt.c            | 34 ++++++++++++++++++++++++++++++++++
 misc/efgcvt_r-template.c | 27 ---------------------------
 misc/efgcvt_r.c          | 37 +++++++++++++++++++++++++++++++++++++
 misc/qefgcvt.c           | 14 ++++++++++++++
 misc/qefgcvt_r.c         | 17 +++++++++++++++++
 6 files changed, 102 insertions(+), 50 deletions(-)
 create mode 100644 misc/efgcvt.c
 create mode 100644 misc/efgcvt_r.c

diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index f8650a934f..aeb4e1ea01 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -76,26 +76,3 @@ __APPEND (FUNC_PREFIX, gcvt) (FLOAT_TYPE value, int ndigit, char *buf)
   sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
   return buf;
 }
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# ifdef LONG_DOUBLE_CVT
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
-#  define cvt_symbol_1(lib, local, symbol, version) \
-    versioned_symbol (lib, local, symbol, version)
-# else
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (q, symbol), GLIBC_2_0); \
-  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(lib, local, symbol, version) \
-  compat_symbol (lib, local, symbol, version)
-# endif
-#else
-# define cvt_symbol(symbol) \
-  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#endif
-cvt_symbol(fcvt);
-cvt_symbol(ecvt);
-cvt_symbol(gcvt);
diff --git a/misc/efgcvt.c b/misc/efgcvt.c
new file mode 100644
index 0000000000..81ac60415e
--- /dev/null
+++ b/misc/efgcvt.c
@@ -0,0 +1,34 @@
+/* Double versions of *cvt_r functions.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "efgcvt.c"
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# define cvt_symbol(symbol) \
+  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
+	      APPEND (q, symbol), GLIBC_2_0); \
+  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+# define cvt_symbol_1(lib, local, symbol, version) \
+  compat_symbol (lib, local, symbol, version)
+#else
+# define cvt_symbol(symbol) \
+  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+#endif
+cvt_symbol (fcvt);
+cvt_symbol (ecvt);
+cvt_symbol (gcvt);
diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c
index 74baad78a0..f215dbd345 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -200,30 +200,3 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
   *decpt += exponent;
   return 0;
 }
-
-#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# ifdef LONG_DOUBLE_CVT
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (FUNC_PREFIX, symbol), GLIBC_2_4)
-#  define cvt_symbol_1(lib, local, symbol, version) \
-    libc_hidden_def (local) \
-    versioned_symbol (lib, local, symbol, version)
-# else
-#  define cvt_symbol(symbol) \
-  cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \
-	      APPEND (q, symbol), GLIBC_2_0); \
-  weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(lib, local, symbol, version) \
-  libc_hidden_def (local) \
-  compat_symbol (lib, local, symbol, version)
-# endif
-#else
-# define cvt_symbol(symbol) \
-  cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
-#  define cvt_symbol_1(local, symbol) \
-  libc_hidden_def (local) \
-  weak_alias (local, symbol)
-#endif
-cvt_symbol(fcvt_r);
-cvt_symbol(ecvt_r);
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
new file mode 100644
index 0000000000..aa0eb8ca43
--- /dev/null
+++ b/misc/efgcvt_r.c
@@ -0,0 +1,37 @@
+/* Double versions of reentrant *cvt_r functions.
+   Copyright (C) 2019 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "efgcvt_r.c"
+
+#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
+# define cvt_symbol(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) \
+  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) \
+  libc_hidden_def (local) \
+  weak_alias (local, symbol)
+#endif
+cvt_symbol (fcvt_r);
+cvt_symbol (ecvt_r);
diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c
index 6987fb0db1..ea48c6b48a 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -17,3 +17,17 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include "efgcvt.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)
+#else
+# define cvt_symbol(symbol) \
+  strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol))
+#endif
+cvt_symbol(fcvt);
+cvt_symbol(ecvt);
+cvt_symbol(gcvt);
diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c
index e1f074b49c..d2f36e6d2a 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -18,3 +18,20 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include "efgcvt_r.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) \
+  libc_hidden_def (local) \
+  versioned_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) \
+  libc_hidden_def (local) \
+  weak_alias (local, symbol)
+#endif
+cvt_symbol(fcvt_r);
+cvt_symbol(ecvt_r);
-- 
2.21.0


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

* [PATCH v2 23/30] Refactor *cvt functions implementation (5/5)
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (21 preceding siblings ...)
  2019-10-25 15:34 ` [PATCH v2 22/30] Refactor *cvt functions implementation (4/5) Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-11-14 23:12   ` Paul E Murphy
  2019-10-25 15:34 ` [PATCH v2 24/30] ldbl-128ibm-compat: Add *cvt functions Gabriel F. T. Gomes
                   ` (6 subsequent siblings)
  29 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

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

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

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

diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c
index aeb4e1ea01..7fabdf264d 100644
--- a/misc/efgcvt-template.c
+++ b/misc/efgcvt-template.c
@@ -25,8 +25,6 @@
 
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
-#define __APPEND(a, b) __APPEND2 (a, b)
-#define __APPEND2(a, b) __##a##b
 
 
 #define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer)
@@ -39,13 +37,11 @@ static char ECVT_BUFFER[MAXDIG];
 libc_freeres_ptr (static char *FCVT_BUFPTR);
 
 char *
-__APPEND (FUNC_PREFIX, fcvt) (FLOAT_TYPE value, int ndigit, int *decpt,
-			      int *sign)
+__FCVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign)
 {
   if (FCVT_BUFPTR == NULL)
     {
-      if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
-					  FCVT_BUFFER, MAXDIG) != -1)
+      if (__FCVT_R (value, ndigit, decpt, sign, FCVT_BUFFER, MAXDIG) != -1)
 	return FCVT_BUFFER;
 
       FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG);
@@ -53,25 +49,22 @@ __APPEND (FUNC_PREFIX, fcvt) (FLOAT_TYPE value, int ndigit, int *decpt,
 	return FCVT_BUFFER;
     }
 
-  (void) __APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign,
-					 FCVT_BUFPTR, FCVT_MAXDIG);
+  (void) __FCVT_R (value, ndigit, decpt, sign, FCVT_BUFPTR, FCVT_MAXDIG);
 
   return FCVT_BUFPTR;
 }
 
 
 char *
-__APPEND (FUNC_PREFIX, ecvt) (FLOAT_TYPE value, int ndigit, int *decpt,
-			      int *sign)
+__ECVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign)
 {
-  (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign,
-					 ECVT_BUFFER, MAXDIG);
+  (void) __ECVT_R (value, ndigit, decpt, sign, ECVT_BUFFER, MAXDIG);
 
   return ECVT_BUFFER;
 }
 
 char *
-__APPEND (FUNC_PREFIX, gcvt) (FLOAT_TYPE value, int ndigit, char *buf)
+__GCVT (FLOAT_TYPE value, int ndigit, char *buf)
 {
   sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value);
   return buf;
diff --git a/misc/efgcvt.c b/misc/efgcvt.c
index 81ac60415e..93a0269d5c 100644
--- a/misc/efgcvt.c
+++ b/misc/efgcvt.c
@@ -16,19 +16,27 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include "efgcvt.c"
+#define ECVT ecvt
+#define FCVT fcvt
+#define GCVT gcvt
+#define __ECVT __ecvt
+#define __FCVT __fcvt
+#define __GCVT __gcvt
+#define __ECVT_R __ecvt_r
+#define __FCVT_R __fcvt_r
+#include <efgcvt-dbl-macros.h>
+#include <efgcvt-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# define cvt_symbol(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 f215dbd345..977750118c 100644
--- a/misc/efgcvt_r-template.c
+++ b/misc/efgcvt_r-template.c
@@ -28,18 +28,10 @@
 
 #define APPEND(a, b) APPEND2 (a, b)
 #define APPEND2(a, b) a##b
-#define __APPEND(a, b) __APPEND2 (a, b)
-#define __APPEND2(a, b) __##a##b
-
-#define FLOOR APPEND(floor, FLOAT_NAME_EXT)
-#define FABS APPEND(fabs, FLOAT_NAME_EXT)
-#define LOG10 APPEND(log10, FLOAT_NAME_EXT)
-#define EXP APPEND(exp, FLOAT_NAME_EXT)
-
 
 int
-__APPEND (FUNC_PREFIX, fcvt_r) (FLOAT_TYPE value, int ndigit, int *decpt,
-				int *sign, char *buf, size_t len)
+__FCVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign,
+	  char *buf, size_t len)
 {
   ssize_t n;
   ssize_t i;
@@ -133,8 +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;
 
@@ -193,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 aa0eb8ca43..5b48ca5b9b 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -16,22 +16,24 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include "efgcvt_r.c"
+#define ECVT_R ecvt_r
+#define FCVT_R fcvt_r
+#define __ECVT_R __ecvt_r
+#define __FCVT_R __fcvt_r
+#include <efgcvt-dbl-macros.h>
+#include <efgcvt_r-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# define cvt_symbol(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 ea48c6b48a..903bf93aa4 100644
--- a/misc/qefgcvt.c
+++ b/misc/qefgcvt.c
@@ -16,18 +16,24 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include "efgcvt.c"
+#define ECVT qecvt
+#define FCVT qfcvt
+#define GCVT qgcvt
+#define __ECVT __qecvt
+#define __FCVT __qfcvt
+#define __GCVT __qgcvt
+#define __ECVT_R __qecvt_r
+#define __FCVT_R __qfcvt_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# define cvt_symbol(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 d2f36e6d2a..b790bf7837 100644
--- a/misc/qefgcvt_r.c
+++ b/misc/qefgcvt_r.c
@@ -17,21 +17,21 @@
    License along with the GNU C Library; if not, see
    <https://www.gnu.org/licenses/>.  */
 
-#include "efgcvt_r.c"
+#define ECVT_R qecvt_r
+#define FCVT_R qfcvt_r
+#define __ECVT_R __qecvt_r
+#define __FCVT_R __qfcvt_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt_r-template.c>
 
 #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-# define cvt_symbol(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] 72+ messages in thread

* [PATCH v2 24/30] ldbl-128ibm-compat: Add *cvt functions
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (22 preceding siblings ...)
  2019-10-25 15:34 ` [PATCH v2 23/30] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 25/30] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Gabriel F. T. Gomes
                   ` (5 subsequent siblings)
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

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 6f1794fac8..759f6e7452 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..8402bd358c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c
@@ -0,0 +1,52 @@
+/* IEEE binary128 versions of *cvt functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* When in IEEE long double mode, call ___ieee128_sprintf.  */
+#include <stdio.h>
+typeof (sprintf) ___ieee128_sprintf attribute_hidden;
+#define SPRINTF ___ieee128_sprintf
+
+/* Declare internal functions: ___qecvtieee128_r and ___qfcvtieee128_r,
+   built from a different compiling unit, and called from here.  */
+#include <stdlib.h>
+typeof (qecvt_r) ___qecvtieee128_r;
+typeof (qfcvt_r) ___qfcvtieee128_r;
+
+/* Rename the static buffers and pointer, otherwise the IEEE long double
+   variants of qecvt and qfcvt would reuse the same buffers and pointer
+   as their non-IEEE long double counterparts.  */
+#define qecvt_buffer qecvtieee128_buffer
+#define qfcvt_buffer qfcvtieee128_buffer
+#define qfcvt_bufptr qfcvtieee128_bufptr
+
+#define ECVT __qecvtieee128
+#define FCVT __qfcvtieee128
+#define GCVT __qgcvtieee128
+#define __ECVT ___qecvtieee128
+#define __FCVT ___qfcvtieee128
+#define __GCVT ___qgcvtieee128
+#define __ECVT_R ___qecvtieee128_r
+#define __FCVT_R ___qfcvtieee128_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt-template.c>
+
+#define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
+cvt_symbol (___qfcvtieee128, __qfcvtieee128);
+cvt_symbol (___qecvtieee128, __qecvtieee128);
+cvt_symbol (___qgcvtieee128, __qgcvtieee128);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c
new file mode 100644
index 0000000000..5eddeff4f5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c
@@ -0,0 +1,34 @@
+/* IEEE binary128 versions of reentrant *cvt_r functions.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* When in IEEE long double mode, call ___ieee128_snprintf.  */
+#include <stdio.h>
+typeof (snprintf) ___ieee128_snprintf attribute_hidden;
+#define SNPRINTF ___ieee128_snprintf
+
+#define ECVT_R __qecvtieee128_r
+#define FCVT_R __qfcvtieee128_r
+#define __ECVT_R ___qecvtieee128_r
+#define __FCVT_R ___qfcvtieee128_r
+#include <efgcvt-ldbl-macros.h>
+#include <efgcvt_r-template.c>
+
+#define cvt_symbol(local, symbol) \
+  strong_alias (local, symbol)
+cvt_symbol (___qfcvtieee128_r, __qfcvtieee128_r);
+cvt_symbol (___qecvtieee128_r, __qecvtieee128_r);
-- 
2.21.0


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

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

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

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>
---
 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] 72+ messages in thread

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

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

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 759f6e7452..013f2d7fc5 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] 72+ messages in thread

* [PATCH v2 27/30] Avoid compat symbols for totalorder in powerpc64le IEEE long double
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (25 preceding siblings ...)
  2019-10-25 15:34 ` [PATCH v2 26/30] ldbl-128ibm-compat: Compiler flags for stdio functions Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 28/30] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Gabriel F. T. Gomes
                   ` (2 subsequent siblings)
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

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.
---
 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] 72+ messages in thread

* [PATCH v2 28/30] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128
  2019-10-25 15:33 [PATCH v2 00/30] Add IEEE long double <-> string functions for powerpc64le Gabriel F. T. Gomes
                   ` (26 preceding siblings ...)
  2019-10-25 15:34 ` [PATCH v2 27/30] Avoid compat symbols for totalorder in powerpc64le IEEE long double Gabriel F. T. Gomes
@ 2019-10-25 15:34 ` Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 29/30] powerpc64le: Require a compiler with -mno-gnu-attribute Gabriel F. T. Gomes
  2019-10-25 15:34 ` [PATCH v2 30/30] RFC: powerpc64le: Enable support for IEEE long double Gabriel F. T. Gomes
  29 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-25 15:34 UTC (permalink / raw)
  To: libc-alpha

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

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 013f2d7fc5..a7c25add7e 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] 72+ messages in thread

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

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

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.
---
 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 d7286841c9..7fb3727ab0 100644
--- a/NEWS
+++ b/NEWS
@@ -32,7 +32,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] 72+ messages in thread

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

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

DO NOT 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 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |  93 ++++++++++++++++
 .../linux/powerpc/powerpc64/le/libm.abilist   | 104 ++++++++++++++++++
 wcsmbs/bits/wchar-ldbl.h                      |  36 +++++-
 wcsmbs/wchar.h                                |  14 ++-
 17 files changed, 357 insertions(+), 43 deletions(-)

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 abcb0d5e3c..4f1d66e425 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -460,7 +460,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)
@@ -469,6 +499,8 @@
 #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
 #  define __LDBL_REDIR_NTH(name, proto) \
   __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+#  define __LDBL_REDIR2_DECL(name) \
+  extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
 #  define __LDBL_REDIR1_DECL(name, alias) \
   extern __typeof (name) name __asm (__ASMNAME (#alias));
 #  define __LDBL_REDIR_DECL(name) \
@@ -479,11 +511,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/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 4b731ebb51..815bb812a3 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, ...),
@@ -687,7 +689,8 @@ extern int vswscanf (const wchar_t *__restrict __s,
 
 # if !defined __USE_GNU \
      && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
-     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \
+     && __LONG_DOUBLE_USES_FLOAT128 == 0
 #  ifdef __REDIRECT
 extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s,
 				  const wchar_t *__restrict __format,
@@ -848,7 +851,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] 72+ messages in thread

* Re: [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions
  2019-10-25 15:33 ` [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions Gabriel F. T. Gomes
@ 2019-10-29 15:42   ` Paul E Murphy
  2019-10-30 16:10     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-10-29 15:42 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> The 'mode' argument to __vfprintf_internal allows the selection of the
> long double format for all long double arguments requested by the format
> string.  Currently, there are two possibilities: long double with the
> same format as double or long double as something else.  The 'something
> else' format varies between architectures, and on powerpc64le, it means
> IBM Extended Precision format.
> 
> In preparation for the third option of long double format on
> powerpc64le, this patch uses the new mode mask,
> PRINTF_LDBL_USES_FLOAT128, which tells __vfprintf_internal to save the
> floating-point values into variables of type __float128 and adjusts the
> parameters to __printf_fp and __printf_fphex as if it was a call from
> strfromf128.
> 
> Many files from the stdio-common, wcsmbs, argp, misc, and libio
> directories will have IEEE binary128 counterparts.  Setting the correct
> compiler options to these files (original and counterparts) would
> produce a large amount of repetitive Makefile rules.  To avoid this
> repetition, this patch adds a Makefile routine that iterates over the
> files adding or removing the appropriate flags.
> 
> Tested for powerpc64le.
> ---
>   elf/tst-addr1.c                               |   7 +-
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  47 ++++-
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  15 ++
>   .../ldbl-128ibm-compat/ieee128-asprintf.c     |  35 ++++
>   .../ldbl-128ibm-compat/ieee128-dprintf.c      |  34 ++++
>   .../ldbl-128ibm-compat/ieee128-fprintf.c      |  34 ++++
>   .../ldbl-128ibm-compat/ieee128-printf.c       |  35 ++++
>   .../ldbl-128ibm-compat/ieee128-snprintf.c     |  35 ++++
>   .../ldbl-128ibm-compat/ieee128-sprintf.c      |  35 ++++
>   .../ldbl-128ibm-compat/ieee128-vasprintf.c    |  27 +++
>   .../ldbl-128ibm-compat/ieee128-vdprintf.c     |  26 +++
>   .../ldbl-128ibm-compat/ieee128-vfprintf.c     |  26 +++
>   .../ldbl-128ibm-compat/ieee128-vprintf.c      |  27 +++
>   .../ldbl-128ibm-compat/ieee128-vsnprintf.c    |  28 +++
>   .../ldbl-128ibm-compat/ieee128-vsprintf.c     |  27 +++
>   .../ldbl-128ibm-compat/test-printf-ibm128.c   |   1 +
>   .../ldbl-128ibm-compat/test-printf-ieee128.c  |   1 +
>   .../test-printf-ldbl-compat.c                 | 171 ++++++++++++++++++
>   .../powerpc64/le/ldbl-128ibm-compat-abi.h     |   8 +
>   19 files changed, 617 insertions(+), 2 deletions(-)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
>   create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
> 
> diff --git a/elf/tst-addr1.c b/elf/tst-addr1.c
> index 68ff74aabd..ee81acda5b 100644
> --- a/elf/tst-addr1.c
> +++ b/elf/tst-addr1.c
> @@ -19,7 +19,12 @@ do_test (void)
>   		rather than in the binary.  printf and _IO_printf
>   		are aliased and which one comes first in the
>   		hash table is up to the linker.  */
> -	     && strcmp (i.dli_sname, "_IO_printf") != 0);
> +	     && strcmp (i.dli_sname, "_IO_printf") != 0
> +	     /* On architectures where long double with IEEE binary128
> +		format is available as a third option (initially, true
> +		for powerpc64le), printf may be redirected to
> +		__printfieee128.  */
> +	     && strcmp (i.dli_sname, "__printfieee128") != 0);

Should there be a guard against this test for architectures which will 
never support this symbol?

>   }
> 
>   #include <support/test-driver.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index 412beb5b5c..89059f37e2 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
OK, those make rules take a little time to digest.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> index 4aa34dbe59..6a27befed2 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK. This seems to be the accepted approach to expose the new ieee128 ABI.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c

... the ieee128-*printf.c wrappers all look OK.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
> new file mode 100644
> index 0000000000..5de4ea3e7f
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
> @@ -0,0 +1 @@
> +#include <test-printf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
> new file mode 100644
> index 0000000000..5de4ea3e7f
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
> @@ -0,0 +1 @@
> +#include <test-printf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
...
> +  long double ld = -1;

Is this the best value to use for compat tests? Would a value which 
produces unique output for the respective format if the wrong compiler 
flags are used? Or, maybe an extra header in *-ibm128.c and *-ieee128.c 
variants to sanity check __LDBL_MANT_DIG__?


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

Should this part of the change be held off until all ldbl == ieee128 
changes are in?

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

* Re: [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions
  2019-10-29 15:42   ` Paul E Murphy
@ 2019-10-30 16:10     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-10-30 16:10 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

On Tue, 29 Oct 2019, Paul E Murphy wrote:

>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
>>
>> diff --git a/elf/tst-addr1.c b/elf/tst-addr1.c
>> index 68ff74aabd..ee81acda5b 100644
>> --- a/elf/tst-addr1.c
>> +++ b/elf/tst-addr1.c
>> @@ -19,7 +19,12 @@ do_test (void)
>>   		rather than in the binary.  printf and _IO_printf
>>   		are aliased and which one comes first in the
>>   		hash table is up to the linker.  */
>> -	     && strcmp (i.dli_sname, "_IO_printf") != 0);
>> +	     && strcmp (i.dli_sname, "_IO_printf") != 0
>> +	     /* On architectures where long double with IEEE binary128
>> +		format is available as a third option (initially, true
>> +		for powerpc64le), printf may be redirected to
>> +		__printfieee128.  */
>> +	     && strcmp (i.dli_sname, "__printfieee128") != 0);  
>
>Should there be a guard against this test for architectures which will 
>never support this symbol?

Yeah, sounds good so that we avoid unintended redirections.  On the other
hand, this is also a residue from our initial development effort, when we
added -mabi=ieeelongdouble to a lot more files, than what I have today.
Today, this test case is not built with -mabi=ieeelongdouble, so I think
this hunk should simply go away.

>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
>> new file mode 100644
>> index 0000000000..5de4ea3e7f
>> --- /dev/null
>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
>> @@ -0,0 +1 @@
>> +#include <test-printf-ldbl-compat.c>
>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c  
>...
>> +  long double ld = -1;  
>
>Is this the best value to use for compat tests? Would a value which 
>produces unique output for the respective format if the wrong compiler 
>flags are used? Or, maybe an extra header in *-ibm128.c and *-ieee128.c 
>variants to sanity check __LDBL_MANT_DIG__?

My rationale for using this value is that it makes it simple to debug when
something goes wrong.  Since the implementation for these functions reuse
the code paths added for _Float128, I didn't think it would be useful to
test for more values again (the _Float128 implementation already checks
for many values).  This test is telling me that the parameters are being
passed and read correctly (on the powerpc64le case, that they are going
through VSX registers, as opposed to two FP registers for IBM long double).

>> +   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
>
>Should this part of the change be held off until all ldbl == ieee128 
>changes are in?

I guess you're right. I moved it to the last commit, which actually adds
sysdeps/ieee754/ldbl-128ibm-compat to the Implies file.


Thanks,
Gabriel

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

* Re: [PATCH v2 02/30] ldbl-128ibm-compat: Add wide character printing functions
  2019-10-25 15:33 ` [PATCH v2 02/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-11-04 15:08   ` Paul E Murphy
  2019-11-04 18:10     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 15:08 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Similarly to what was done for regular character printing functions,
> this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, in the
> 'mode' argument of the wide characters printing function,
> __vfwprintf_internal (which is also extended to support printing
> floating-point values with IEEE binary128, by saving floating-point
> values into variables of type __float128 and adjusting the parameters to
> __printf_fp and __printf_fphex as if it was a call from a wide-character
> version of strfromf128 (even though such version does not exist)).
> 
> Tested for powerpc64le.
> ---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  13 +-
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |   8 ++
>   .../ldbl-128ibm-compat/ieee128-fwprintf.c     |  35 ++++++
>   .../ldbl-128ibm-compat/ieee128-swprintf.c     |  36 ++++++
>   .../ldbl-128ibm-compat/ieee128-vfwprintf.c    |  27 +++++
>   .../ldbl-128ibm-compat/ieee128-vswprintf.c    |  28 +++++
>   .../ldbl-128ibm-compat/ieee128-vwprintf.c     |  27 +++++
>   .../ldbl-128ibm-compat/ieee128-wprintf.c      |  35 ++++++
>   .../ldbl-128ibm-compat/test-wprintf-ibm128.c  |   1 +
>   .../ldbl-128ibm-compat/test-wprintf-ieee128.c |   1 +
>   .../test-wprintf-ldbl-compat.c                | 111 ++++++++++++++++++
>   11 files changed, 321 insertions(+), 1 deletion(-)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
> 
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index 89059f37e2..0f2f58d5b9 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> @@ -11,7 +11,13 @@ ldbl-extra-routines += printf_size \
>   		       vfprintf \
>   		       vprintf \
>   		       vsnprintf \
> -		       vsprintf
> +		       vsprintf \
> +		       fwprintf \
> +		       swprintf \
> +		       wprintf \
> +		       vfwprintf \
> +		       vswprintf \
> +		       vwprintf
> 
>   # Printing long double values with IEEE binary128 format reuses part
>   # of the internal float128 implementation (__printf_fp, __printf_fphex,
> @@ -19,6 +25,7 @@ ldbl-extra-routines += printf_size \
>   # the following functions, must have -mfloat128 and -mabi=ibmlongdouble
>   # passed to the compiler.
>   CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
> +CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
> 
>   # Basic tests for the implementation of long double with IEEE binary128
>   # format and for the related redirections in installed headers.
> @@ -26,6 +33,10 @@ tests-internal += test-printf-ieee128 test-printf-ibm128
>   CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
>   CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
> 
> +tests-internal += test-wprintf-ieee128 test-wprintf-ibm128
> +CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
> +CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
> +
>   tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
>   CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
>   CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> index 6a27befed2..0485a2b5d4 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> @@ -134,5 +134,13 @@ libc {
>       __vprintfieee128;
>       __vsnprintfieee128;
>       __vsprintfieee128;
> +
> +    __fwprintfieee128;
> +    __swprintfieee128;
> +    __wprintfieee128;
> +
> +    __vfwprintfieee128;
> +    __vswprintfieee128;
> +    __vwprintfieee128;
>     }
>   }

Looks OK, and is consistent with committed patches.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c

The 6 wide-character printf wrappers look OK too.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
> new file mode 100644
> index 0000000000..9e230cd6f8
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c
> @@ -0,0 +1 @@
> +#include <test-wprintf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
> new file mode 100644
> index 0000000000..9e230cd6f8
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c
> @@ -0,0 +1 @@
> +#include <test-wprintf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
> new file mode 100644
> index 0000000000..71edfec235
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
> @@ -0,0 +1,111 @@
> +/* Test for the long double variants of *w*printf functions.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdarg.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <wchar.h>
> +
> +#include <support/capture_subprocess.h>
> +#include <support/check.h>
> +
> +static void
> +do_test_call_varg (FILE *stream, const wchar_t *format, ...)
> +{
> +  wchar_t string[128];
> +  va_list args;
> +
> +  wprintf (L"%15Ls", L"vfwprintf: ");
> +  va_start (args, format);
> +  vfwprintf (stream, format, args);
> +  va_end (args);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%15Ls", L"vswprintf: ");
> +  va_start (args, format);
> +  vswprintf (string, 127, format, args);
> +  va_end (args);
> +  wprintf (L"%Ls", string);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%15Ls", L"vwprintf: ");
> +  va_start (args, format);
> +  vwprintf (format, args);
> +  va_end (args);
> +  wprintf (L"\n");
> +}
> +
> +static void
> +do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
> +{
> +  wchar_t string[128];
> +
> +  wprintf (L"%15Ls", L"fwprintf: ");
> +  fwprintf (stream, format, ld);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%15Ls", L"swprintf: ");
> +  swprintf (string, 127, format, ld);
> +  wprintf (L"%Ls", string);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%15Ls", L"wprintf: ");
> +  wprintf (format, ld);
> +  wprintf (L"\n");
> +}
> +
> +static void
> +do_test_call (void)
> +{
> +  long double ld = -1;
> +
> +  /* Print in decimal notation.  */
> +  do_test_call_rarg (stdout, L"%.10Lf", ld);
> +  do_test_call_varg (stdout, L"%.10Lf", ld);
> +
> +  /* Print in hexadecimal notation.  */
> +  do_test_call_rarg (stdout, L"%.10La", ld);
> +  do_test_call_varg (stdout, L"%.10La", ld);
> +}
> +
> +static int
> +do_test (void)
> +{
> +  struct support_capture_subprocess result;
> +  result = support_capture_subprocess ((void *) &do_test_call, NULL);
> +
> +  /* Compare against the expected output.  */
> +  const char *expected =
> +    "     fwprintf: -1.0000000000\n"
> +    "     swprintf: -1.0000000000\n"
> +    "      wprintf: -1.0000000000\n"
> +    "    vfwprintf: -1.0000000000\n"
> +    "    vswprintf: -1.0000000000\n"
> +    "     vwprintf: -1.0000000000\n"
> +    "     fwprintf: -0x1.0000000000p+0\n"
> +    "     swprintf: -0x1.0000000000p+0\n"
> +    "      wprintf: -0x1.0000000000p+0\n"
> +    "    vfwprintf: -0x1.0000000000p+0\n"
> +    "    vswprintf: -0x1.0000000000p+0\n"
> +    "     vwprintf: -0x1.0000000000p+0\n";
> +  TEST_COMPARE_STRING (expected, result.out.buffer);
> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> 

Is it prohibitively difficult to merge the wide character tester with 
the one in the previous patch? Otherwise, this looks OK too.

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

* Re: [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified printing functions
  2019-10-25 15:33 ` [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified " Gabriel F. T. Gomes
@ 2019-11-04 15:43   ` Paul E Murphy
  2019-11-05 19:37     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 15:43 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Since the introduction of internal functions with explicit flags for the
> printf family of functions, the 'mode' parameter can be used to select
> which format long double parameters have (with the mode flags:
> PRINTF_LDBL_IS_DBL and PRINTF_LDBL_USES_FLOAT128), as well as to select
> whether to check for overflows (mode flag: PRINTF_FORTIFY).
> 
> This patch combines PRINTF_LDBL_USES_FLOAT128 and PRINTF_FORTIFY to
> provide the IEEE binary128 version of printf-like function for platforms
> where long double can take this format, in addition to the double format
> and to some non-ieee format (currently, this means powerpc64le).
> 
> There are two flavors of test cases provided with this patch: one that
> explicitly calls the fortified functions, for instance __asprintf_chk,
> and another that reuses the non-fortified test, but defining
> _FORTIFY_SOURCE as 2.  The first guarantees that the implementations are
> actually being tested (in bits/stdio2.h, vprintf gets redirected to
> __vfprintf_chk, which would leave __vprintf_chk untested), whereas the
> second guarantees that the redirections calls the correct function in
> the IBM and IEEE long double cases.
> 
> Tested for powerpc64le.
> ---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  25 +++
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  14 ++
>   .../ldbl-128ibm-compat/ieee128-asprintf_chk.c |  38 ++++
>   .../ldbl-128ibm-compat/ieee128-dprintf_chk.c  |  38 ++++
>   .../ldbl-128ibm-compat/ieee128-fprintf_chk.c  |  38 ++++
>   .../ldbl-128ibm-compat/ieee128-printf_chk.c   |  38 ++++
>   .../ldbl-128ibm-compat/ieee128-snprintf_chk.c |  42 ++++
>   .../ldbl-128ibm-compat/ieee128-sprintf_chk.c  |  42 ++++
>   .../ieee128-vasprintf_chk.c                   |  31 +++
>   .../ldbl-128ibm-compat/ieee128-vdprintf_chk.c |  30 +++
>   .../ldbl-128ibm-compat/ieee128-vfprintf_chk.c |  30 +++
>   .../ldbl-128ibm-compat/ieee128-vprintf_chk.c  |  30 +++
>   .../ieee128-vsnprintf_chk.c                   |  34 ++++
>   .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c |  34 ++++
>   .../test-printf-chk-ibm128.c                  |   1 +
>   .../test-printf-chk-ieee128.c                 |   1 +
>   .../test-printf-chk-ldbl-compat.c             | 179 ++++++++++++++++++
>   .../test-printf-chk-redir-ibm128.c            |   2 +
>   .../test-printf-chk-redir-ieee128.c           |   2 +
>   19 files changed, 649 insertions(+)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
> 
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

These changes look OK.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
> new file mode 100644
> index 0000000000..149fc046b6
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c

The 12 wrappers look OK, and suspiciously similar to the ndbl-64 code :).


> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
> new file mode 100644
> index 0000000000..7d50284d9c
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c
> @@ -0,0 +1 @@
> +#include <test-printf-chk-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
> new file mode 100644
> index 0000000000..7d50284d9c
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c
> @@ -0,0 +1 @@
> +#include <test-printf-chk-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
> new file mode 100644
> index 0000000000..f3d18c92ec
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
> @@ -0,0 +1,179 @@
> +/* Test for the long double variants of *printf_chk functions.
> +   Copyright (C) 2018 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define _FORTIFY_SOURCE 2
> +
> +#include <stdarg.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +
> +#include <support/capture_subprocess.h>
> +#include <support/check.h>
> +
> +static void
> +do_test_call_varg (FILE *stream, const char *format, ...)
> +{
> +  char *buffer = NULL;
> +  char string[128];
> +  int res;
> +  va_list args;
> +
> +  printf ("%20s", "__vasprintf_chk: ");
> +  va_start (args, format);
> +  res = __vasprintf_chk (&buffer, 1, format, args);
> +  va_end (args);
> +  if (res == -1)
> +    printf ("Error using vasprintf\n");
> +  if (buffer == NULL)
> +    printf ("Error using vasprintf\n");
> +  else
> +    {
> +      printf ("%s", buffer);
> +      free (buffer);
> +    }
> +  printf ("\n");
> +
> +  printf ("%20s", "__vdprintf_chk: ");
> +  va_start (args, format);
> +  __vdprintf_chk (fileno (stream), 1, format, args);
> +  va_end (args);
> +  printf ("\n");
> +
> +  printf ("%20s", "__vfprintf_chk: ");
> +  va_start (args, format);
> +  __vfprintf_chk (stream, 1, format, args);
> +  va_end (args);
> +  printf ("\n");
> +
> +  printf ("%20s", "__vprintf_chk: ");
> +  va_start (args, format);
> +  __vprintf_chk (1, format, args);
> +  va_end (args);
> +  printf ("\n");
> +
> +  printf ("%20s", "__vsnprintf_chk: ");
> +  va_start (args, format);
> +  __vsnprintf_chk (string, 79, 1, 127, format, args);
> +  va_end (args);
> +  printf ("%s", string);
> +  printf ("\n");
> +
> +  printf ("%20s", "__vsprintf_chk: ");
> +  va_start (args, format);
> +  __vsprintf_chk (string, 1, 127, format, args);
> +  va_end (args);
> +  printf ("%s", string);
> +  printf ("\n");
> +}
> +
> +static void
> +do_test_call_rarg (FILE *stream, const char *format, long double ld)
> +{
> +  char *buffer = NULL;
> +  char string[128];
> +  int res;
> +
> +  printf ("%20s", "__asprintf_chk: ");
> +  res = __asprintf_chk (&buffer, 1, format, ld);
> +  if (res == -1)
> +    printf ("Error using vasprintf\n");
> +  if (buffer == NULL)
> +    printf ("Error using asprintf\n");
> +  else
> +    {
> +      printf ("%s", buffer);
> +      free (buffer);
> +    }
> +  printf ("\n");
> +
> +  printf ("%20s", "__dprintf_chk: ");
> +  __dprintf_chk (fileno (stream), 1, format, ld);
> +  printf ("\n");
> +
> +  printf ("%20s", "__fprintf_chk: ");
> +  __fprintf_chk (stdout, 1, format, ld);
> +  printf ("\n");
> +
> +  printf ("%20s", "__printf_chk: ");
> +  __printf_chk (1, format, ld);
> +  printf ("\n");
> +
> +  printf ("%20s", "__snprintf_chk: ");
> +  __snprintf_chk (string, 79, 1, 127, format, ld);
> +  printf ("%s", string);
> +  printf ("\n");
> +
> +  printf ("%20s", "__sprintf_chk: ");
> +  __sprintf_chk (string, 1, 127, format, ld);
> +  printf ("%s", string);
> +  printf ("\n");
> +}
> +
> +static void
> +do_test_call (void)
> +{
> +  long double ld = -1;
> +
> +  /* Print in decimal notation.  */
> +  do_test_call_rarg (stdout, "%.10Lf", ld);
> +  do_test_call_varg (stdout, "%.10Lf", ld);
> +
> +  /* Print in hexadecimal notation.  */
> +  do_test_call_rarg (stdout, "%.10La", ld);
> +  do_test_call_varg (stdout, "%.10La", ld);
> +}
> +
> +static int
> +do_test (void)
> +{
> +  struct support_capture_subprocess result;
> +  result = support_capture_subprocess ((void *) &do_test_call, NULL);
> +
> +  /* Compare against the expected output.  */
> +  const char *expected =
> +    "    __asprintf_chk: -1.0000000000\n"
> +    "     __dprintf_chk: -1.0000000000\n"
> +    "     __fprintf_chk: -1.0000000000\n"
> +    "      __printf_chk: -1.0000000000\n"
> +    "    __snprintf_chk: -1.0000000000\n"
> +    "     __sprintf_chk: -1.0000000000\n"
> +    "   __vasprintf_chk: -1.0000000000\n"
> +    "    __vdprintf_chk: -1.0000000000\n"
> +    "    __vfprintf_chk: -1.0000000000\n"
> +    "     __vprintf_chk: -1.0000000000\n"
> +    "   __vsnprintf_chk: -1.0000000000\n"
> +    "    __vsprintf_chk: -1.0000000000\n"
> +    "    __asprintf_chk: -0x1.0000000000p+0\n"
> +    "     __dprintf_chk: -0x1.0000000000p+0\n"
> +    "     __fprintf_chk: -0x1.0000000000p+0\n"
> +    "      __printf_chk: -0x1.0000000000p+0\n"
> +    "    __snprintf_chk: -0x1.0000000000p+0\n"
> +    "     __sprintf_chk: -0x1.0000000000p+0\n"
> +    "   __vasprintf_chk: -0x1.0000000000p+0\n"
> +    "    __vdprintf_chk: -0x1.0000000000p+0\n"
> +    "    __vfprintf_chk: -0x1.0000000000p+0\n"
> +    "     __vprintf_chk: -0x1.0000000000p+0\n"
> +    "   __vsnprintf_chk: -0x1.0000000000p+0\n"
> +    "    __vsprintf_chk: -0x1.0000000000p+0\n";
> +  TEST_COMPARE_STRING (expected, result.out.buffer);
> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
> new file mode 100644
> index 0000000000..aeab22412b
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
> @@ -0,0 +1,2 @@
> +#define _FORTIFY_SOURCE 2

This is also defined in the unified test case above. Is it necessary 
here to?

> +#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
> new file mode 100644
> index 0000000000..aeab22412b
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c
> @@ -0,0 +1,2 @@
> +#define _FORTIFY_SOURCE 2

Likewise.

> +#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
> 

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

* Re: [PATCH v2 04/30] ldbl-128ibm-compat: Add wide character, fortified printing functions
  2019-10-25 15:33 ` [PATCH v2 04/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-11-04 16:07   ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 16:07 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Similarly to what was done for the regular character, fortified printing
> functions, this patch combines the mode masks PRINTF_LDBL_USES_FLOAT128
> and PRINTF_FORTIFY to provide wide character versions of fortified
> printf functions.  It also adds two flavors of test cases: one that
> explicitly calls the fortified functions, and another that reuses the
> non-fortified test, but defining _FORTIFY_SOURCE as 2.  The first
> guarantees that the implementations are actually being tested
> (independently of what's in bits/wchar2.h), whereas the second
> guarantees that the redirections calls the correct function in the IBM
> and IEEE long double cases.
> 
> Tested for powerpc64le.
> ---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  18 ++-
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |   8 ++
>   .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c |  38 ++++++
>   .../ldbl-128ibm-compat/ieee128-swprintf_chk.c |  42 +++++++
>   .../ieee128-vfwprintf_chk.c                   |  31 +++++
>   .../ieee128-vswprintf_chk.c                   |  34 ++++++
>   .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c |  30 +++++
>   .../ldbl-128ibm-compat/ieee128-wprintf_chk.c  |  38 ++++++
>   .../test-wprintf-chk-ibm128.c                 |   1 +
>   .../test-wprintf-chk-ieee128.c                |   1 +
>   .../test-wprintf-chk-ldbl-compat.c            | 113 ++++++++++++++++++
>   .../test-wprintf-chk-redir-ibm128.c           |   2 +
>   .../test-wprintf-chk-redir-ieee128.c          |   2 +
>   13 files changed, 357 insertions(+), 1 deletion(-)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
> 
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c

The 6 wrappers look OK too.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
> new file mode 100644
> index 0000000000..5e47dccc0d
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
> @@ -0,0 +1,30 @@
> +/* Wrapper for __vwprintf_chk.  IEEE128 version.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <libio/libioP.h>
> +
> +extern int
> +___ieee128_vwprintf_chk (int flag, const wchar_t *format, va_list ap)
> +{
> +  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
> +  if (flag > 0)
> +    mode |= PRINTF_FORTIFY;
> +
> +  return __vfwprintf_internal (stdout, format, ap, mode);
> +}
> +strong_alias (___ieee128_vwprintf_chk, __vwprintf_chkieee128)
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
> new file mode 100644
> index 0000000000..ba00b7be54
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
> @@ -0,0 +1,38 @@
> +/* Wrapper for __wprintf_chk.  IEEE128 version.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdarg.h>
> +#include <libio/libioP.h>
> +
> +extern int
> +___ieee128_wprintf_chk (int flag, const wchar_t *format, ...)
> +{
> +  va_list ap;
> +  int done;
> +
> +  unsigned int mode = PRINTF_LDBL_USES_FLOAT128;
> +  if (flag > 0)
> +    mode |= PRINTF_FORTIFY;
> +
> +  va_start (ap, format);
> +  done = __vfwprintf_internal (stdout, format, ap, mode);
> +  va_end (ap);
> +
> +  return done;
> +}
> +strong_alias (___ieee128_wprintf_chk, __wprintf_chkieee128)
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
> new file mode 100644
> index 0000000000..5323df71e2
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c
> @@ -0,0 +1 @@
> +#include <test-wprintf-chk-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
> new file mode 100644
> index 0000000000..5323df71e2
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c
> @@ -0,0 +1 @@
> +#include <test-wprintf-chk-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
> new file mode 100644
> index 0000000000..f614004f27
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
> @@ -0,0 +1,113 @@
> +/* Test for the long double variants of *w*printf_chk functions.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define _FORTIFY_SOURCE 2
> +
> +#include <stdarg.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <wchar.h>
> +
> +#include <support/capture_subprocess.h>
> +#include <support/check.h>
> +
> +static void
> +do_test_call_varg (FILE *stream, const wchar_t *format, ...)
> +{
> +  wchar_t string[128];
> +  va_list args;
> +
> +  wprintf (L"%20Ls", L"__vfwprintf_chk: ");
> +  va_start (args, format);
> +  __vfwprintf_chk (stream, 1, format, args);
> +  va_end (args);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%20Ls", L"__vswprintf_chk: ");
> +  va_start (args, format);
> +  __vswprintf_chk (string, 79, 1, 127, format, args);
> +  va_end (args);
> +  wprintf (L"%Ls", string);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%20Ls", L"__vwprintf_chk: ");
> +  va_start (args, format);
> +  __vwprintf_chk (1, format, args);
> +  va_end (args);
> +  wprintf (L"\n");
> +}
> +
> +static void
> +do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld)
> +{
> +  wchar_t string[128];
> +
> +  wprintf (L"%20Ls", L"__fwprintf_chk: ");
> +  __fwprintf_chk (stream, 1, format, ld);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%20Ls", L"__swprintf_chk: ");
> +  __swprintf_chk (string, 79, 1, 127, format, ld);
> +  wprintf (L"%Ls", string);
> +  wprintf (L"\n");
> +
> +  wprintf (L"%20Ls", L"__wprintf_chk: ");
> +  __wprintf_chk (1, format, ld);
> +  wprintf (L"\n");
> +}
> +
> +static void
> +do_test_call (void)
> +{
> +  long double ld = -1;
> +
> +  /* Print in decimal notation.  */
> +  do_test_call_rarg (stdout, L"%.10Lf", ld);
> +  do_test_call_varg (stdout, L"%.10Lf", ld);
> +
> +  /* Print in hexadecimal notation.  */
> +  do_test_call_rarg (stdout, L"%.10La", ld);
> +  do_test_call_varg (stdout, L"%.10La", ld);
> +}
> +
> +static int
> +do_test (void)
> +{
> +  struct support_capture_subprocess result;
> +  result = support_capture_subprocess ((void *) &do_test_call, NULL);
> +
> +  /* Compare against the expected output.  */
> +  const char *expected =
> +    "    __fwprintf_chk: -1.0000000000\n"
> +    "    __swprintf_chk: -1.0000000000\n"
> +    "     __wprintf_chk: -1.0000000000\n"
> +    "   __vfwprintf_chk: -1.0000000000\n"
> +    "   __vswprintf_chk: -1.0000000000\n"
> +    "    __vwprintf_chk: -1.0000000000\n"
> +    "    __fwprintf_chk: -0x1.0000000000p+0\n"
> +    "    __swprintf_chk: -0x1.0000000000p+0\n"
> +    "     __wprintf_chk: -0x1.0000000000p+0\n"
> +    "   __vfwprintf_chk: -0x1.0000000000p+0\n"
> +    "   __vswprintf_chk: -0x1.0000000000p+0\n"
> +    "    __vwprintf_chk: -0x1.0000000000p+0\n";
> +  TEST_COMPARE_STRING (expected, result.out.buffer);
> +
> +  return 0;
> +}
> +

OK

> +#include <support/test-driver.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
> new file mode 100644
> index 0000000000..a12186a945
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c
> @@ -0,0 +1,2 @@
> +#define _FORTIFY_SOURCE 2

Similar comment to the narrow printing version of the patch. Is this 
needed here as well as the shared test code?

> +#include <sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
> new file mode 100644
> index 0000000000..a12186a945
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c
> @@ -0,0 +1,2 @@
> +#define _FORTIFY_SOURCE 2

Likewise.

> +#include <sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c>
> 

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

* Re: [PATCH v2 05/30] ldbl-128ibm-compat: Test double values
  2019-10-25 15:33 ` [PATCH v2 05/30] ldbl-128ibm-compat: Test double values Gabriel F. T. Gomes
@ 2019-11-04 16:15   ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 16:15 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> A single format string can take double and long double parameters at the
> same time.  Internally, these parameters are routed to the same
> function, which correctly reads them and calls the underlying functions
> responsible for the actual conversion to string.  This patch adds a new
> case to test this scenario.
> 
> Tested for powerpc64le.

I think the contents of the patch look OK. However, I am curious, what 
hidden behavior is being verified by these tests? I would expect the 
behavior of any non long-double arguments to be unchanged based on this 
patch series.

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

* Re: [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments
  2019-10-25 15:33 ` [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments Gabriel F. T. Gomes
@ 2019-11-04 16:55   ` Paul E Murphy
  2019-11-06 17:28     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 16:55 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> The format string can request positional parameters, instead of relying
> on the order in which they appear as arguments.  Since this has an
> effect on how the type of each argument is determined, this patch
> extends the test cases to use positional parameters with mixed double
> and long double types, to verify that the IEEE long double
> implementations of *printf work correctly in this scenario.
> 
> Tested for powerpc64le.

OK. Are there any other weird cases which should be tested against? Are 
these meant to be implicit tests of the underlying ABI?

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

* Re: [PATCH v2 08/30] ldbl-128ibm-compat: Add wide character scanning functions
  2019-10-25 15:33 ` [PATCH v2 08/30] ldbl-128ibm-compat: Add wide " Gabriel F. T. Gomes
@ 2019-11-04 17:46   ` Paul E Murphy
  2019-11-11 14:33     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 17:46 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Similarly to what was done for regular character scanning functions,
> this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, in the
> 'mode' argument of the wide characters scanning function,
> __vfwscanf_internal (which is also extended to support scanning
> floating-point values with IEEE binary128, by redirecting calls to
> __wcstold_internal to __wcstof128_internal).
> 
> Tested for powerpc64le.
> ---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 33 ++++++++++++++-
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  8 ++++
>   .../ldbl-128ibm-compat/ieee128-fwscanf.c      | 35 ++++++++++++++++
>   .../ldbl-128ibm-compat/ieee128-swscanf.c      | 40 +++++++++++++++++++
>   .../ldbl-128ibm-compat/ieee128-vfwscanf.c     | 27 +++++++++++++
>   .../ldbl-128ibm-compat/ieee128-vswscanf.c     | 32 +++++++++++++++
>   .../ldbl-128ibm-compat/ieee128-vwscanf.c      | 27 +++++++++++++
>   .../ldbl-128ibm-compat/ieee128-wscanf.c       | 35 ++++++++++++++++
>   .../ldbl-128ibm-compat/test-wscanf-ibm128.c   |  1 +
>   .../ldbl-128ibm-compat/test-wscanf-ieee128.c  |  1 +
>   .../test-wscanf-ldbl-compat.c                 | 10 +++++
>   11 files changed, 248 insertions(+), 1 deletion(-)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c

With exception to some minor comments in my previous reviews, are there 
any additional suggestions from the community? The *printf and *scanf 
patches look ready to commit.

Reviewed-By Paul E. Murphy <murphyp@linux.vnet.ibm.com>

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index a1f0f7d74e..031ee0b38f 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> @@ -1,3 +1,11 @@
> +ifeq ($(subdir),libio)
> +ldbl-extra-routines += fwscanf \
> +		       swscanf \
> +		       wscanf \
> +		       vswscanf \
> +		       vwscanf
> +endif
> +
>   ifeq ($(subdir),stdio-common)
>   ldbl-extra-routines += printf_size \
>   		       asprintf \
> @@ -23,7 +31,8 @@ ldbl-extra-routines += printf_size \
>   		       sscanf \
>   		       vfscanf \
>   		       vscanf \
> -		       vsscanf
> +		       vsscanf \
> +		       vfwscanf
> 
>   # Printing long double values with IEEE binary128 format reuses part
>   # of the internal float128 implementation (__printf_fp, __printf_fphex,
> @@ -34,6 +43,7 @@ ldbl-extra-routines += printf_size \
>   CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
>   CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble
>   CFLAGS-vfscanf-internal.c += -mfloat128 -mabi=ibmlongdouble
> +CFLAGS-vfwscanf-internal.c += -mfloat128 -mabi=ibmlongdouble
> 
>   # Basic tests for the implementation of long double with IEEE binary128
>   # format and for the related redirections in installed headers.
> @@ -51,9 +61,18 @@ CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
> 
>   $(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link)
> 
> +tests-internal += test-wscanf-ieee128 test-wscanf-ibm128
> +CFLAGS-test-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
> +CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
> +
> +$(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link)
> +
>   ifeq ($(run-built-tests),yes)
>   tests-special += $(objpfx)test-scanf-ieee128.out
>   tests-special += $(objpfx)test-scanf-ibm128.out
> +
> +tests-special += $(objpfx)test-wscanf-ieee128.out
> +tests-special += $(objpfx)test-wscanf-ibm128.out
>   endif
> 
>   $(objpfx)test-scanf-ieee128.out: \
> @@ -68,6 +87,18 @@ $(objpfx)test-scanf-ibm128.out: \
>   	$(SHELL) $^ '$(test-program-prefix)' $@; \
>   	$(evaluate-test)
> 
> +$(objpfx)test-wscanf-ieee128.out: \
> +  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
> +  $(objpfx)test-wscanf-ieee128
> +	$(SHELL) $^ '$(test-program-prefix)' $@; \
> +	$(evaluate-test)
> +
> +$(objpfx)test-wscanf-ibm128.out: \
> +  ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \
> +  $(objpfx)test-wscanf-ibm128
> +	$(SHELL) $^ '$(test-program-prefix)' $@; \
> +	$(evaluate-test)
> +
>   tests-internal += test-printf-size-ieee128 test-printf-size-ibm128
>   CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
>   CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf. > diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c 
b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
> new file mode 100644
> index 0000000000..ef21fc4741
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c
> @@ -0,0 +1 @@
> +#include <test-wscanf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
> new file mode 100644
> index 0000000000..ef21fc4741
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c
> @@ -0,0 +1 @@
> +#include <test-wscanf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
> new file mode 100644
> index 0000000000..e93cf3b9bd
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c
> @@ -0,0 +1,10 @@
> +#define CHAR wchar_t
> +#define L(x) L##x
> +#define FSCANF fwscanf
> +#define SSCANF swscanf
> +#define SCANF wscanf
> +#define VFSCANF vfwscanf
> +#define VSSCANF vswscanf
> +#define VSCANF vwscanf
> +#define STRCPY wcscpy
> +#include <test-scanf-ldbl-compat-template.c>
> 

OK

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

* Re: [PATCH v2 02/30] ldbl-128ibm-compat: Add wide character printing functions
  2019-11-04 15:08   ` Paul E Murphy
@ 2019-11-04 18:10     ` Gabriel F. T. Gomes
  2019-11-04 20:11       ` Paul E Murphy
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-04 18:10 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

On Mon, 04 Nov 2019, Paul E Murphy wrote:
>
>Is it prohibitively difficult to merge the wide character tester with 
>the one in the previous patch? Otherwise, this looks OK too.

It's not difficult...  In fact, that's how I started it, but it ended up
being too hard to read (imo, anyway), because of the excessive use of
macros and because of the not so nice correspondence between function
names.

I suppose you're suggesting it so that we have less code duplication.
I can make the merge...  It's just not how I would do it.

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

* Re: [PATCH v2 02/30] ldbl-128ibm-compat: Add wide character printing functions
  2019-11-04 18:10     ` Gabriel F. T. Gomes
@ 2019-11-04 20:11       ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-04 20:11 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 11/4/19 12:10 PM, Gabriel F. T. Gomes wrote:
> Hi, Paul,
> 
> On Mon, 04 Nov 2019, Paul E Murphy wrote:
>>
>> Is it prohibitively difficult to merge the wide character tester with
>> the one in the previous patch? Otherwise, this looks OK too.
> 
> It's not difficult...  In fact, that's how I started it, but it ended up
> being too hard to read (imo, anyway), because of the excessive use of
> macros and because of the not so nice correspondence between function
> names.
> 
> I suppose you're suggesting it so that we have less code duplication.
> I can make the merge...  It's just not how I would do it.

I can agree with this line of reasoning. I think the tradeoff made by 
these patches is OK. I don't think these tests will see much change once 
merged.

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

* Re: [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified printing functions
  2019-11-04 15:43   ` Paul E Murphy
@ 2019-11-05 19:37     ` Gabriel F. T. Gomes
  2019-11-08 16:44       ` Paul E Murphy
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-05 19:37 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

On Mon, 04 Nov 2019, Paul E Murphy wrote:

>> --- /dev/null
>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
>> @@ -0,0 +1,179 @@

[...]

>> --- /dev/null
>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
>> @@ -0,0 +1,2 @@
>> +#define _FORTIFY_SOURCE 2
>
>This is also defined in the unified test case above. Is it necessary 
>here to?

It is necessary here, too, because this test includes a different file:

  +#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>

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

* Re: [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments
  2019-11-04 16:55   ` Paul E Murphy
@ 2019-11-06 17:28     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-06 17:28 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

On Mon, 04 Nov 2019, Paul E Murphy wrote:

>OK. Are there any other weird cases which should be tested against? Are 
>these meant to be implicit tests of the underlying ABI?

I haven't thought of other weird cases.  This test for positional
parameters, as well as the test for double typed variables (previous patch
in this set) check that the relevant code paths in __vfprintf_internal
(added by commit ID 1626f499d159, but not yet fully used so far) are
working as designed.  These tests are an attempt to improve the testing of
vfprintf as suggested by Joseph in a somewhat old message [1].

[1] https://sourceware.org/ml/libc-alpha/2018-06/msg00084.html

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

* Re: [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified printing functions
  2019-11-05 19:37     ` Gabriel F. T. Gomes
@ 2019-11-08 16:44       ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 16:44 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha



On 11/5/19 1:37 PM, Gabriel F. T. Gomes wrote:
> Hi, Paul,
> 
> On Mon, 04 Nov 2019, Paul E Murphy wrote:
> 
>>> --- /dev/null
>>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
>>> @@ -0,0 +1,179 @@
> 
> [...]
> 
>>> --- /dev/null
>>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c
>>> @@ -0,0 +1,2 @@
>>> +#define _FORTIFY_SOURCE 2
>>
>> This is also defined in the unified test case above. Is it necessary
>> here to?
> 
> It is necessary here, too, because this test includes a different file:
> 
>    +#include <sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c>
> 

Ah, I missed the missing -redir component in the included file. Thank 
you for correcting me. OK.

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

* Re: [PATCH v2 09/30] ldbl-128ibm-compat: Add argp_error and argp_failure
  2019-10-25 15:33 ` [PATCH v2 09/30] ldbl-128ibm-compat: Add argp_error and argp_failure Gabriel F. T. Gomes
@ 2019-11-08 19:57   ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 19:57 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Use the recently added, internal functions, __argp_error_internal and
> __argp_failure_internal, to provide argp_error and argp_failure that can
> take long double arguments with IEEE binary128 format on platforms where
> long double can also take double format or some non-IEEE format
> (currently, this means powerpc64le).
> 
> Tested for powerpc64le.

This looks OK to me.

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

* Re: [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions
  2019-10-25 15:33 ` [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions Gabriel F. T. Gomes
@ 2019-11-08 20:22   ` Paul E Murphy
  2019-11-13 14:24     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 20:22 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Use the recently added, internal functions, __vwarnx_internal and
> __vwarn_internal, to provide err.h functions that can take long double
> arguments with IEEE binary128 format on platforms where long double can
> also take double format or some non-IEEE format (currently, this means
> powerpc64le).
> 
> Tested for powerpc64le.
> ---
>   misc/errP.h                                   | 28 ++++++
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  4 +
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  9 ++
>   .../ieee754/ldbl-128ibm-compat/ieee128-err.c  | 93 +++++++++++++++++++
>   4 files changed, 134 insertions(+)
>   create mode 100644 misc/errP.h
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
> 
> diff --git a/misc/errP.h b/misc/errP.h

These are also declared in includes/err.h. Is there a subtle configury 
that prevents their usage?

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
> new file mode 100644
> index 0000000000..8a34508e5e
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c
> @@ -0,0 +1,93 @@
> +/* Wrappers for err.h functions.  IEEE128 version.
> +   Copyright (C) 2018 Free Software Foundation, Inc.

Trivial nit, I think the year needs updated in a few places, and likely 
for the previous patches too.

> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdarg.h>
> +#include <misc/errP.h>
> +#include <libio/libioP.h>
> +
> +#define VA(call)							\
> +{									\
> +  va_list ap;								\
> +  va_start (ap, format);						\
> +  IEEE128_CALL (call);							\
> +  va_end (ap);								\
> +}
> +
> +#define IEEE128_ALIAS(name) \
> +  strong_alias (___ieee128_##name, __##name##ieee128)
> +
> +#define IEEE128_DECL(name) ___ieee128_##name
> +#define IEEE128_CALL(name) ___ieee128_##name
> +
> +void
> +IEEE128_DECL (vwarn) (const char *format, __gnuc_va_list ap)
> +{
> +  __vwarn_internal (format, ap, PRINTF_LDBL_USES_FLOAT128);
> +}
> +IEEE128_ALIAS (vwarn)
> +
> +void
> +IEEE128_DECL (vwarnx) (const char *format, __gnuc_va_list ap)
> +{
> +  __vwarnx_internal (format, ap, PRINTF_LDBL_USES_FLOAT128);
> +}
> +IEEE128_ALIAS (vwarnx)
> +
> +void
> +IEEE128_DECL (warn) (const char *format, ...)
> +{
> +  VA (vwarn (format, ap))
> +}
> +IEEE128_ALIAS (warn)
> +
> +void
> +IEEE128_DECL (warnx) (const char *format, ...)
> +{
> +  VA (vwarnx (format, ap))
> +}
> +IEEE128_ALIAS (warnx)

OK


> +
> +void
> +IEEE128_DECL (verr) (int status, const char *format, __gnuc_va_list ap)
> +{
> +  IEEE128_CALL (vwarn) (format, ap);
> +  exit (status);
> +}
> +IEEE128_ALIAS (verr)
> +
> +void
> +IEEE128_DECL (verrx) (int status, const char *format, __gnuc_va_list ap)
> +{
> +  IEEE128_CALL (vwarnx) (format, ap);
> +  exit (status);
> +}
> +IEEE128_ALIAS (verrx)

I notice the nldbl wrappers call __vwarn{,x}_internal directly with the 
respective mode option.  I think it is OK as is.

> +
> +void
> +IEEE128_DECL (err) (int status, const char *format, ...)
> +{
> +  VA (verr (status, format, ap))
> +}
> +IEEE128_ALIAS (err)
> +
> +void
> +IEEE128_DECL (errx) (int status, const char *format, ...)
> +{
> +  VA (verrx (status, format, ap))
> +}
> +IEEE128_ALIAS (errx)
> 
OK.

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

* Re: [PATCH v2 11/30] ldbl-128ibm-compat: Add error.h functions
  2019-10-25 15:33 ` [PATCH v2 11/30] ldbl-128ibm-compat: Add error.h functions Gabriel F. T. Gomes
@ 2019-11-08 22:21   ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 22:21 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Use the recently added, internal functions, __error_at_line_internal and
> __error_internal, to provide error.h functions that can take long double
> arguments with IEEE binary128 format on platforms where long double can
> also take double format or some non-IEEE format (currently, this means
> powerpc64le).
> 
> Tested for powerpc64le.
> ---
>   misc/errorP.h                                 | 28 ++++++++++
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  3 +-
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  3 ++
>   .../ldbl-128ibm-compat/ieee128-error.c        | 51 +++++++++++++++++++
>   4 files changed, 84 insertions(+), 1 deletion(-)
>   create mode 100644 misc/errorP.h
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c
> 
> diff --git a/misc/errorP.h b/misc/errorP.h
> new file mode 100644
> index 0000000000..c61c49cd61
> --- /dev/null
> +++ b/misc/errorP.h
> @@ -0,0 +1,28 @@
> +/* Prototypes for internal error.h functions.
> +   Copyright (C) 2018 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdarg.h>
> +
> +void
> +__error_internal (int status, int errnum, const char *message,
> +		  va_list args, unsigned int mode_flags);
> +
> +void
> +__error_at_line_internal (int status, int errnum, const char *file_name,
> +			  unsigned int line_number, const char *message,
> +			  va_list args, unsigned int mode_flags);

A similar question to patch 10 in this series. These declarations appear 
in include/error.h too.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c

OK.

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

* Re: [PATCH v2 12/30] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions
  2019-10-25 15:33 ` [PATCH v2 12/30] ldbl-128ibm-compat: Reuse tests for err.h and " Gabriel F. T. Gomes
@ 2019-11-08 22:25   ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 22:25 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Commit IDs 9771e6cb5102 and 7597b0c7f711 added tests for the functions
> from err.h and error.h that can take long double parameters.
> Afterwards, commit ID f0eaf8627654 reused them on architectures that
> changed the long double format from the same as double to something else
> (i.e.: architectures that imply ldbl-opt).  This patch reuses it again
> for IEEE long double on powerpc64le.
> 
> Tested for powerpc64le.
> ---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 15 +++++++++++++++
>   1 file changed, 15 insertions(+)
> 
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index a09209a2dd..ed0e2ec098 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> @@ -177,6 +177,21 @@ endif
>   ifeq ($(subdir),misc)
>   ldbl-extra-routines += err \
>   		       error
> +
> +tests-internal += tst-ibm128-warn tst-ieee128-warn
> +tests-internal += tst-ibm128-error tst-ieee128-error
> +
> +$(objpfx)tst-ibm128-%.c: tst-ldbl-%.c
> +	cp $< $@
> +
> +$(objpfx)tst-ieee128-%.c: tst-ldbl-%.c
> +	cp $< $@
> +
> +CFLAGS-tst-ibm128-warn.c += -mabi=ibmlongdouble -Wno-psabi
> +CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi
> +
> +CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
> +CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
>   endif
> 
>   # Add IEEE binary128 files as make targets.
> 

OK.

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

* Re: [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-10-25 15:33 ` [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Gabriel F. T. Gomes
@ 2019-11-08 23:25   ` Paul E Murphy
  2019-11-21 13:43     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 23:25 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> 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 and on
> _GNU_SOURCE.  When _GNU_SOURCE is not set and when in compatibility with
> ISO C99, these modifiers consume a floating-point argument.  Otherwise,
> they behave like ascanf, and allocate memory for the output.  This patch
> adds the IEEE binary128 variant of these functions for the third long
> double format on powerpc64le.
> 
> Tested for powerpc64le.

git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile 
b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c

...

The various wrappers all look OK.


> +strong_alias (___ieee128_isoc99_wscanf, __isoc99_wscanfieee128)
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
> new file mode 100644
> index 0000000000..70688ac2bb
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c
> @@ -0,0 +1,13 @@
> +#undef _GNU_SOURCE
> +/* The following macro definitions are a hack.  They word around disabling
> +   the GNU extension while still using a few internal headers.  */
> +#define u_char unsigned char
> +#define u_short unsigned short
> +#define u_int unsigned int
> +#define u_long unsigned long
> +#include <libio/stdio.h>
> +#include <stdlib/stdlib.h>
> +#include <string/string.h>
> +#include <wcsmbs/wchar.h>
> +
> +#include <test-isoc99-scanf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
> new file mode 100644
> index 0000000000..70688ac2bb
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
> @@ -0,0 +1,13 @@
> +#undef _GNU_SOURCE
> +/* The following macro definitions are a hack.  They word around disabling
> +   the GNU extension while still using a few internal headers.  */

Indeed a hack. How frail is this?

> +#define u_char unsigned char
> +#define u_short unsigned short
> +#define u_int unsigned int
> +#define u_long unsigned long
> +#include <libio/stdio.h>
> +#include <stdlib/stdlib.h>
> +#include <string/string.h>
> +#include <wcsmbs/wchar.h>
> +
> +#include <test-isoc99-scanf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
> new file mode 100644
> index 0000000000..ffc7ca2aaa
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c
> @@ -0,0 +1,119 @@
> +/* Test for the long double variants of __isoc99_*scanf functions.
> +   Copyright (C) 2018 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <stdarg.h>
> +#include <stdint.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <wchar.h>
> +
> +#include <support/check.h>
> +
> +#define CLEAR_VARGS							\
> +  va_start (args, format);						\
> +  ldptr = va_arg (args, long double *);					\
> +  fptr = va_arg (args, float *);					\
> +  *ldptr = 0;								\
> +  *fptr = 0;								\
> +  va_end (args);
> +
> +#define CHECK_VARGS							\
> +  va_start (args, format);						\
> +  ldptr = va_arg (args, long double *);					\
> +  fptr = va_arg (args, float *);					\
> +  va_end (args);							\
> +  if (*ldptr == -1 && *fptr == -2)					\

Should the pointer itself also be verified?

> +    printf ("OK");							\
> +  else									\
> +    printf ("ERROR (%Lf %f)", *ldptr, *fptr);				\
> +  printf ("\n");
> +
> +#define CLEAR_VALUE							\
> +  ld = 0;								\
> +  f = 0;
> +
> +#define CHECK_VALUE							\
> +  if (ld == -1 && f == -2)						\
> +    printf ("OK");							\
> +  else									\
> +    printf ("ERROR (%Lf %f)", ld, f);					\
> +  printf ("\n");
> +
> +static void
> +do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
> +{
> +  float *fptr;
> +  float f;
> +  long double *ldptr;
> +  long double ld;
> +  va_list args;
> +
> +  CLEAR_VALUE
> +  printf ("fscanf: ");
> +  FSCANF (stream, format, &ld, &f);
> +  CHECK_VALUE
> +
> +  CLEAR_VALUE
> +  printf ("scanf: ");
> +  SCANF (format, &ld, &f);
> +  CHECK_VALUE
> +
> +  CLEAR_VALUE
> +  printf ("sscanf: ");
> +  SSCANF (string, format, &ld, &f);
> +  CHECK_VALUE
> +
> +  CLEAR_VARGS
> +  printf ("vfscanf: ");
> +  va_start (args, format);
> +  VFSCANF (stream, format, args);
> +  va_end (args);
> +  CHECK_VARGS
> +
> +  CLEAR_VARGS
> +  printf ("vscanf: ");
> +  va_start (args, format);
> +  VSCANF (format, args);
> +  va_end (args);
> +  CHECK_VARGS
> +
> +  CLEAR_VARGS
> +  printf ("vsscanf: ");
> +  va_start (args, format);
> +  VSSCANF (string, format, args);
> +  va_end (args);
> +  CHECK_VARGS
> +}
> +
> +static int
> +do_test (void)
> +{
> +  CHAR string[256];
> +  float f;
> +  long double ld;
> +
> +  /* Scan floating-point value with '%as'.  */
> +  STRCPY (string,
> +	  L ("-0x1.0p+0 -0x2.0p+0\n")
> +	  L ("-0x1.0p+0 -0x2.0p+0\n") );
> +  do_test_call (stdin, string, L("%La %as"), &ld, &f);
> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh

OK

ysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c 
b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
> new file mode 100644
> index 0000000000..6be29624d9
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c
> @@ -0,0 +1,13 @@
> +#undef _GNU_SOURCE
> +/* The following macro definitions are a hack.  They word around disabling
> +   the GNU extension while still using a few internal headers.  */
> +#define u_char unsigned char
> +#define u_short unsigned short
> +#define u_int unsigned int
> +#define u_long unsigned long
> +#include <libio/stdio.h>
> +#include <stdlib/stdlib.h>
> +#include <string/string.h>
> +#include <wcsmbs/wchar.h>
> +
> +#include <test-isoc99-wscanf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
> new file mode 100644
> index 0000000000..6be29624d9
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
> @@ -0,0 +1,13 @@
> +#undef _GNU_SOURCE
> +/* The following macro definitions are a hack.  They word around disabling
> +   the GNU extension while still using a few internal headers.  */

The same hack shows up four times, should it be isolated in one place?

> +#define u_char unsigned char
> +#define u_short unsigned short
> +#define u_int unsigned int
> +#define u_long unsigned long
> +#include <libio/stdio.h>
> +#include <stdlib/stdlib.h>
> +#include <string/string.h>
> +#include <wcsmbs/wchar.h>
> +
> +#include <test-isoc99-wscanf-ldbl-compat.c>

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.l > 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

OK

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

* Re: [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions
  2019-10-25 15:33 ` [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions Gabriel F. T. Gomes
@ 2019-11-08 23:42   ` Paul E Murphy
  2019-11-27 19:11     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-08 23:42 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Similarly to the functions from the *printf family, this patch adds
> implementations for __obstack_*printf* functions that set the
> 'mode_flags' parameter to PRINTF_LDBL_USES_FLOAT128, before making calls
> to __vfprintf_internal (indirectly through __obstack_vprintf_internal).

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c

...

The wrappers all look OK.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat. > diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c 
b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c

OK.  I think it may be time to start the weekend.

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

* Re: [PATCH v2 08/30] ldbl-128ibm-compat: Add wide character scanning functions
  2019-11-04 17:46   ` Paul E Murphy
@ 2019-11-11 14:33     ` Gabriel F. T. Gomes
  2019-11-22 22:34       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-11 14:33 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Mon, 04 Nov 2019, Paul E Murphy wrote:
>
>With exception to some minor comments in my previous reviews, are there 
>any additional suggestions from the community? The *printf and *scanf 
>patches look ready to commit.

Thanks,

I'm running patches 1 to 8 with build-many-glibcs.py once again before I
commit them, which I plan to do after the test is over.  I think they got
a lot of feedback, specially if you count the initial patches sent before
Zack's refactoring of vfprinf_internal and vfscanf_internal, and have
converged to this version based on community suggestions and guidance. :)

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

* Re: [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions
  2019-11-08 20:22   ` Paul E Murphy
@ 2019-11-13 14:24     ` Gabriel F. T. Gomes
  2019-11-27 19:10       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-13 14:24 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

On Fri, 08 Nov 2019, Paul E Murphy wrote:

>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
>> 
>> diff --git a/misc/errP.h b/misc/errP.h  
>
>These are also declared in includes/err.h. Is there a subtle configury 
>that prevents their usage?

Not at all, you're totally right.  Removed (locally) in favor of
include/err.h (here and in the subsequent patch, v2 11/30).

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

* Re: [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions
  2019-10-25 15:33 ` [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
@ 2019-11-14 17:47   ` Paul E Murphy
  2019-11-14 18:25   ` Florian Weimer
  1 sibling, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-14 17:47 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> Changes since v1:
> 
>    - Moved the test to a container, which stopped messages being written
>      to the system log.
> 
> Comment from v1:
> 
> I'm using 'syslog (LOG_DEBUG, etc.);' and support_capture_subprocess in
> the test case, which I believe will not print to the console, but I'm
> not sure if changing some system setting to high verbosity will disturb
> people's lives.  Please advise.  :)
> 
> -- 8< --
> Similarly to __vfprintf_internal and __vfscanf_internal, the internal
> implementation of syslog functions (__vsyslog_internal) takes a
> 'mode_flags' parameter used to select the format of long double
> parameters.  This patch adds variants of the syslog functions that set
> 'mode_flags' to PRINTF_LDBL_USES_FLOAT128, thus enabling the correct
> printing of long double values on powerpc64le, when long double has IEEE
> binary128 format (-mabi=ieeelongdouble).
> 
> Tested for powerpc64le.

glibc has containers these days, neat. This looks OK to me and addresses 
the feedback from v1.

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

* Re: [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format
  2019-10-25 15:33 ` [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Gabriel F. T. Gomes
@ 2019-11-14 18:03   ` Paul E Murphy
  2019-11-27 17:43     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-14 18:03 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Similarly to what has been done for printf-like functions, more
> specifically to the internal implementation in __vfprintf_internal, this
> patch extends __vstrfmon_l_internal to deal with long double values with
> binary128 format (as a third format option and reusing the float128
> implementation).
> 
> Tested for powerpc64le and x86_64.
> ---
>   include/monetary.h                            |  1 +
>   stdlib/strfmon_l.c                            | 31 +++++++++++++---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   | 12 +++++++
>   sysdeps/ieee754/ldbl-128ibm-compat/Versions   |  3 ++
>   .../ldbl-128ibm-compat/ieee128-strfmon.c      | 35 +++++++++++++++++++
>   .../ldbl-128ibm-compat/ieee128-strfmon_l.c    | 35 +++++++++++++++++++
>   6 files changed, 113 insertions(+), 4 deletions(-)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c
> 
> diff --git a/include/monetary.h b/include/monetary.h
> index f59bdf9150..240925e87d 100644
> --- a/include/monetary.h
> +++ b/include/monetary.h
> @@ -15,5 +15,6 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>      same format as double, in which case the flag should be set to one,
>      or as another format, otherwise.  */
>   #define STRFMON_LDBL_IS_DBL 0x0001
> +#define STRFMON_LDBL_USES_FLOAT128  0x0002
> 
>   #endif
> diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
> index 134dad6963..b26cec24e2 100644
> --- a/stdlib/strfmon_l.c
> +++ b/stdlib/strfmon_l.c
> @@ -29,6 +29,7 @@
>   #include <stdio.h>
>   #include <string.h>
>   #include "../locale/localeinfo.h"
> +#include <bits/floatn.h>
> 
> 
>   #define out_char(Ch)							      \
> @@ -96,6 +97,9 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>         {
>   	double dbl;
>   	long double ldbl;
> +#if __HAVE_DISTINCT_FLOAT128
> +      _Float128 f128;

Nit, should this be a hard tab? Otherwise, OK

> +#endif
>         }
>         fpnum;
>         int int_format;
> @@ -106,6 +110,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>         int group;
>         char pad;
>         int is_long_double;
> +      int is_binary128;
>         int p_sign_posn;
>         int n_sign_posn;
>         int sign_posn;
> @@ -150,6 +155,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>         group = 1;			/* Print digits grouped.  */
>         pad = ' ';			/* Fill character is <SP>.  */
>         is_long_double = 0;		/* Double argument by default.  */
> +      is_binary128 = 0;		/* Long double argument by default.  */

Nit, is the spacing of the comment off here too?

>         p_sign_posn = -2;			/* This indicates whether the */
>         n_sign_posn = -2;			/* '(' flag is given.  */
>         width = -1;			/* No width specified so far.  */
> @@ -270,6 +276,10 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>   	  ++fmt;
>   	  if (__glibc_likely ((flags & STRFMON_LDBL_IS_DBL) == 0))
>   	    is_long_double = 1;
> +#if __HAVE_DISTINCT_FLOAT128
> +	  if (__glibc_likely ((flags & STRFMON_LDBL_USES_FLOAT128) != 0))
> +	    is_binary128 = is_long_double;
> +#endif

OK

>   	}
> 
>         /* Handle format specifier.  */
> @@ -324,10 +334,22 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>         /* Now it's time to get the value.  */
>         if (is_long_double == 1)
>   	{
> -	  fpnum.ldbl = va_arg (ap, long double);
> -	  is_negative = fpnum.ldbl < 0;
> -	  if (is_negative)
> -	    fpnum.ldbl = -fpnum.ldbl;
> +#if __HAVE_DISTINCT_FLOAT128
> +	  if (is_binary128 == 1)
> +	    {
> +	      fpnum.f128 = va_arg (ap, _Float128);
> +	      is_negative = fpnum.f128 < 0;
> +	      if (is_negative)
> +	        fpnum.f128 = -fpnum.f128;
> +	    }
> +	  else
> +#endif
> +	  {
> +	    fpnum.ldbl = va_arg (ap, long double);
> +	    is_negative = fpnum.ldbl < 0;
> +	    if (is_negative)
> +	      fpnum.ldbl = -fpnum.ldbl;
> +	  }

OK

>   	}
>         else
>   	{
> @@ -517,6 +539,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
>         info.width = left_prec + (right_prec ? (right_prec + 1) : 0);
>         info.spec = 'f';
>         info.is_long_double = is_long_double;
> +      info.is_binary128 = is_binary128;

OK

>         info.group = group;
>         info.pad = pad;
>         info.extra = 1;		/* This means use values from LC_MONETARY.  */

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c

OK

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

* Re: [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l
  2019-10-25 15:33 ` [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Gabriel F. T. Gomes
@ 2019-11-14 18:11   ` Paul E Murphy
  2019-12-03 16:57     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-14 18:11 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> This patch adds elementary tests to check that strfmon and strfmon_l
> correctly evaluate long double values with IBM Extended Precision and
> IEEE binary128 format.
> 
> Tested for powerpc64le.
> ---
>   sysdeps/ieee754/ldbl-128ibm-compat/Makefile   |  6 ++
>   .../ldbl-128ibm-compat/test-strfmon-ibm128.c  |  1 +
>   .../ldbl-128ibm-compat/test-strfmon-ieee128.c |  1 +
>   .../test-strfmon-ldbl-compat.c                | 59 +++++++++++++++++++
>   4 files changed, 67 insertions(+)
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
>   create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c
> 
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c

OK

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

* Re: [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions
  2019-10-25 15:33 ` [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions Gabriel F. T. Gomes
  2019-11-14 17:47   ` Paul E Murphy
@ 2019-11-14 18:25   ` Florian Weimer
  2019-11-27 19:11     ` Gabriel F. T. Gomes
  1 sibling, 1 reply; 72+ messages in thread
From: Florian Weimer @ 2019-11-14 18:25 UTC (permalink / raw)
  To: Gabriel F. T. Gomes; +Cc: libc-alpha

* Gabriel F. T. Gomes:

> +   Copyright (C) 2018 Free Software Foundation, Inc.

Copyright year needs adjusting (twice).

I don't think we will ever pass through /dev/log from the container, so
this should work for suppressing the messages.

You could also use support_become_root, and, in the child process,
xchroot if you don't want to use the full container environment, but the
container is okay too.

Thanks,
Florian


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

* Re: [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
  2019-10-25 15:33 ` [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Gabriel F. T. Gomes
@ 2019-11-14 18:25   ` Paul E Murphy
  2019-11-27 17:47     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-14 18:25 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> Since the commit
> 
> commit 86a0f56158bd9cbaf2d640e2e6c66539f4cbbcc1
> Author: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
> Date:   Thu Jun 28 13:57:50 2018 +0530
> 
>      ldbl-128ibm-compat: Introduce ieee128 symbols
> 
> IEEE long double versions of strfroml, strtold, and wcstold have been
> prepared, but not exposed (which will only happen when the full support
> for IEEE long double is complete).  This patch adds tests for these
> functions in both IBM and IEEE long double mode.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c
OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c

OK

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
> new file mode 100644
> index 0000000000..8b9e300147
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c
> @@ -0,0 +1,36 @@
> +/* Test for the long double variant of wcstold.
> +   Copyright (C) 2019 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#include <wchar.h>
> +
> +#include <support/check.h>
> +
> +static int
> +do_test (void)
> +{
> +  const wchar_t *input = L"-1.0000000000";
> +  long double read;
> +
> +  read = wcstold (input, NULL);
> +  if (read != (long double) -1)

Trivial nit, any reason to avoid using -1.0L directly (likewise for 
test-wcstold-ldbl-compat.c)?

> +    support_record_failure ();
> +
> +  return 0;
> +}
> +
> +#include <support/test-driver.c>
> 

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

* Re: [PATCH v2 07/30] ldbl-128ibm-compat: Add regular character scanning functions
  2019-10-25 15:33 ` [PATCH v2 07/30] ldbl-128ibm-compat: Add regular character scanning functions Gabriel F. T. Gomes
@ 2019-11-14 21:36   ` Paul E Murphy
  0 siblings, 0 replies; 72+ messages in thread
From: Paul E Murphy @ 2019-11-14 21:36 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> No changes since v1.
> 
> -- 8< --
> The 'mode' argument to __vfscanf_internal allows the selection of the
> long double format for all long double arguments requested by the format
> string.  Currently, there are two possibilities: long double with the
> same format as double or long double as something else.  The 'something
> else' format varies between architectures, and on powerpc64le, it means
> IBM Extended Precision format.
> 
> In preparation for the third option of long double format on
> powerpc64le, this patch uses the new mode mask,
> SCANF_LDBL_USES_FLOAT128, which tells __vfscanf_internal to call
> __strtof128_internal, instead of __strtold_internal, and save the output
> into a _Float128 variable.
> 
> Tested for powerpc64le.

I accidentally hopped over this one.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.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
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c

These all look OK.

> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
> new file mode 100644
> index 0000000000..822b4c3607
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh
> @@ -0,0 +1,63 @@
> +#!/bin/sh
> +# Testing of *scanf.  IEEE binary128 for powerpc64le version.
> +# Copyright (C) 2018 Free Software Foundation, Inc.

Minor nit, the copyright dates should be updated throughout too. 
Otherwise, OK.

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

* Re: [PATCH v2 23/30] Refactor *cvt functions implementation (5/5)
  2019-10-25 15:34 ` [PATCH v2 23/30] Refactor *cvt functions implementation (5/5) Gabriel F. T. Gomes
@ 2019-11-14 23:12   ` Paul E Murphy
  2019-11-27 17:42     ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Paul E Murphy @ 2019-11-14 23:12 UTC (permalink / raw)
  To: Gabriel F. T. Gomes, libc-alpha



On 10/25/19 10:34 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
> 
> 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).
> 
> -- 8< --
> 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.

I think the non-trivial changes here to fixup the shuffling and the 
preceding four patches should be squashed and resent as a single patch 
to the list. I am guessing they should squash into a somewhat readable 
patch self contained patch.

The slightly more substantial changes needed to support the new ldbl 
would be more easily reviewed as a separate patch (e.g replacing the 
__APPEND macro and reworking cvt_symbol)


> diff --git a/misc/efgcvt.c b/misc/efgcvt.c
> index 81ac60415e..93a0269d5c 100644
> --- a/misc/efgcvt.c
> +++ b/misc/efgcvt.c
> @@ -16,19 +16,27 @@
>      License along with the GNU C Library; if not, see
>      <http://www.gnu.org/licenses/>.  */
> 
> -#include "efgcvt.c"

I see some noise in the refactoring :). (and in efgcvt_r.c),


> diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c

...

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

These macros don't even appear to be used... OK.


> diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
> index aa0eb8ca43..5b48ca5b9b 100644
> --- a/misc/efgcvt_r.c
> +++ b/misc/efgcvt_r.c
> @@ -16,22 +16,24 @@
>      License along with the GNU C Library; if not, see
>      <http://www.gnu.org/licenses/>.  */
> 
> -#include "efgcvt_r.c"
> +#define ECVT_R ecvt_r
> +#define FCVT_R fcvt_r
> +#define __ECVT_R __ecvt_r
> +#define __FCVT_R __fcvt_r
> +#include <efgcvt-dbl-macros.h>
> +#include <efgcvt_r-template.c>
> 
>   #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
> -# define cvt_symbol(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 ea48c6b48a..903bf93aa4 100644
> --- a/misc/qefgcvt.c
> +++ b/misc/qefgcvt.c
> @@ -16,18 +16,24 @@
>      License along with the GNU C Library; if not, see
>      <https://www.gnu.org/licenses/>.  */
> 
> -#include "efgcvt.c"
> +#define ECVT qecvt
> +#define FCVT qfcvt
> +#define GCVT qgcvt
> +#define __ECVT __qecvt
> +#define __FCVT __qfcvt
> +#define __GCVT __qgcvt
> +#define __ECVT_R __qecvt_r
> +#define __FCVT_R __qfcvt_r
> +#include <efgcvt-ldbl-macros.h>
> +#include <efgcvt-template.c>
> 
>   #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
> -# define cvt_symbol(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 d2f36e6d2a..b790bf7837 100644
> --- a/misc/qefgcvt_r.c
> +++ b/misc/qefgcvt_r.c
> @@ -17,21 +17,21 @@
>      License along with the GNU C Library; if not, see
>      <https://www.gnu.org/licenses/>.  */
> 
> -#include "efgcvt_r.c"
> +#define ECVT_R qecvt_r
> +#define FCVT_R qfcvt_r
> +#define __ECVT_R __qecvt_r
> +#define __FCVT_R __qfcvt_r
> +#include <efgcvt-ldbl-macros.h>
> +#include <efgcvt_r-template.c>
> 
>   #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
> -# define cvt_symbol(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)

This isn't a bug with the patch, but should the version tested in 
LONG_DOUBLE_COMPAT match that passed into versioned_symbol?

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

The two non-trivial versioning macros get duplicated in two places. Is 
it possible to unify the four very similar instances into a single 
shared macro?

> -cvt_symbol(fcvt_r);
> -cvt_symbol(ecvt_r);
> +cvt_symbol (__qfcvt_r, qfcvt_r);
> +cvt_symbol (__qecvt_r, qecvt_r);
> 

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

* Re: [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-11-08 23:25   ` Paul E Murphy
@ 2019-11-21 13:43     ` Gabriel F. T. Gomes
  2019-11-22 22:48       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-21 13:43 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

Hi, Paul,

I'm sorry I took so long to reply to this message.  It sent me down a
rabbit hole.

On Fri, 08 Nov 2019, Paul E Murphy wrote:
>
>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
>> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>> 
>> --- /dev/null
>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c
>> @@ -0,0 +1,13 @@
>> +#undef _GNU_SOURCE
>> +/* The following macro definitions are a hack.  They word around disabling
>> +   the GNU extension while still using a few internal headers.  */  
>
>Indeed a hack. How frail is this?

A bit too much! :B

I spent some time trying to remember why I thought that was necessary and
I have a better understanding, now.

This hack is only really necessary for the wide-character versions of the
tests, because in wcsmbs/wchar.h, the redirections for vfwscanf, vwscanf,
and, more specifically, vswscanf to their ISO C99 versions is protected by
#if !defined __USE_GNU, whereas the redirections for fwscanf, wscanf, and
swscanf, as well as for all of the non-wide equivalents is protected by
#if !__GLIBC_USE (DEPRECATED_SCANF).

The use of DEPRECATED_SCANF is somewhat recent (added by commit ID
03992356e6fe) and it is my understanding that the change is missing for
vswscanf (and friends) simply due to oversight.

I have a patch to implement the missing change and I just finished running
it with build-many-glibcs.py.  I'll send it for review.

>> +#define u_char unsigned char
>> +#define u_short unsigned short
>> +#define u_int unsigned int
>> +#define u_long unsigned long
>> +#include <libio/stdio.h>
>> +#include <stdlib/stdlib.h>
>> +#include <string/string.h>
>> +#include <wcsmbs/wchar.h>
>>
>> [...]
>>
>> --- /dev/null
>> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c
>> @@ -0,0 +1,13 @@
>> +#undef _GNU_SOURCE
>> +/* The following macro definitions are a hack.  They word around disabling
>> +   the GNU extension while still using a few internal headers.  */  
>
>The same hack shows up four times, should it be isolated in one place?

With the fix, I'll try and make it all go away.  Thanks for pointing that out.

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

* Re: [PATCH v2 08/30] ldbl-128ibm-compat: Add wide character scanning functions
  2019-11-11 14:33     ` Gabriel F. T. Gomes
@ 2019-11-22 22:34       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-22 22:34 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Mon, 11 Nov 2019, Gabriel F. T. Gomes wrote:

>On Mon, 04 Nov 2019, Paul E Murphy wrote:
>>
>>With exception to some minor comments in my previous reviews, are there 
>>any additional suggestions from the community? The *printf and *scanf 
>>patches look ready to commit.  
>
>I'm running patches 1 to 8 with build-many-glibcs.py once again before I
>commit them, which I plan to do after the test is over.  I think they got
>a lot of feedback, specially if you count the initial patches sent before
>Zack's refactoring of vfprinf_internal and vfscanf_internal, and have
>converged to this version based on community suggestions and guidance. :)

I have finally committed patches 1 to 8 (after testing with b-m-g and
applying your suggestions: delay the definition of LDBL_IBM128_VERSION to
the last patch; guard the test in elf/tst-addr1.c (actually removed the
change); update copyright years).

Thanks.

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

* Re: [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions
  2019-11-21 13:43     ` Gabriel F. T. Gomes
@ 2019-11-22 22:48       ` Gabriel F. T. Gomes
  2019-11-27 19:12         ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-22 22:48 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Thu, 21 Nov 2019, Gabriel F. T. Gomes wrote:
>
>On Fri, 08 Nov 2019, Paul E Murphy wrote:
>>
>>The same hack shows up four times, should it be isolated in one place?  
>
>With the fix, I'll try and make it all go away.  Thanks for pointing that out.

Now that commit ID 93486ba583ec is in, these hacks are gone.  I'll send a
new version of this patch, probably next week.

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

* Re: [PATCH v2 23/30] Refactor *cvt functions implementation (5/5)
  2019-11-14 23:12   ` Paul E Murphy
@ 2019-11-27 17:42     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-27 17:42 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Thu, 14 Nov 2019, Paul E Murphy wrote:
>
>I think the non-trivial changes here to fixup the shuffling and the 
>preceding four patches should be squashed and resent as a single patch 
>to the list. I am guessing they should squash into a somewhat readable 
>patch self contained patch.

I guess you're right.  I'll send them squashed in v3.

>The slightly more substantial changes needed to support the new ldbl 
>would be more easily reviewed as a separate patch (e.g replacing the 
>__APPEND macro and reworking cvt_symbol)

Agreed.

>On 10/25/19 10:34 AM, Gabriel F. T. Gomes wrote:
>> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>>
>> -#include "efgcvt.c"  
>
>I see some noise in the refactoring :). (and in efgcvt_r.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)  
>
>This isn't a bug with the patch, but should the version tested in 
>LONG_DOUBLE_COMPAT match that passed into versioned_symbol?

We test against GLIBC_2_0, because that's the version that introduced
q{efg}cvt symbols for the first time.  The LONG_DOUBLE_COMPAT macro then
expands it to SHLIB_COMPAT with GLIBC_2_0 in the 'introduced' argument and
LONG_DOUBLE_COMPAT_VERSION in the 'obsoleted' argument.

I think it would be OK to change GLIBC_2_4 to LONG_DOUBLE_COMPAT_VERSION
(maybe that would make it easier to read).

For completeness, on powerpc64, replacing GLIBC_2_0 with GLIBC_2_4 makes
test cases fail to build, e.g.:

  misc/./tst-efgcvt-template.c:214: undefined reference to `qfcvt_r'
  .../misc/tst-ldbl-efgcvt.o:(.toc+0x0): undefined reference to `qecvt'
  .../misc/tst-ldbl-efgcvt.o:(.toc+0x8): undefined reference to `qfcvt'
  .../misc/tst-ldbl-efgcvt.o:(.toc+0x10): undefined reference to `qecvt_r'
  .../misc/tst-ldbl-efgcvt.o:(.toc+0x18): undefined reference to `qfcvt_r'
  collect2: error: ld returned 1 exit status

>The two non-trivial versioning macros get duplicated in two places. Is 
>it possible to unify the four very similar instances into a single 
>shared macro?

Before this refactoring, the macro definition for {efg}cvt and q{efg}cvt
was defined in a single file, but I failed to see any benefit in it (it
relied on the LONG_DOUBLE_CVT macro and provided completely different
definitions for each case (long double and double).  Likewise for the
sharing between {efg}cvt_r and q{efg}cvt_r.

As for the differences between {efg}cvt and {efg}cvt_r, they seem too
large to allow for the sharing of code (one uses weak_symbol where the
other uses strong_symbol; only [q]{efg}cvt_r require hidden_def). Likewise
for the long double versions.

I think a single definition for all cases would make the code harder to
read (maybe it would make it easier to maintain, but I actually find it
very confusing and hard to maintain when the macros depend on too many
things).

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

* Re: [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format
  2019-11-14 18:03   ` Paul E Murphy
@ 2019-11-27 17:43     ` Gabriel F. T. Gomes
  2019-12-03 16:57       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-27 17:43 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Thu, 14 Nov 2019, Paul E Murphy wrote:

>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
>>
>> +#if __HAVE_DISTINCT_FLOAT128
>> +      _Float128 f128;  
>
>Nit, should this be a hard tab? Otherwise, OK

Yes, you're right.  Fixed locally.

>> +      is_binary128 = 0;		/* Long double argument by default.  */  
>
>Nit, is the spacing of the comment off here too?

Yes.  Also fixed locally.


Thanks!

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

* Re: [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
  2019-11-14 18:25   ` Paul E Murphy
@ 2019-11-27 17:47     ` Gabriel F. T. Gomes
  2019-12-03 16:58       ` Gabriel F. T. Gomes
  0 siblings, 1 reply; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-27 17:47 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Thu, 14 Nov 2019, Paul E Murphy wrote:

>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
>>
>> +  if (read != (long double) -1)  
>
>Trivial nit, any reason to avoid using -1.0L directly (likewise for 
>test-wcstold-ldbl-compat.c)?

No reason, really.  I applied this suggestion locally (in both files).

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

* Re: [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions
  2019-11-13 14:24     ` Gabriel F. T. Gomes
@ 2019-11-27 19:10       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-27 19:10 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Wed, 13 Nov 2019, Gabriel F. T. Gomes wrote:

>On Fri, 08 Nov 2019, Paul E Murphy wrote:
>
>>These are also declared in includes/err.h. Is there a subtle configury 
>>that prevents their usage?  
>
>Not at all, you're totally right.  Removed (locally) in favor of
>include/err.h (here and in the subsequent patch, v2 11/30).

This and the subsequent patch are now pushed with this change.  Thanks!

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

* Re: [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions
  2019-11-08 23:42   ` Paul E Murphy
@ 2019-11-27 19:11     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-27 19:11 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Fri, 08 Nov 2019, Paul E Murphy wrote:

>The wrappers all look OK.

Thanks, now pushed to master.

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

* Re: [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions
  2019-11-14 18:25   ` Florian Weimer
@ 2019-11-27 19:11     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-11-27 19:11 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, Paul E Murphy

On Thu, 14 Nov 2019, Florian Weimer wrote:

>Copyright year needs adjusting (twice).

Fixed.

>I don't think we will ever pass through /dev/log from the container, so
>this should work for suppressing the messages.
>
>You could also use support_become_root, and, in the child process,
>xchroot if you don't want to use the full container environment, but the
>container is okay too.

Thanks, now pushed with the copyright years fixed.

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

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

On Fri, 22 Nov 2019, Gabriel F. T. Gomes wrote:

>I'll send a new version of this patch, probably next week.

Apart from Paul's suggestions, I have also unified two test cases for
reuse, which makes the patch smaller.  I'll send the new version shortly.


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

* Re: [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format
  2019-11-27 17:43     ` Gabriel F. T. Gomes
@ 2019-12-03 16:57       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 16:57 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Wed, 27 Nov 2019, Gabriel F. T. Gomes wrote:

>On Thu, 14 Nov 2019, Paul E Murphy wrote:
>
>>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:  
>>>
>>> +#if __HAVE_DISTINCT_FLOAT128
>>> +      _Float128 f128;    
>>
>>Nit, should this be a hard tab? Otherwise, OK  
>
>Yes, you're right.  Fixed locally.
>
>>> +      is_binary128 = 0;		/* Long double argument by default.  */    
>>
>>Nit, is the spacing of the comment off here too?  
>
>Yes.  Also fixed locally.

Now pushed with these changes and fixed copyright years.  Thanks!

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

* Re: [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l
  2019-11-14 18:11   ` Paul E Murphy
@ 2019-12-03 16:57     ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 16:57 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Thu, 14 Nov 2019, Paul E Murphy wrote:

>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
>> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>> 
>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c
>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c
>> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c  
>
>OK

Thanks, now pushed.

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

* Re: [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold
  2019-11-27 17:47     ` Gabriel F. T. Gomes
@ 2019-12-03 16:58       ` Gabriel F. T. Gomes
  0 siblings, 0 replies; 72+ messages in thread
From: Gabriel F. T. Gomes @ 2019-12-03 16:58 UTC (permalink / raw)
  To: Paul E Murphy; +Cc: libc-alpha

On Wed, 27 Nov 2019, Gabriel F. T. Gomes wrote:

>On Thu, 14 Nov 2019, Paul E Murphy wrote:
>
>>On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:  
>>>
>>> +  if (read != (long double) -1)    
>>
>>Trivial nit, any reason to avoid using -1.0L directly (likewise for 
>>test-wcstold-ldbl-compat.c)?  
>
>No reason, really.  I applied this suggestion locally (in both files).

Now pushed with this change.  Thanks.

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

end of thread, other threads:[~2019-12-03 16:58 UTC | newest]

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

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