Discussion:
[PATCH 00/14] Functions with format string for IEEE128 on powercpc64le
(too old to reply)
Gabriel F. T. Gomes
2018-06-21 02:10:09 UTC
Permalink
As a follow-up to my previous message on this topic [1], this patch set
adds more functions that need new versions on powerpc64le for the long
double format transition. There are functions that are still missing
(__isoc99_*scanf, printf_size, obstack_*printf, obstack_*printf_chk,
strfmon, as well as strfromld and strtold), thus, the redirections are
still on a temporary patch (not included in this email thread, but
provided in my personal branch [2]).

These changes depend on Zack's patches [3], which I have rebased on top
of current master and which are again available on my personal branch [2].

Changes since the RFC:

- Rebased the branch against current master;
- Fixed setting of 'is_binary128' and added a test for the printing of
double values in __*ieee128 functions;
- Renamed the external functions to the pattern __*ieee128;
- Added patch to prepare vfscanf to use the 'mode_flags' parameter on
__*ieee128 functions
- Added a similar patch to prepare functions from argp.h, err.h, and
error.h for the same goal (following Zack's idea of a 'mode_flags'
parameter.
- Added functions and tests for __*printfieee128, __*scanfieee128
(except for __isoc99_*scanf), as well as for the functions in
argp.h, err.h, and error.h.
- These changes are spread across many commits, in the hope that it
can ease review. If someone would prefer some squashes, that
sould be easy to do.

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

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

[3] https://sourceware.org/ml/libc-alpha/2018-03/msg00185.html

Gabriel F. T. Gomes (14):
Prepare vfprintf to use __printf_fp/__printf_fphex with float128 arg
Prepare vfscanf to use __strtof128_internal
Add internal implementations for argp.h, err.h, and error.h functions
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: 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: Add tests for err.h and error.h functions

argp/argp-help.c | 44 +--
argp/argpP.h | 29 ++
libio/libioP.h | 10 +-
misc/err.c | 36 ++-
misc/errP.h | 28 ++
misc/error.c | 46 ++-
misc/errorP.h | 28 ++
stdio-common/printf-parse.h | 3 +
stdio-common/vfprintf-internal.c | 62 +++-
stdio-common/vfscanf-internal.c | 14 +
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 333 +++++++++++++++++++++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 78 +++++
.../ldbl-128ibm-compat/ieee128-argp_error.c | 30 ++
.../ldbl-128ibm-compat/ieee128-argp_failure.c | 32 ++
.../ieee754/ldbl-128ibm-compat/ieee128-asprintf.c | 35 +++
.../ldbl-128ibm-compat/ieee128-asprintf_chk.c | 38 +++
.../ieee754/ldbl-128ibm-compat/ieee128-dprintf.c | 34 +++
.../ldbl-128ibm-compat/ieee128-dprintf_chk.c | 38 +++
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c | 93 ++++++
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c | 51 ++++
.../ieee754/ldbl-128ibm-compat/ieee128-fprintf.c | 34 +++
.../ldbl-128ibm-compat/ieee128-fprintf_chk.c | 38 +++
.../ieee754/ldbl-128ibm-compat/ieee128-fscanf.c | 34 +++
.../ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c | 35 +++
.../ldbl-128ibm-compat/ieee128-fwprintf_chk.c | 38 +++
.../ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c | 35 +++
.../ieee754/ldbl-128ibm-compat/ieee128-printf.c | 35 +++
.../ldbl-128ibm-compat/ieee128-printf_chk.c | 38 +++
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c | 34 +++
.../ieee754/ldbl-128ibm-compat/ieee128-snprintf.c | 35 +++
.../ldbl-128ibm-compat/ieee128-snprintf_chk.c | 42 +++
.../ieee754/ldbl-128ibm-compat/ieee128-sprintf.c | 35 +++
.../ldbl-128ibm-compat/ieee128-sprintf_chk.c | 42 +++
.../ieee754/ldbl-128ibm-compat/ieee128-sscanf.c | 38 +++
.../ieee754/ldbl-128ibm-compat/ieee128-swprintf.c | 36 +++
.../ldbl-128ibm-compat/ieee128-swprintf_chk.c | 42 +++
.../ieee754/ldbl-128ibm-compat/ieee128-swscanf.c | 40 +++
.../ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c | 27 ++
.../ldbl-128ibm-compat/ieee128-vasprintf_chk.c | 31 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c | 26 ++
.../ldbl-128ibm-compat/ieee128-vdprintf_chk.c | 30 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c | 26 ++
.../ldbl-128ibm-compat/ieee128-vfprintf_chk.c | 30 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c | 26 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c | 27 ++
.../ldbl-128ibm-compat/ieee128-vfwprintf_chk.c | 31 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c | 27 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vprintf.c | 27 ++
.../ldbl-128ibm-compat/ieee128-vprintf_chk.c | 30 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vscanf.c | 26 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c | 28 ++
.../ldbl-128ibm-compat/ieee128-vsnprintf_chk.c | 34 +++
.../ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c | 27 ++
.../ldbl-128ibm-compat/ieee128-vsprintf_chk.c | 34 +++
.../ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c | 29 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c | 28 ++
.../ldbl-128ibm-compat/ieee128-vswprintf_chk.c | 34 +++
.../ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c | 31 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c | 27 ++
.../ldbl-128ibm-compat/ieee128-vwprintf_chk.c | 30 ++
.../ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c | 27 ++
.../ieee754/ldbl-128ibm-compat/ieee128-wprintf.c | 35 +++
.../ldbl-128ibm-compat/ieee128-wprintf_chk.c | 38 +++
.../ieee754/ldbl-128ibm-compat/ieee128-wscanf.c | 35 +++
.../ldbl-128ibm-compat/test-argp-error-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-argp-error-ieee128.c | 1 +
.../test-argp-error-ldbl-compat.c | 3 +
.../test-argp-error-ldbl-compat.sh | 46 +++
.../ldbl-128ibm-compat/test-argp-failure-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-argp-failure-ieee128.c | 1 +
.../test-argp-failure-ldbl-compat.c | 3 +
.../test-argp-failure-ldbl-compat.sh | 45 +++
.../ldbl-128ibm-compat/test-argp-ldbl-compat.c | 69 +++++
.../ieee754/ldbl-128ibm-compat/test-err-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-err-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-err-ldbl-compat.c | 3 +
.../ldbl-128ibm-compat/test-err-ldbl-compat.sh | 44 +++
.../ldbl-128ibm-compat/test-error-ldbl-compat.c | 45 +++
.../ldbl-128ibm-compat/test-error1-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-error1-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-error1-ldbl-compat.c | 3 +
.../ldbl-128ibm-compat/test-error2-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-error2-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-error2-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-errx-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-errx-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-errx-ldbl-compat.c | 3 +
.../ldbl-128ibm-compat/test-printf-chk-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-printf-chk-ieee128.c | 1 +
.../test-printf-chk-ldbl-compat.c | 142 +++++++++
.../test-printf-chk-ldbl-compat.sh | 64 ++++
.../ldbl-128ibm-compat/test-printf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-printf-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-printf-ldbl-compat.c | 135 +++++++++
.../ldbl-128ibm-compat/test-printf-ldbl-compat.sh | 64 ++++
.../ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-scanf-ieee128.c | 1 +
.../test-scanf-ldbl-compat-template.c | 117 ++++++++
.../ldbl-128ibm-compat/test-scanf-ldbl-compat.c | 10 +
.../ldbl-128ibm-compat/test-scanf-ldbl-compat.sh | 63 ++++
.../ieee754/ldbl-128ibm-compat/test-verr-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-verr-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-verr-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-verrx-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-verrx-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-warn-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-warn-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-warn-ldbl-compat.c | 61 ++++
.../ldbl-128ibm-compat/test-warn-ldbl-compat.sh | 50 ++++
.../ldbl-128ibm-compat/test-wprintf-chk-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-wprintf-chk-ieee128.c | 1 +
.../test-wprintf-chk-ldbl-compat.c | 89 ++++++
.../test-wprintf-chk-ldbl-compat.sh | 52 ++++
.../ldbl-128ibm-compat/test-wprintf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-wprintf-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c | 89 ++++++
.../ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh | 52 ++++
.../ldbl-128ibm-compat/test-wscanf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-wscanf-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-wscanf-ldbl-compat.c | 10 +
.../powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h | 8 +
122 files changed, 3745 insertions(+), 58 deletions(-)
create mode 100644 argp/argpP.h
create mode 100644 misc/errP.h
create mode 100644 misc/errorP.h
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makefile
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_error.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_failure.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-printf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.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-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-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-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-argp-error-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-errx-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-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
create mode 100644 sysdeps/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-verr-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh
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-ldbl-compat.sh
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-wprintf-ldbl-compat.sh
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.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:10 UTC
Permalink
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of printf-like functions is aware of these possibilites
and properly parses floating-point values from the variable arguments,
before making calls to __printf_fp and __printf_fphex. These functions
are also aware of the format possibilites and know how to convert both
formats to string.

When library support for TS 18661-3 was added to glibc, __printf_fp and
__printf_fphex were extented with support for an additional type
(__float128/_Float128) with a different format (binary128). Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
__float128/_Float128, this patch extends __vfprintf_internal to properly
call __printf_fp and __printf_fphex with this new format.

Tested for powerpc64le (with additional patches to actually enable the
use of these preparations) and for x86_64.

* libio/libioP.h (PRINTF_LDBL_USES_FLOAT128): New macro to be
used as a mask for the mode argument of __vfprintf_internal.
* stdio-common/printf-parse.h (printf_arg): New union member:
pa_float128.
* stdio-common/vfprintf-internal.c
(LDBL_USES_FLOAT128): New macro.
(PARSE_FLOAT_VA_ARG_EXTENDED): Likewise.
(PARSE_FLOAT_VA_ARG): Likewise.
(SETUP_FLOAT128_INFO): Likewise.
(process_arg): Use PARSE_FLOAT_VA_ARG_EXTENDED and
SETUP_FLOAT128_INFO.
[__HAVE_FLOAT128_UNLIKE_LDBL] (printf_positional): Write
floating-point value to the new union member, pa_float128.
---
libio/libioP.h | 5 ++--
stdio-common/printf-parse.h | 3 ++
stdio-common/vfprintf-internal.c | 62 +++++++++++++++++++++++++++++++---------
3 files changed, 55 insertions(+), 15 deletions(-)

diff --git a/libio/libioP.h b/libio/libioP.h
index e9446b87f2..fba4b52460 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -687,8 +687,9 @@ extern int __vswprintf_internal (wchar_t *string, size_t maxlen,
unsigned int mode_flags);

/* Flags for __v*printf_internal. */
-#define PRINTF_LDBL_IS_DBL 0x0001
-#define PRINTF_FORTIFY 0x0002
+#define PRINTF_LDBL_IS_DBL 0x0001
+#define PRINTF_FORTIFY 0x0002
+#define PRINTF_LDBL_USES_FLOAT128 0x0004

extern size_t _IO_getline (FILE *,char *, size_t, int, int);
libc_hidden_proto (_IO_getline)
diff --git a/stdio-common/printf-parse.h b/stdio-common/printf-parse.h
index e07186ec83..9c79f3c862 100644
--- a/stdio-common/printf-parse.h
+++ b/stdio-common/printf-parse.h
@@ -57,6 +57,9 @@ union printf_arg
unsigned long long int pa_u_long_long_int;
double pa_double;
long double pa_long_double;
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ _Float128 pa_float128;
+#endif
const char *pa_string;
const wchar_t *pa_wstring;
void *pa_pointer;
diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
index 2d9016e83b..95d36969d1 100644
--- a/stdio-common/vfprintf-internal.c
+++ b/stdio-common/vfprintf-internal.c
@@ -68,8 +68,43 @@
} while (0)
#define UNBUFFERED_P(S) ((S)->_flags & _IO_UNBUFFERED)
#define LDBL_IS_DBL (__glibc_unlikely ((mode_flags & PRINTF_LDBL_IS_DBL) != 0))
+#define LDBL_USES_FLOAT128 ((mode_flags & PRINTF_LDBL_USES_FLOAT128) != 0)
#define DO_FORTIFY ((mode_flags & PRINTF_FORTIFY) != 0)

+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ if (LDBL_USES_FLOAT128 && is_long_double) \
+ { \
+ INFO.is_binary128 = 1; \
+ the_arg.pa_float128 = va_arg (ap, _Float128); \
+ } \
+ else \
+ { \
+ PARSE_FLOAT_VA_ARG (INFO) \
+ }
+#else
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ PARSE_FLOAT_VA_ARG (INFO)
+#endif
+
+#define PARSE_FLOAT_VA_ARG(INFO) \
+ INFO.is_binary128 = 0; \
+ if (is_long_double) \
+ the_arg.pa_long_double = va_arg (ap, long double); \
+ else \
+ the_arg.pa_double = va_arg (ap, double);
+
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define SETUP_FLOAT128_INFO(INFO) \
+ if (LDBL_USES_FLOAT128) \
+ INFO.is_binary128 = is_long_double; \
+ else \
+ INFO.is_binary128 = 0;
+#else
+# define SETUP_FLOAT128_INFO(INFO) \
+ INFO.is_binary128 = 0;
+#endif
+
#define done_add(val) \
do { \
unsigned int _val = val; \
@@ -773,10 +808,7 @@ static const uint8_t jump_table[] =
.wide = sizeof (CHAR_T) != 1, \
.is_binary128 = 0}; \
\
- if (is_long_double) \
- the_arg.pa_long_double = va_arg (ap, long double); \
- else \
- the_arg.pa_double = va_arg (ap, double); \
+ PARSE_FLOAT_VA_ARG_EXTENDED (info) \
ptr = (const void *) &the_arg; \
\
function_done = __printf_fp (s, &info, &ptr); \
@@ -789,8 +821,7 @@ static const uint8_t jump_table[] =
fspec->data_arg_type = PA_DOUBLE; \
fspec->info.is_long_double = 0; \
} \
- /* Not supported by *printf functions. */ \
- fspec->info.is_binary128 = 0; \
+ SETUP_FLOAT128_INFO (fspec->info) \
\
function_done = __printf_fp (s, &fspec->info, &ptr); \
} \
@@ -833,10 +864,7 @@ static const uint8_t jump_table[] =
.wide = sizeof (CHAR_T) != 1, \
.is_binary128 = 0}; \
\
- if (is_long_double) \
- the_arg.pa_long_double = va_arg (ap, long double); \
- else \
- the_arg.pa_double = va_arg (ap, double); \
+ PARSE_FLOAT_VA_ARG_EXTENDED (info) \
ptr = (const void *) &the_arg; \
\
function_done = __printf_fphex (s, &info, &ptr); \
@@ -846,8 +874,7 @@ static const uint8_t jump_table[] =
ptr = (const void *) &args_value[fspec->data_arg]; \
if (LDBL_IS_DBL) \
fspec->info.is_long_double = 0; \
- /* Not supported by *printf functions. */ \
- fspec->info.is_binary128 = 0; \
+ SETUP_FLOAT128_INFO (fspec->info) \
\
function_done = __printf_fphex (s, &fspec->info, &ptr); \
} \
@@ -1871,6 +1898,10 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
args_value[cnt].pa_double = va_arg (*ap_savep, double);
args_type[cnt] &= ~PA_FLAG_LONG_DOUBLE;
}
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ else if (LDBL_USES_FLOAT128)
+ args_value[cnt].pa_float128 = va_arg (*ap_savep, _Float128);
+#endif
else
args_value[cnt].pa_long_double = va_arg (*ap_savep, long double);
break;
@@ -1889,7 +1920,12 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
(args_value[cnt].pa_user, ap_savep);
}
else
- args_value[cnt].pa_long_double = 0.0;
+ {
+ args_value[cnt].pa_long_double = 0.0;
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ args_value[cnt].pa_float128 = 0;
+#endif
+ }
break;
case -1:
/* Error case. Not all parameters appear in N$ format
--
2.14.4
Joseph Myers
2018-06-21 21:22:15 UTC
Permalink
Post by Gabriel F. T. Gomes
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ if (LDBL_USES_FLOAT128 && is_long_double) \
+ { \
+ INFO.is_binary128 = 1; \
+ the_arg.pa_float128 = va_arg (ap, _Float128); \
+ } \
+ else \
+ { \
+ PARSE_FLOAT_VA_ARG (INFO) \
+ }
I'd expect all these macros to be implemented in the do { ... } while (0)
style, so that they do genuinely act as single statements when followed by
';', and then to be followed by ';' at the sites where they are used (so
avoiding editors messing up indentation at / after those sites), unless
there is some reason that convention can't work here.
--
Joseph S. Myers
***@codesourcery.com
Gabriel F. T. Gomes
2018-12-07 20:15:57 UTC
Permalink
Post by Joseph Myers
Post by Gabriel F. T. Gomes
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ if (LDBL_USES_FLOAT128 && is_long_double) \
+ { \
+ INFO.is_binary128 = 1; \
+ the_arg.pa_float128 = va_arg (ap, _Float128); \
+ } \
+ else \
+ { \
+ PARSE_FLOAT_VA_ARG (INFO) \
+ }
I'd expect all these macros to be implemented in the do { ... } while (0)
style, so that they do genuinely act as single statements when followed by
';', and then to be followed by ';' at the sites where they are used (so
avoiding editors messing up indentation at / after those sites), unless
there is some reason that convention can't work here.
I have updated this patch for this comment and for comments to the removal
of __ldbl_is_dbl removal series that also apply here. This is the updated
patch:

From 2fa3d126947dc63be408009b3b926c706bef3824 Mon Sep 17 00:00:00 2001
From: "Gabriel F. T. Gomes" <***@inconstante.eti.br>
Date: Sun, 3 Jun 2018 17:20:43 -0300
Subject: [PATCH v2] Prepare vfprintf to use __printf_fp/__printf_fphex with
float128 arg

Changes since v1:

- Updated to the revised and integrated patches for __ldbl_is_dbl
removal, i.e.: the patches in the following thread:
<https://sourceware.org/ml/libc-alpha/2018-12/msg00186.html>.
- Added description for the PRINTF_LDBL_USES_FLOAT128 macro.
- Removed the LDBL_USES_FLOAT128 macro.
- Added `do { } while (0)' to the PARSE_FLOAT_VA_ARG_EXTENDED,
PARSE_FLOAT_VA_ARG, and SETUP_FLOAT128_INFO macros. Appended
expansions with `;', accordingly.

-- 8< --
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of printf-like functions is aware of these possibilities
and properly parses floating-point values from the variable arguments,
before making calls to __printf_fp and __printf_fphex. These functions
are also aware of the format possibilities and know how to convert both
formats to string.

When library support for TS 18661-3 was added to glibc, __printf_fp and
__printf_fphex were extended with support for an additional type
(__float128/_Float128) with a different format (binary128). Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
__float128/_Float128, this patch extends __vfprintf_internal to properly
call __printf_fp and __printf_fphex with this new format.

Tested for powerpc64le (with additional patches to actually enable the
use of these preparations) and for x86_64.

* libio/libioP.h (PRINTF_LDBL_USES_FLOAT128): New macro to be
used as a mask for the mode argument of __vfprintf_internal.
* stdio-common/printf-parse.h (printf_arg): New union member:
pa_float128.
* stdio-common/vfprintf-internal.c
(PARSE_FLOAT_VA_ARG_EXTENDED): New macro.
(PARSE_FLOAT_VA_ARG): Likewise.
(SETUP_FLOAT128_INFO): Likewise.
(process_arg): Use PARSE_FLOAT_VA_ARG_EXTENDED and
SETUP_FLOAT128_INFO.
[__HAVE_FLOAT128_UNLIKE_LDBL] (printf_positional): Write
floating-point value to the new union member, pa_float128.
---
libio/libioP.h | 18 ++++++++--
stdio-common/printf-parse.h | 3 ++
stdio-common/vfprintf-internal.c | 74 +++++++++++++++++++++++++++++++++-------
3 files changed, 79 insertions(+), 16 deletions(-)

diff --git a/libio/libioP.h b/libio/libioP.h
index 958ef9bffe..f3c1d886c0 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -705,9 +705,21 @@ extern int __vswprintf_internal (wchar_t *string, size_t maxlen,
PRINTF_FORTIFY, when set to one, indicates that fortification checks
are to be performed in input parameters. This is used by the
__*printf_chk functions, which are used when _FORTIFY_SOURCE is
- defined to 1 or 2. Otherwise, such checks are ignored. */
-#define PRINTF_LDBL_IS_DBL 0x0001
-#define PRINTF_FORTIFY 0x0002
+ defined to 1 or 2. Otherwise, such checks are ignored.
+
+ PRINTF_LDBL_USES_FLOAT128 is used on platforms where the long double
+ format used to be different from the IEC 60559 double format *and*
+ also different from the Quadruple 128-bits IEC 60559 format (such as
+ the IBM Extended Precision format on powerpc or the 80-bits IEC 60559
+ format on x86), but was later converted to the Quadruple 128-bits IEC
+ 60559 format, which is the same format that the _Float128 always has
+ (hence the `USES_FLOAT128' suffix in the name of the flag). When set
+ to one, this macros indicates that long double values are to be
+ handled as having this new format. Otherwise, they should be handled
+ as the previous format on that platform. */
+#define PRINTF_LDBL_IS_DBL 0x0001
+#define PRINTF_FORTIFY 0x0002
+#define PRINTF_LDBL_USES_FLOAT128 0x0004

extern size_t _IO_getline (FILE *,char *, size_t, int, int);
libc_hidden_proto (_IO_getline)
diff --git a/stdio-common/printf-parse.h b/stdio-common/printf-parse.h
index e07186ec83..9c79f3c862 100644
--- a/stdio-common/printf-parse.h
+++ b/stdio-common/printf-parse.h
@@ -57,6 +57,9 @@ union printf_arg
unsigned long long int pa_u_long_long_int;
double pa_double;
long double pa_long_double;
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ _Float128 pa_float128;
+#endif
const char *pa_string;
const wchar_t *pa_wstring;
void *pa_pointer;
diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
index 61769e0ce1..4b74bfa31c 100644
--- a/stdio-common/vfprintf-internal.c
+++ b/stdio-common/vfprintf-internal.c
@@ -68,6 +68,53 @@
} while (0)
#define UNBUFFERED_P(S) ((S)->_flags & _IO_UNBUFFERED)

+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ do \
+ { \
+ if (is_long_double \
+ && (mode_flags & PRINTF_LDBL_USES_FLOAT128) != 0) \
+ { \
+ INFO.is_binary128 = 1; \
+ the_arg.pa_float128 = va_arg (ap, _Float128); \
+ } \
+ else \
+ { \
+ PARSE_FLOAT_VA_ARG (INFO); \
+ } \
+ } while (0)
+#else
+# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \
+ PARSE_FLOAT_VA_ARG (INFO);
+#endif
+
+#define PARSE_FLOAT_VA_ARG(INFO) \
+ do \
+ { \
+ INFO.is_binary128 = 0; \
+ if (is_long_double) \
+ the_arg.pa_long_double = va_arg (ap, long double); \
+ else \
+ the_arg.pa_double = va_arg (ap, double); \
+ } while (0)
+
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+# define SETUP_FLOAT128_INFO(INFO) \
+ do \
+ { \
+ if ((mode_flags & PRINTF_LDBL_USES_FLOAT128) != 0) \
+ INFO.is_binary128 = is_long_double; \
+ else \
+ INFO.is_binary128 = 0; \
+ } while (0)
+#else
+# define SETUP_FLOAT128_INFO(INFO) \
+ do \
+ { \
+ INFO.is_binary128 = 0; \
+ } while (0)
+#endif
+
#define done_add(val) \
do { \
unsigned int _val = val; \
@@ -771,10 +818,7 @@ static const uint8_t jump_table[] =
.wide = sizeof (CHAR_T) != 1, \
.is_binary128 = 0}; \
\
- if (is_long_double) \
- the_arg.pa_long_double = va_arg (ap, long double); \
- else \
- the_arg.pa_double = va_arg (ap, double); \
+ PARSE_FLOAT_VA_ARG_EXTENDED (info); \
ptr = (const void *) &the_arg; \
\
function_done = __printf_fp (s, &info, &ptr); \
@@ -787,8 +831,7 @@ static const uint8_t jump_table[] =
fspec->data_arg_type = PA_DOUBLE; \
fspec->info.is_long_double = 0; \
} \
- /* Not supported by *printf functions. */ \
- fspec->info.is_binary128 = 0; \
+ SETUP_FLOAT128_INFO (fspec->info); \
\
function_done = __printf_fp (s, &fspec->info, &ptr); \
} \
@@ -831,10 +874,7 @@ static const uint8_t jump_table[] =
.wide = sizeof (CHAR_T) != 1, \
.is_binary128 = 0}; \
\
- if (is_long_double) \
- the_arg.pa_long_double = va_arg (ap, long double); \
- else \
- the_arg.pa_double = va_arg (ap, double); \
+ PARSE_FLOAT_VA_ARG_EXTENDED (info); \
ptr = (const void *) &the_arg; \
\
function_done = __printf_fphex (s, &info, &ptr); \
@@ -844,8 +884,7 @@ static const uint8_t jump_table[] =
ptr = (const void *) &args_value[fspec->data_arg]; \
if (__glibc_unlikely ((mode_flags & PRINTF_LDBL_IS_DBL) != 0)) \
fspec->info.is_long_double = 0; \
- /* Not supported by *printf functions. */ \
- fspec->info.is_binary128 = 0; \
+ SETUP_FLOAT128_INFO (fspec->info); \
\
function_done = __printf_fphex (s, &fspec->info, &ptr); \
} \
@@ -1869,6 +1908,10 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
args_value[cnt].pa_double = va_arg (*ap_savep, double);
args_type[cnt] &= ~PA_FLAG_LONG_DOUBLE;
}
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ else if ((mode_flags & PRINTF_LDBL_USES_FLOAT128) != 0)
+ args_value[cnt].pa_float128 = va_arg (*ap_savep, _Float128);
+#endif
else
args_value[cnt].pa_long_double = va_arg (*ap_savep, long double);
break;
@@ -1887,7 +1930,12 @@ printf_positional (FILE *s, const CHAR_T *format, int readonly_format,
(args_value[cnt].pa_user, ap_savep);
}
else
- args_value[cnt].pa_long_double = 0.0;
+ {
+ args_value[cnt].pa_long_double = 0.0;
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ args_value[cnt].pa_float128 = 0;
+#endif
+ }
break;
case -1:
/* Error case. Not all parameters appear in N$ format
--
2.14.5
Gabriel F. T. Gomes
2018-06-21 02:10:11 UTC
Permalink
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.

When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type. Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal when appropriate. The result gets saved
into a variable of _Float128 type.

* libio/libioP.h (SCANF_LDBL_USES_FLOAT128): New macro to be
used as a mask for the mode argument of __vfscanf_internal and
__vfwscanf_internal.
* stdio-common/vfscanf-internal.c
[defined COMPILE_WSCANF && __HAVE_FLOAT128_UNLIKE_LDBL]
(__strtof128_internal): Define to __wcstof128_internal.
(LDBL_USES_FLOAT128): New macro.
[__HAVE_FLOAT128_UNLIKE_LDBL] (__vfscanf_internal): Call
__strtof128_internal when the format of long double is the same
as _Float128.
---
libio/libioP.h | 5 +++--
stdio-common/vfscanf-internal.c | 14 ++++++++++++++
2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/libio/libioP.h b/libio/libioP.h
index fba4b52460..6858d8ee88 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -731,8 +731,9 @@ extern off64_t _IO_seekpos_unlocked (FILE *, off64_t, int)
#endif /* _G_HAVE_MMAP */

/* Flags for __vfscanf_internal and __vfwscanf_internal. */
-#define SCANF_LDBL_IS_DBL 0x0001
-#define SCANF_ISOC99_A 0x0002
+#define SCANF_LDBL_IS_DBL 0x0001
+#define SCANF_ISOC99_A 0x0002
+#define SCANF_LDBL_USES_FLOAT128 0x0004

extern int __vfscanf_internal (FILE *fp, const char *format, va_list argp,
unsigned int flags);
diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
index 0eb6b5e655..d333def905 100644
--- a/stdio-common/vfscanf-internal.c
+++ b/stdio-common/vfscanf-internal.c
@@ -97,6 +97,9 @@
# define __strtold_internal __wcstold_internal
# define __strtod_internal __wcstod_internal
# define __strtof_internal __wcstof_internal
+# if __HAVE_FLOAT128_UNLIKE_LDBL
+# define __strtof128_internal __wcstof128_internal
+# endif

# define L_(Str) L##Str
# define CHAR_T wchar_t
@@ -332,6 +335,7 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
scratch_buffer_init (&charbuf.scratch);

#define LDBL_DISTINCT (__glibc_likely ((mode_flags & SCANF_LDBL_IS_DBL) == 0))
+#define LDBL_USES_FLOAT128 ((mode_flags & SCANF_LDBL_USES_FLOAT128) != 0)
#define USE_ISOC99_A (__glibc_likely (mode_flags & SCANF_ISOC99_A))

#ifdef __va_copy
@@ -2422,6 +2426,16 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
done = EOF;
goto errout;
}
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ if ((flags & LONGDBL) && LDBL_USES_FLOAT128)
+ {
+ _Float128 d = __strtof128_internal
+ (char_buffer_start (&charbuf), &tw, flags & GROUP);
+ if (!(flags & SUPPRESS) && tw != char_buffer_start (&charbuf))
+ *ARG (_Float128 *) = d;
+ }
+ else
+#endif
if ((flags & LONGDBL) && LDBL_DISTINCT)
{
long double d = __strtold_internal
--
2.14.4
Joseph Myers
2018-06-21 21:35:28 UTC
Permalink
Post by Gabriel F. T. Gomes
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.
When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type. Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal when appropriate. The result gets saved
into a variable of _Float128 type.
This patch is OK once Zack's patches are reviewed and checked in.
--
Joseph S. Myers
***@codesourcery.com
Zack Weinberg
2018-06-21 21:39:31 UTC
Permalink
Post by Joseph Myers
Post by Gabriel F. T. Gomes
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.
When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type. Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal when appropriate. The result gets saved
into a variable of _Float128 type.
This patch is OK once Zack's patches are reviewed and checked in.
FYI, it now looks like I will _not_ have time to revise and resubmit
that patchset before the freeze. Sorry, dayjob is extremely demanding
right now. Don't expect to hear much from me until, like, October.

zw
Gabriel F. T. Gomes
2018-12-07 20:09:11 UTC
Permalink
Post by Joseph Myers
Post by Gabriel F. T. Gomes
On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.
When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type. Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal when appropriate. The result gets saved
into a variable of _Float128 type.
This patch is OK once Zack's patches are reviewed and checked in.
I have now committed this patch, adapted for current master, and
with the descriptive comment for the SCANF_LDBL_USES_FLOAT128 macro.


From 10446f5d9f2cf4d91c8ae483fd2b5470242ae2a1 Mon Sep 17 00:00:00 2001
From: "Gabriel F. T. Gomes" <***@inconstante.eti.br>
Date: Sun, 10 Jun 2018 22:42:34 -0300
Subject: [PATCH] Prepare vfscanf to use __strtof128_internal

On powerpc64le, long double can currently take two formats: the same as
double (-mlong-double-64) or IBM Extended Precision (default with
-mlong-double-128 or explicitly with -mabi=ibmlongdouble). The internal
implementation of scanf-like functions is aware of these possibilites
and, based on the format in use, properly calls __strtold_internal or
__strtod_internal, saving the return to a variable of type double or
long double.

When library support for TS 18661-3 was added to glibc, a new function,
__strtof128_internal, was added to enable reading of floating-point
values with IEEE binary128 format into the _Float128 type. Now that
powerpc64le is getting support for its third long double format, and
taking into account that this format is the same as the format of
_Float128, this patch extends __vfscanf_internal and __vfwscanf_internal
to call __strtof128_internal or __wcstof128_internal when appropriate.
The result gets saved into a variable of _Float128 type.

Tested for powerpc64le.
---
ChangeLog | 12 ++++++++++++
libio/libioP.h | 18 +++++++++++++++---
stdio-common/vfscanf-internal.c | 14 ++++++++++++++
3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 998f4c153f..c6ad912b11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2018-12-07 Gabriel F. T. Gomes <***@inconstante.eti.br>
+
+ * libio/libioP.h (SCANF_LDBL_USES_FLOAT128): New macro to be
+ used as a mask for the mode argument of __vfscanf_internal and
+ __vfwscanf_internal.
+ * stdio-common/vfscanf-internal.c
+ [defined COMPILE_WSCANF && __HAVE_FLOAT128_UNLIKE_LDBL]
+ (__strtof128_internal): Define to __wcstof128_internal.
+ [__HAVE_FLOAT128_UNLIKE_LDBL] (__vfscanf_internal): Call
+ __strtof128_internal or __wcstof128_internal when the format of
+ long double is the same as _Float128.
+
2018-12-05 Samuel Thibault <***@ens-lyon.org>

* include/unistd.h (__confstr): Add prototype and hidden prototype.
diff --git a/libio/libioP.h b/libio/libioP.h
index ce5228e382..958ef9bffe 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -759,9 +759,21 @@ extern off64_t _IO_seekpos_unlocked (FILE *, off64_t, int)
allocation for input strings with %as, %aS and %a[, a GNU extension,
is disabled. This is the behavior that the __isoc99_scanf family of
functions use. When the flag is set to zero, automatic allocation is
- enabled. */
-#define SCANF_LDBL_IS_DBL 0x0001
-#define SCANF_ISOC99_A 0x0002
+ enabled.
+
+ SCANF_LDBL_USES_FLOAT128 is used on platforms where the long double
+ format used to be different from the IEC 60559 double format *and*
+ also different from the Quadruple 128-bits IEC 60559 format (such as
+ the IBM Extended Precision format on powerpc or the 80-bits IEC 60559
+ format on x86), but was later converted to the Quadruple 128-bits IEC
+ 60559 format, which is the same format that the _Float128 always has
+ (hence the `USES_FLOAT128' suffix in the name of the flag). When set
+ to one, this macros indicates that long double values are to be
+ handled as having this new format. Otherwise, they should be handled
+ as the previous format on that platform. */
+#define SCANF_LDBL_IS_DBL 0x0001
+#define SCANF_ISOC99_A 0x0002
+#define SCANF_LDBL_USES_FLOAT128 0x0004

extern int __vfscanf_internal (FILE *fp, const char *format, va_list argp,
unsigned int flags)
diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c
index 19cfef0906..5d002078d8 100644
--- a/stdio-common/vfscanf-internal.c
+++ b/stdio-common/vfscanf-internal.c
@@ -98,6 +98,9 @@
# define __strtold_internal __wcstold_internal
# define __strtod_internal __wcstod_internal
# define __strtof_internal __wcstof_internal
+# if __HAVE_FLOAT128_UNLIKE_LDBL
+# define __strtof128_internal __wcstof128_internal
+# endif

# define L_(Str) L##Str
# define CHAR_T wchar_t
@@ -2420,6 +2423,17 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr,
done = EOF;
goto errout;
}
+#if __HAVE_FLOAT128_UNLIKE_LDBL
+ if ((flags & LONGDBL) \
+ && (mode_flags & SCANF_LDBL_USES_FLOAT128) != 0)
+ {
+ _Float128 d = __strtof128_internal
+ (char_buffer_start (&charbuf), &tw, flags & GROUP);
+ if (!(flags & SUPPRESS) && tw != char_buffer_start (&charbuf))
+ *ARG (_Float128 *) = d;
+ }
+ else
+#endif
if ((flags & LONGDBL) \
&& __glibc_likely ((mode_flags & SCANF_LDBL_IS_DBL) == 0))
{
--
2.14.5
Gabriel F. T. Gomes
2018-06-21 02:10:12 UTC
Permalink
Since the introduction of explicit flags in the internal implementation
of the printf family of functions, the 'mode' parameter can be used to
select which format long double parameters have (with the mode flag:
PRINTF_LDBL_IS_DBL). This patch uses this feature in the implementation
of some functions in argp.h, err.h, and error.h (only those that take a
format string and positional parameters). Future patches will add
support for 'nldbl' and 'ieee128' versions of these functions.

Tested for powerpc64le.

* argp/argp-help.c (__argp_error_internal): New function,
renamed from __argp_error, but that takes a 'mode_flags'
parameter to control the format of long double parameters.
(__argp_error): Converted into a call __argp_error_internal.
(__argp_failure_internal): New function, renamed from
__argp_failure, but that takes a 'mode_flags' parameter.
(__argp_failure): Converted into a call __argp_failure_internal.
* misc/err.c: [defined _LIBC] Include libioP.h for the
definitions of __vfprintf_internal and __vfwprintf_internal.
(convert_and_print): Add 'mode_flags' parameter. Call
__vfwprintf_internal, instead of __vfwprintf.
(__vwarnx_internal): New function, renamed from vwarnx, but that
takes a 'mode_flags' parameter.
(vwarnx): Converted into a call to __vwarnx_internal.
(__vwarn_internal): New function, renamed from vwarn, but that
takes a 'mode_flags' parameter.
(vwarn): Converted into a call to __vwarn_internal.
* misc/error.c: Include libioP.h for the definitions of
__vfprintf_internal and __vfwprintf_internal.
(error_tail): Add 'mode_flags' parameter. Call
__vfprintf_internal and __vfwprintf_internal.
(__error_internal): New function, renamed from error, but that
takes a 'mode_flags' parameter.
(error): Converted into a call to __error_internal.
(__error_at_line_internal): New function, renamed from
error_at_line, but that takes a 'mode_flags' parameter.
(error_at_line): Converted into a call to
__error_at_line_internal.
---
argp/argp-help.c | 44 ++++++++++++++++++++++++++------------------
misc/err.c | 36 +++++++++++++++++++++++++++---------
misc/error.c | 46 ++++++++++++++++++++++++++++++++--------------
3 files changed, 85 insertions(+), 41 deletions(-)

diff --git a/argp/argp-help.c b/argp/argp-help.c
index 9f25338ca0..6113cb2412 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -1750,7 +1750,8 @@ weak_alias (__argp_state_help, argp_state_help)
by the program name and `:', to stderr, and followed by a `Try ... --help'
message, then exit (1). */
void
-__argp_error (const struct argp_state *state, const char *fmt, ...)
+__argp_error_internal (const struct argp_state *state, const char *fmt,
+ va_list ap, unsigned int mode_flags)
{
if (!state || !(state->flags & ARGP_NO_ERRS))
{
@@ -1758,18 +1759,14 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)

if (stream)
{
- va_list ap;
-
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__flockfile (stream);
#endif

- va_start (ap, fmt);
-
#ifdef _LIBC
char *buf;

- if (__vasprintf (&buf, fmt, ap) < 0)
+ if (__vasprintf_internal (&buf, fmt, ap, mode_flags) < 0)
buf = NULL;

__fxprintf (stream, "%s: %s\n",
@@ -1782,21 +1779,27 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)
putc_unlocked (':', stream);
putc_unlocked (' ', stream);

- vfprintf (stream, fmt, ap);
+ __vfprintf_internal (stream, fmt, ap, mode_flags);

putc_unlocked ('\n', stream);
#endif

__argp_state_help (state, stream, ARGP_HELP_STD_ERR);

- va_end (ap);
-
#if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
__funlockfile (stream);
#endif
}
}
}
+void
+__argp_error (const struct argp_state *state, const char *fmt, ...)
+{
+ va_list ap;
+ va_start (ap, fmt);
+ __argp_error_internal (state, fmt, ap, 0);
+ va_end (ap);
+}
#ifdef weak_alias
weak_alias (__argp_error, argp_error)
#endif
@@ -1810,8 +1813,9 @@ weak_alias (__argp_error, argp_error)
*parsing errors*, and the former is for other problems that occur during
parsing but don't reflect a (syntactic) problem with the input. */
void
-__argp_failure (const struct argp_state *state, int status, int errnum,
- const char *fmt, ...)
+__argp_failure_internal (const struct argp_state *state, int status,
+ int errnum, const char *fmt, va_list ap,
+ unsigned int mode_flags)
{
if (!state || !(state->flags & ARGP_NO_ERRS))
{
@@ -1833,13 +1837,10 @@ __argp_failure (const struct argp_state *state, int status, int errnum,

if (fmt)
{
- va_list ap;
-
- va_start (ap, fmt);
#ifdef _LIBC
char *buf;

- if (__vasprintf (&buf, fmt, ap) < 0)
+ if (__vasprintf_internal (&buf, fmt, ap, mode_flags) < 0)
buf = NULL;

__fxprintf (stream, ": %s", buf);
@@ -1849,10 +1850,8 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
putc_unlocked (':', stream);
putc_unlocked (' ', stream);

- vfprintf (stream, fmt, ap);
+ __vfprintf_internal (stream, fmt, ap, mode_flags);
#endif
-
- va_end (ap);
}

if (errnum)
@@ -1887,6 +1886,15 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
}
}
}
+void
+__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, 0);
+ va_end (ap);
+}
#ifdef weak_alias
weak_alias (__argp_failure, argp_failure)
#endif
diff --git a/misc/err.c b/misc/err.c
index 2b836e8358..e46bda3021 100644
--- a/misc/err.c
+++ b/misc/err.c
@@ -27,6 +27,10 @@
#define flockfile(s) _IO_flockfile (s)
#define funlockfile(s) _IO_funlockfile (s)

+#ifdef _LIBC
+# include <../libio/libioP.h>
+#endif
+
extern char *__progname;

#define VA(call) \
@@ -38,7 +42,8 @@ extern char *__progname;
}

static void
-convert_and_print (const char *format, __gnuc_va_list ap)
+convert_and_print (const char *format, __gnuc_va_list ap,
+ unsigned int mode_flags)
{
#define ALLOCA_LIMIT 2000
size_t len;
@@ -79,32 +84,33 @@ convert_and_print (const char *format, __gnuc_va_list ap)
/* The string cannot be converted. */
wformat = (wchar_t *) L"???";

- __vfwprintf (stderr, wformat, ap);
+ __vfwprintf_internal (stderr, wformat, ap, mode_flags);
}

void
-vwarnx (const char *format, __gnuc_va_list ap)
+__vwarnx_internal (const char *format, __gnuc_va_list ap,
+ unsigned int mode_flags)
{
flockfile (stderr);
if (_IO_fwide (stderr, 0) > 0)
{
__fwprintf (stderr, L"%s: ", __progname);
- convert_and_print (format, ap);
+ convert_and_print (format, ap, mode_flags);
putwc_unlocked (L'\n', stderr);
}
else
{
fprintf (stderr, "%s: ", __progname);
if (format)
- vfprintf (stderr, format, ap);
+ __vfprintf_internal (stderr, format, ap, mode_flags);
putc_unlocked ('\n', stderr);
}
funlockfile (stderr);
}
-libc_hidden_def (vwarnx)

void
-vwarn (const char *format, __gnuc_va_list ap)
+__vwarn_internal (const char *format, __gnuc_va_list ap,
+ unsigned int mode_flags)
{
int error = errno;

@@ -114,7 +120,7 @@ vwarn (const char *format, __gnuc_va_list ap)
__fwprintf (stderr, L"%s: ", __progname);
if (format)
{
- convert_and_print (format, ap);
+ convert_and_print (format, ap, mode_flags);
fputws_unlocked (L": ", stderr);
}
__set_errno (error);
@@ -125,7 +131,7 @@ vwarn (const char *format, __gnuc_va_list ap)
fprintf (stderr, "%s: ", __progname);
if (format)
{
- vfprintf (stderr, format, ap);
+ __vfprintf_internal (stderr, format, ap, mode_flags);
fputs_unlocked (": ", stderr);
}
__set_errno (error);
@@ -133,8 +139,20 @@ vwarn (const char *format, __gnuc_va_list ap)
}
funlockfile (stderr);
}
+
+void
+vwarn (const char *format, __gnuc_va_list ap)
+{
+ __vwarn_internal (format, ap, 0);
+}
libc_hidden_def (vwarn)

+void
+vwarnx (const char *format, __gnuc_va_list ap)
+{
+ __vwarnx_internal (format, ap, 0);
+}
+libc_hidden_def (vwarnx)

void
warn (const char *format, ...)
diff --git a/misc/error.c b/misc/error.c
index b4e8b6c938..9f8067eb9b 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -39,6 +39,7 @@
# include <stdbool.h>
# include <stdint.h>
# include <wchar.h>
+# include <../libio/libioP.h>
# define mbsrtowcs __mbsrtowcs
# define USE_UNLOCKED_IO 0
# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
@@ -200,7 +201,8 @@ print_errno_message (int errnum)
}

static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))
-error_tail (int status, int errnum, const char *message, va_list args)
+error_tail (int status, int errnum, const char *message, va_list args,
+ unsigned int mode_flags)
{
#if _LIBC
if (_IO_fwide (stderr, 0) > 0)
@@ -261,14 +263,14 @@ error_tail (int status, int errnum, const char *message, va_list args)
wmessage = (wchar_t *) L"???";
}

- __vfwprintf (stderr, wmessage, args);
+ __vfwprintf_internal (stderr, wmessage, args, mode_flags);

if (use_malloc)
free (wmessage);
}
else
#endif
- vfprintf (stderr, message, args);
+ __vfprintf_internal (stderr, message, args, mode_flags);
va_end (args);

++error_message_count;
@@ -290,10 +292,9 @@ error_tail (int status, int errnum, const char *message, va_list args)
If ERRNUM is nonzero, print its corresponding system error message.
Exit with status STATUS if it is nonzero. */
void
-error (int status, int errnum, const char *message, ...)
+__error_internal (int status, int errnum, const char *message,
+ va_list args, unsigned int mode_flags)
{
- va_list args;
-
#if defined _LIBC && defined __libc_ptf_call
/* We do not want this call to be cut short by a thread
cancellation. Therefore disable cancellation for now. */
@@ -317,8 +318,7 @@ error (int status, int errnum, const char *message, ...)
#endif
}

- va_start (args, message);
- error_tail (status, errnum, message, args);
+ error_tail (status, errnum, message, args, mode_flags);

#ifdef _LIBC
_IO_funlockfile (stderr);
@@ -327,17 +327,25 @@ error (int status, int errnum, const char *message, ...)
# endif
#endif
}
+
+void
+error (int status, int errnum, const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ __error_internal (status, errnum, message, ap, 0);
+ va_end (ap);
+}

/* Sometimes we want to have at most one error per line. This
variable controls whether this mode is selected or not. */
int error_one_per_line;

void
-error_at_line (int status, int errnum, const char *file_name,
- unsigned int line_number, const char *message, ...)
+__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)
{
- va_list args;
-
if (error_one_per_line)
{
static const char *old_file_name;
@@ -388,8 +396,7 @@ error_at_line (int status, int errnum, const char *file_name,
file_name, line_number);
#endif

- va_start (args, message);
- error_tail (status, errnum, message, args);
+ error_tail (status, errnum, message, args, mode_flags);

#ifdef _LIBC
_IO_funlockfile (stderr);
@@ -399,6 +406,17 @@ error_at_line (int status, int errnum, const char *file_name,
#endif
}

+void
+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, 0);
+ va_end (ap);
+}
+
#ifdef _LIBC
/* Make the weak alias. */
# undef error
--
2.14.4
Joseph Myers
2018-06-21 21:36:39 UTC
Permalink
Post by Gabriel F. T. Gomes
Since the introduction of explicit flags in the internal implementation
of the printf family of functions, the 'mode' parameter can be used to
PRINTF_LDBL_IS_DBL). This patch uses this feature in the implementation
of some functions in argp.h, err.h, and error.h (only those that take a
format string and positional parameters). Future patches will add
support for 'nldbl' and 'ieee128' versions of these functions.
It's probably best to work with Paul on review of this patch, in case
there are any issues where doing things one way rather than another is
helpful to keeping the glibc and gnulib sources of the argp and error
interfaces in sync as much as possible.
--
Joseph S. Myers
***@codesourcery.com
Gabriel F. T. Gomes
2018-06-21 02:10:13 UTC
Permalink
The 'mode' argument to __vfprintf_internal allows the selection of the
long double format for all long double arguments requested by the format
string. Currently, there are two possibilities: long double with the
same format as double or long double as something else. The 'something
else' format varies between architectures, and on powerpc64le, it means
IBM Extended Precision format.

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

Tested for powerpc64le.

* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
[subdir == stdio-common] (routines): Add ieee128-asprintf,
ieee128-dprintf, ieee128-fprintf, ieee128-printf,
ieee128-snprintf, ieee128-sprintf, ieee128-vasprintf,
ieee128-vdprintf, ieee128-vfprintf, ieee128-vprintf,
ieee128-vsnprintf, and ieee128-vsprintf.
[subdir == stdio-common] (CFLAGS-vfprintf-internal.c): New
variable. Add -mfloat128 to the compilation of
vfprintf-internal.c, so that it gets support for the use of
__printf_fp and __printf_fphex with __float128 parameter.
[subdir == stdio-common] (tests-internal): Add
test-printf-ieee128 and test-printf-ibm128.
[subdir == stdio-common] (CFLAGS-test-printf-ieee128.c): New
variable to add the relevant -mabi flags to the compilation.
[subdir == stdio-common] (CFLAGS-test-printf-ibm128.c): Likewise.
[subdir == stdio-common && run-built-tests == yes]
(tests-special): Add $(objpfx)test-printf-ieee128.out and
$(objpfx)test-printf-ibm128.out.
[subdir == stdio-common] ($(objpfx)test-printf-ieee128.out):
New build and test rule.
[subdir == stdio-common] ($(objpfx)test-printf-ibm128.out):
Likewise.

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

* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh:
Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 46 +++++++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 17 +++
.../ieee754/ldbl-128ibm-compat/ieee128-asprintf.c | 35 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-dprintf.c | 34 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-fprintf.c | 34 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-printf.c | 35 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-snprintf.c | 35 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-sprintf.c | 35 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c | 27 +++++
.../ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c | 26 ++++
.../ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c | 26 ++++
.../ieee754/ldbl-128ibm-compat/ieee128-vprintf.c | 27 +++++
.../ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c | 28 +++++
.../ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c | 27 +++++
.../ldbl-128ibm-compat/test-printf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-printf-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-printf-ldbl-compat.c | 134 +++++++++++++++++++++
.../ldbl-128ibm-compat/test-printf-ldbl-compat.sh | 64 ++++++++++
.../powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h | 8 ++
19 files changed, 640 insertions(+)
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makefile
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
new file mode 100644
index 0000000000..7cc05b85ab
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -0,0 +1,46 @@
+ifeq ($(subdir),stdio-common)
+# Wrappers for *printf functions that take long double arguments with
+# IEEE binary128 format
+routines += ieee128-asprintf
+routines += ieee128-dprintf
+routines += ieee128-fprintf
+routines += ieee128-printf
+routines += ieee128-snprintf
+routines += ieee128-sprintf
+
+routines += ieee128-vasprintf
+routines += ieee128-vdprintf
+routines += ieee128-vfprintf
+routines += ieee128-vprintf
+routines += ieee128-vsnprintf
+routines += ieee128-vsprintf
+
+# Printing long double values with IEEE binary128 format reuses part
+# of the internal float128 implementation (__printf_fp, __printf_fphex,
+# and __float128 variables and union members). Thus, the compilation of
+# the following functions, must have -mfloat128 passed to the compiler.
+CFLAGS-vfprintf-internal.c += -mfloat128
+
+# Basic tests for the implementation of long double with IEEE binary128
+# format and for the related redirections in installed headers.
+tests-internal += test-printf-ieee128 test-printf-ibm128
+CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)test-printf-ieee128.out
+tests-special += $(objpfx)test-printf-ibm128.out
+endif
+
+$(objpfx)test-printf-ieee128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh \
+ $(objpfx)test-printf-ieee128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-printf-ibm128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh \
+ $(objpfx)test-printf-ibm128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 322041132e..c55c2c1b4a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -111,3 +111,20 @@ libm {
__ynieee128;
}
}
+libc {
+ LDBL_IBM128_VERSION {
+ __asprintfieee128;
+ __dprintfieee128;
+ __fprintfieee128;
+ __printfieee128;
+ __snprintfieee128;
+ __sprintfieee128;
+
+ __vasprintfieee128;
+ __vdprintfieee128;
+ __vfprintfieee128;
+ __vprintfieee128;
+ __vsnprintfieee128;
+ __vsprintfieee128;
+ }
+}
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
new file mode 100644
index 0000000000..543b646c3e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for asprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_asprintf (char **string_ptr, const char *format, ...)
+{
+ va_list ap;
+ int done;
+
+ va_start (ap, format);
+ done = __vasprintf_internal (string_ptr, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+ va_end (ap);
+
+ return done;
+}
+strong_alias (___ieee128_asprintf, __asprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
new file mode 100644
index 0000000000..2c7ea41b92
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
@@ -0,0 +1,34 @@
+/* Wrapper for dprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_dprintf (int d, const char *format, ...)
+{
+ va_list ap;
+ int done;
+
+ va_start (ap, format);
+ done = __vdprintf_internal (d, format, ap, PRINTF_LDBL_USES_FLOAT128);
+ va_end (ap);
+
+ return done;
+}
+strong_alias (___ieee128_dprintf, __dprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
new file mode 100644
index 0000000000..e4b9bc66a5
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
@@ -0,0 +1,34 @@
+/* Wrapper for fprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_fprintf (FILE *fp, const char *format, ...)
+{
+ va_list ap;
+ int done;
+
+ va_start (ap, format);
+ done = __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128);
+ va_end (ap);
+
+ return done;
+}
+strong_alias (___ieee128_fprintf, __fprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
new file mode 100644
index 0000000000..acf7479d2c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
@@ -0,0 +1,35 @@
+/* Wrapper for printf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_printf (const char *format, ...)
+{
+ va_list ap;
+ int done;
+
+ va_start (ap, format);
+ done = __vfprintf_internal (stdout, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+ va_end (ap);
+
+ return done;
+}
+strong_alias (___ieee128_printf, __printfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
new file mode 100644
index 0000000000..f1b4bb8111
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for snprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_snprintf (char *s, size_t maxlen, const char *format, ...)
+{
+ va_list ap;
+ int done;
+
+ va_start (ap, format);
+ done = __vsnprintf_internal (s, maxlen, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+ va_end (ap);
+
+ return done;
+}
+strong_alias (___ieee128_snprintf, __snprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
new file mode 100644
index 0000000000..d0790f0a11
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for sprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <libio/libioP.h>
+
+extern int
+___ieee128_sprintf (char *s, const char *format, ...)
+{
+ va_list ap;
+ int done;
+
+ va_start (ap, format);
+ done = __vsprintf_internal (s, -1, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+ va_end (ap);
+
+ return done;
+}
+strong_alias (___ieee128_sprintf, __sprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
new file mode 100644
index 0000000000..ae9714790e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vasprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vasprintf (char **result_ptr, const char *format, va_list ap)
+{
+ return __vasprintf_internal (result_ptr, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vasprintf, __vasprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
new file mode 100644
index 0000000000..d02b56299f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vdprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vdprintf (int d, const char *format, va_list ap)
+{
+ return __vdprintf_internal (d, format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vdprintf, __vdprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
new file mode 100644
index 0000000000..8f5e268516
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
@@ -0,0 +1,26 @@
+/* Wrapper for vfprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vfprintf (FILE *fp, const char *format, va_list ap)
+{
+ return __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vfprintf, __vfprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
new file mode 100644
index 0000000000..40ffe87ae2
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vprintf (const char *format, va_list ap)
+{
+ return __vfprintf_internal (stdout, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vprintf, __vprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
new file mode 100644
index 0000000000..f597df429d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
@@ -0,0 +1,28 @@
+/* Wrapper for vsnprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsnprintf (char *string, size_t maxlen, const char *format,
+ va_list ap)
+{
+ return __vsnprintf_internal (string, maxlen, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsnprintf, __vsnprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
new file mode 100644
index 0000000000..29d6e24c2f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vsprintf. IEEE128 version.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <libio/libioP.h>
+
+extern int
+___ieee128_vsprintf (char *string, const char *format, va_list ap)
+{
+ return __vsprintf_internal (string, -1, format, ap,
+ PRINTF_LDBL_USES_FLOAT128);
+}
+strong_alias (___ieee128_vsprintf, __vsprintfieee128)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
new file mode 100644
index 0000000000..5de4ea3e7f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
@@ -0,0 +1 @@
+#include <test-printf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
new file mode 100644
index 0000000000..5de4ea3e7f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
@@ -0,0 +1 @@
+#include <test-printf-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
new file mode 100644
index 0000000000..936e85f8d6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -0,0 +1,134 @@
+/* Test for the long double variants of *printf functions.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+
+#include <support/check.h>
+
+static void
+do_test_call_varg (FILE *stream, const char *format, ...)
+{
+ char *buffer = NULL;
+ char string[128];
+ va_list args;
+
+ printf ("%20s", "vasprintf: ");
+ va_start (args, format);
+ vasprintf (&buffer, format, args);
+ va_end (args);
+ if (buffer == NULL)
+ printf ("Error using vasprintf\n");
+ else
+ {
+ printf ("%s", buffer);
+ free (buffer);
+ }
+ printf ("\n");
+
+ printf ("%20s", "vdprintf: ");
+ va_start (args, format);
+ vdprintf (1, format, args);
+ va_end (args);
+ printf ("\n");
+
+ printf ("%20s", "vfprintf: ");
+ va_start (args, format);
+ vfprintf (stream, format, args);
+ va_end (args);
+ printf ("\n");
+
+ printf ("%20s", "vprintf: ");
+ va_start (args, format);
+ vprintf (format, args);
+ va_end (args);
+ printf ("\n");
+
+ printf ("%20s", "vsnprintf: ");
+ va_start (args, format);
+ vsnprintf (string, 127, format, args);
+ va_end (args);
+ printf ("%s", string);
+ printf ("\n");
+
+ printf ("%20s", "vsprintf: ");
+ va_start (args, format);
+ vsprintf (string, format, args);
+ va_end (args);
+ printf ("%s", string);
+ printf ("\n");
+}
+
+static void
+do_test_call_rarg (FILE *stream, const char *format, long double ld)
+{
+ char *buffer = NULL;
+ char string[128];
+
+ printf ("%20s", "asprintf: ");
+ asprintf (&buffer, format, ld);
+ if (buffer == NULL)
+ printf ("Error using asprintf\n");
+ else
+ {
+ printf ("%s", buffer);
+ free (buffer);
+ }
+ printf ("\n");
+
+ printf ("%20s", "dprintf: ");
+ dprintf (1, format, ld);
+ printf ("\n");
+
+ printf ("%20s", "fprintf: ");
+ fprintf (stdout, format, ld);
+ printf ("\n");
+
+ printf ("%20s", "printf: ");
+ printf (format, ld);
+ printf ("\n");
+
+ printf ("%20s", "snprintf: ");
+ snprintf (string, 127, format, ld);
+ printf ("%s", string);
+ printf ("\n");
+
+ printf ("%20s", "sprintf: ");
+ sprintf (string, format, ld);
+ printf ("%s", string);
+ printf ("\n");
+}
+
+static int
+do_test (void)
+{
+ long double ld = -1;
+
+ /* Print in decimal notation. */
+ do_test_call_rarg (stdout, "%.60Lf", ld);
+ do_test_call_varg (stdout, "%.60Lf", ld);
+
+ /* Print in hexadecimal notation. */
+ do_test_call_rarg (stdout, "%.60La", ld);
+ do_test_call_varg (stdout, "%.60La", ld);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
new file mode 100644
index 0000000000..62bc5d03a6
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+# Testing of *printf. IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+ ${test_program} \
+ > ${test_program_output} || status=1
+
+cat <<'EOF' |
+ asprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ dprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ fprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ printf: -1.000000000000000000000000000000000000000000000000000000000000
+ snprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ sprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vasprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vdprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vfprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vsnprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vsprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ asprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ dprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ fprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ printf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ snprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ sprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vasprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vdprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vfprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vsnprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vsprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
new file mode 100644
index 0000000000..6eb0e72b07
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
@@ -0,0 +1,8 @@
+/* ABI version for long double switch to IEEE 128-bit floating point..
+ This is used by the Versions and math_ldbl_opt.h files in
+ sysdeps/ieee754/ldbl-128ibm-compat/. It gives the ABI version where
+ long double == ibm128 was replaced with long double == _Float128
+ for libm *l functions and libc functions using long double. */
+
+#define LDBL_IBM128_VERSION GLIBC_2.28
+#define LDBL_IBM128_COMPAT_VERSION GLIBC_2_28
--
2.14.4
Joseph Myers
2018-06-21 21:03:36 UTC
Permalink
I noted in my review of a previous version of the printf changes that
there should be a test involving positional arguments (%n$La, etc., where
n is the position of the long double argument in that case) - because of
the significantly different code paths involved in processing formats
using such arguments. I don't see any tests with positional arguments in
this patch series.
--
Joseph S. Myers
***@codesourcery.com
Gabriel F. T. Gomes
2018-06-21 02:10:14 UTC
Permalink
Similarly to what was done for regular character printing functions,
this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, in the
'mode' argument of the wide characters printing function,
__vfwprintf_internal (which is also extended to support printing
floating-point values with IEEE binary128, by saving floating-point
values into variables of type __float128 and adjusting the parameters to
__printf_fp and __printf_fphex as if it was a call from a wide-character
version of strfromf128 (even though such version does not exist)).

Tested for powerpc64le.

* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
[subdir == stdio-common] (routines): Add ieee128-fwprintf,
ieee128-swprintf, ieee128-wprintf, ieee128-vfwprintf,
ieee128-vswprintf, and ieee128-vwprintf.
[subdir == stdio-common] (CFLAGS-vfwprintf-internal.c): New
variable. Add -mfloat128 to the compilation of
vfprintf-internal.c, so that it gets support for the use of
__printf_fp and __printf_fphex with __float128 parameter.
[subdir == stdio-common] (tests-internal): Add
test-wprintf-ieee128 and test-wprintf-ibm128.
[subdir == stdio-common] (CFLAGS-test-wprintf-ieee128.c): New
variable to add the relevant -mabi flags to the compilation.
[subdir == stdio-common] (CFLAGS-test-wprintf-ibm128.c): Likewise.
[subdir == stdio-common && run-built-tests == yes]
(tests-special): Add $(objpfx)test-wprintf-ieee128.out and
$(objpfx)test-wprintf-ibm128.out.
[subdir == stdio-common] ($(objpfx)test-wprintf-ieee128.out):
New build and test rule.
[subdir == stdio-common] ($(objpfx)test-wprintf-ibm128.out):
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__fwprintfieee128, __swprintfieee128, __wprintfieee128,
__vfwprintfieee128, __vswprintfieee128, and __vwprintfieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 28 +++++++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++
.../ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c | 35 +++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-swprintf.c | 36 +++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c | 27 +++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c | 28 +++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c | 27 +++++++
.../ieee754/ldbl-128ibm-compat/ieee128-wprintf.c | 35 +++++++++
.../ldbl-128ibm-compat/test-wprintf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-wprintf-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c | 87 ++++++++++++++++++++++
.../ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh | 52 +++++++++++++
12 files changed, 365 insertions(+)
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
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 7cc05b85ab..e07074356b 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -15,11 +15,20 @@ routines += ieee128-vprintf
routines += ieee128-vsnprintf
routines += ieee128-vsprintf

+routines += ieee128-fwprintf
+routines += ieee128-swprintf
+routines += ieee128-wprintf
+
+routines += ieee128-vfwprintf
+routines += ieee128-vswprintf
+routines += ieee128-vwprintf
+
# Printing long double values with IEEE binary128 format reuses part
# of the internal float128 implementation (__printf_fp, __printf_fphex,
# and __float128 variables and union members). Thus, the compilation of
# the following functions, must have -mfloat128 passed to the compiler.
CFLAGS-vfprintf-internal.c += -mfloat128
+CFLAGS-vfwprintf-internal.c += -mfloat128

# Basic tests for the implementation of long double with IEEE binary128
# format and for the related redirections in installed headers.
@@ -27,9 +36,16 @@ 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
+
ifeq ($(run-built-tests),yes)
tests-special += $(objpfx)test-printf-ieee128.out
tests-special += $(objpfx)test-printf-ibm128.out
+
+tests-special += $(objpfx)test-wprintf-ieee128.out
+tests-special += $(objpfx)test-wprintf-ibm128.out
endif

$(objpfx)test-printf-ieee128.out: \
@@ -43,4 +59,16 @@ $(objpfx)test-printf-ibm128.out: \
$(objpfx)test-printf-ibm128
$(SHELL) $^ '$(test-program-prefix)' $@; \
$(evaluate-test)
+
+$(objpfx)test-wprintf-ieee128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh \
+ $(objpfx)test-wprintf-ieee128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-wprintf-ibm128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh \
+ $(objpfx)test-wprintf-ibm128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index c55c2c1b4a..4c3f8622b1 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -126,5 +126,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..dd156c6b4f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for fwprintf. 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_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..d865f13313
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c
@@ -0,0 +1,36 @@
+/* Wrapper for swprintf. 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_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..6fd4f7b6fb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vfwprintf. 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_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..0524e1788f
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c
@@ -0,0 +1,28 @@
+/* Wrapper for vswprintf. 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_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..4ba26e29a1
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c
@@ -0,0 +1,27 @@
+/* Wrapper for vwprintf. 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_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..741633f8ba
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c
@@ -0,0 +1,35 @@
+/* Wrapper for wprintf. 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_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..67ddbc9194
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -0,0 +1,87 @@
+/* Test for the long double variants of *w*printf functions.
+ Copyright (C) 2018 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <wchar.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: ");
+ va_start (args, format);
+ vfwprintf (stream, format, args);
+ va_end (args);
+ wprintf (L"\n");
+
+ wprintf (L"%20Ls", L"vswprintf: ");
+ va_start (args, format);
+ vswprintf (string, 127, format, args);
+ va_end (args);
+ wprintf (L"%Ls", string);
+ wprintf (L"\n");
+
+ wprintf (L"%20Ls", 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"%20Ls", L"fwprintf: ");
+ fwprintf (stream, format, ld);
+ wprintf (L"\n");
+
+ wprintf (L"%20Ls", L"swprintf: ");
+ swprintf (string, 127, format, ld);
+ wprintf (L"%Ls", string);
+ wprintf (L"\n");
+
+ wprintf (L"%20Ls", L"wprintf: ");
+ wprintf (format, ld);
+ wprintf (L"\n");
+}
+
+static int
+do_test (void)
+{
+ long double ld = -1;
+
+ /* Print in decimal notation. */
+ do_test_call_rarg (stdout, L"%.60Lf", ld);
+ do_test_call_varg (stdout, L"%.60Lf", ld);
+
+ /* Print in hexadecimal notation. */
+ do_test_call_rarg (stdout, L"%.60La", ld);
+ do_test_call_varg (stdout, L"%.60La", ld);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
new file mode 100644
index 0000000000..029006eb5e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Testing of *w*printf. IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+ ${test_program} \
+ > ${test_program_output} || status=1
+
+cat <<'EOF' |
+ fwprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ swprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ wprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vfwprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vswprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ vwprintf: -1.000000000000000000000000000000000000000000000000000000000000
+ fwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ swprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ wprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vfwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vswprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ vwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
--
2.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:15 UTC
Permalink
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).

Tested for powerpc64le.

* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
[subdir == stdio-common] (routines): Add ieee128-asprintf_chk,
ieee128-dprintf_chk, ieee128-fprintf_chk, ieee128-printf_chk,
ieee128-snprintf_chk, ieee128-sprintf_chk, ieee128-vasprintf_chk,
ieee128-vdprintf_chk, ieee128-vfprintf_chk, ieee128-vprintf_chk,
ieee128-vsnprintf_chk, and ieee128-vsprintf_chk.
[subdir == stdio-common] (tests-internal): Add
test-printf-chk-ieee128 and test-printf-chk-ibm128.
[subdir == stdio-common] (CFLAGS-test-printf-chk-ieee128.c): New
variable to add the relevant -mabi flags to the compilation.
[subdir == stdio-common] (CFLAGS-test-printf-chk-ibm128.c): Likewise.
[subdir == stdio-common && run-built-tests == yes]
(tests-special): Add $(objpfx)test-printf-chk-ieee128.out, and
$(objpfx)test-printf-chk-ibm128.out.
[subdir == stdio-common] ($(objpfx)test-printf-chk-ieee128.out):
New build and test rule.
[subdir == stdio-common] ($(objpfx)test-printf-chk-ibm128.out):
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__asprintf_chkieee128, __dprintf_chkieee128, __fprintf_chkieee128,
__printf_chkieee128, __snprintf_chkieee128, __sprintf_chkieee128,
__vasprintf_chkieee128, __vdprintf_chkieee128, __vfprintf_chkieee128,
__vprintf_chkieee128, __vsnprintf_chkieee128, __vsprintf_chkieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.sh:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 33 +++++
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 ++++++
.../ldbl-128ibm-compat/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 +++++
.../ldbl-128ibm-compat/ieee128-vsnprintf_chk.c | 34 +++++
.../ldbl-128ibm-compat/ieee128-vsprintf_chk.c | 34 +++++
.../ldbl-128ibm-compat/test-printf-chk-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-printf-chk-ieee128.c | 1 +
.../test-printf-chk-ldbl-compat.c | 142 +++++++++++++++++++++
.../test-printf-chk-ldbl-compat.sh | 64 ++++++++++
18 files changed, 680 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-ldbl-compat.sh

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index e07074356b..78400a7a4a 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -23,6 +23,20 @@ routines += ieee128-vfwprintf
routines += ieee128-vswprintf
routines += ieee128-vwprintf

+routines += ieee128-asprintf_chk
+routines += ieee128-dprintf_chk
+routines += ieee128-fprintf_chk
+routines += ieee128-printf_chk
+routines += ieee128-snprintf_chk
+routines += ieee128-sprintf_chk
+
+routines += ieee128-vasprintf_chk
+routines += ieee128-vdprintf_chk
+routines += ieee128-vfprintf_chk
+routines += ieee128-vprintf_chk
+routines += ieee128-vsnprintf_chk
+routines += ieee128-vsprintf_chk
+
# 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
@@ -40,12 +54,19 @@ 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-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
+
ifeq ($(run-built-tests),yes)
tests-special += $(objpfx)test-printf-ieee128.out
tests-special += $(objpfx)test-printf-ibm128.out

tests-special += $(objpfx)test-wprintf-ieee128.out
tests-special += $(objpfx)test-wprintf-ibm128.out
+
+tests-special += $(objpfx)test-printf-chk-ieee128.out
+tests-special += $(objpfx)test-printf-chk-ibm128.out
endif

$(objpfx)test-printf-ieee128.out: \
@@ -71,4 +92,16 @@ $(objpfx)test-wprintf-ibm128.out: \
$(objpfx)test-wprintf-ibm128
$(SHELL) $^ '$(test-program-prefix)' $@; \
$(evaluate-test)
+
+$(objpfx)test-printf-chk-ieee128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.sh \
+ $(objpfx)test-printf-chk-ieee128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-printf-chk-ibm128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.sh \
+ $(objpfx)test-printf-chk-ibm128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 4c3f8622b1..540237d6d4 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -134,5 +134,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..d3b9ee0b79
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __asprintf_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_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..7b4ce157be
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __dprintf_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_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..a1ec25b6e8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __fprintf_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_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..b94ec7d5cd
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __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_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..5f5c0297fd
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __snprintf_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_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..05847df6ec
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __sprintf_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_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, -1, 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..5b1b5ad08a
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __vasprintf_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_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..b01fcb61a4
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vdprintf_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_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..d3a494494c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vfprintf_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_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..c11d36f2ee
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __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_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..9fc43a67c9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vsnprintf_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_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..964a26f935
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vsprintf_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_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, -1, 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..3243a8ecf9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c
@@ -0,0 +1,142 @@
+/* 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 <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 (1, 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 (1, 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 int
+do_test (void)
+{
+ long double ld = -1;
+
+ /* Print in decimal notation. */
+ do_test_call_rarg (stdout, "%.60Lf", ld);
+ do_test_call_varg (stdout, "%.60Lf", ld);
+
+ /* Print in hexadecimal notation. */
+ do_test_call_rarg (stdout, "%.60La", ld);
+ do_test_call_varg (stdout, "%.60La", ld);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.sh
new file mode 100644
index 0000000000..872e1e2721
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.sh
@@ -0,0 +1,64 @@
+#!/bin/sh
+# Testing of *printf. IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+ ${test_program} \
+ > ${test_program_output} || status=1
+
+cat <<'EOF' |
+ __asprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __dprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __fprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __printf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __snprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __sprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vasprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vdprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vfprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vsnprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vsprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __asprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __dprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __fprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __printf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __snprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __sprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vasprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vdprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vfprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vsnprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vsprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
--
2.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:16 UTC
Permalink
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.

Tested for powerpc64le.

* sysdeps/ieee754/ldbl-128ibm-compat/Makefile:
[subdir == stdio-common] (routines): Add ieee128-fwprintf_chk,
ieee128-swprintf_chk, ieee128-wprintf_chk,
ieee128-vfwprintf_chk, ieee128-vswprintf_chk, and
ieee128-vwprintf_chk.
[subdir == stdio-common] (tests-internal): Add
test-wprintf-chk-ieee128 and test-wprintf-chk-ibm128.
[subdir == stdio-common] (CFLAGS-test-wprintf-chk-ieee128.c): New
variable to add the relevant -mabi flags to the compilation.
[subdir == stdio-common] (CFLAGS-test-wprintf-chk-ibm128.c): Likewise.
[subdir == stdio-common && run-built-tests == yes]
(tests-special): Add $(objpfx)test-wprintf-chk-ieee128.out, and
$(objpfx)test-wprintf-chk-ibm128.out.
[subdir == stdio-common] ($(objpfx)test-wprintf-chk-ieee128.out):
New build and test rule.
[subdir == stdio-common] ($(objpfx)test-wprintf-chk-ibm128.out):
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__fwprintf_chkieee128, __swprintf_chkieee128,
__wprintf_chkieee128, __vfwprintf_chkieee128,
__vswprintf_chkieee128, and __vwprintf_chkieee128;
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c:
New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.sh:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 27 +++++++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++
.../ldbl-128ibm-compat/ieee128-fwprintf_chk.c | 38 +++++++++
.../ldbl-128ibm-compat/ieee128-swprintf_chk.c | 42 ++++++++++
.../ldbl-128ibm-compat/ieee128-vfwprintf_chk.c | 31 ++++++++
.../ldbl-128ibm-compat/ieee128-vswprintf_chk.c | 34 +++++++++
.../ldbl-128ibm-compat/ieee128-vwprintf_chk.c | 30 ++++++++
.../ldbl-128ibm-compat/ieee128-wprintf_chk.c | 38 +++++++++
.../ldbl-128ibm-compat/test-wprintf-chk-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-wprintf-chk-ieee128.c | 1 +
.../test-wprintf-chk-ldbl-compat.c | 89 ++++++++++++++++++++++
.../test-wprintf-chk-ldbl-compat.sh | 52 +++++++++++++
12 files changed, 391 insertions(+)
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-ldbl-compat.sh

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 78400a7a4a..88cb36576b 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -37,6 +37,14 @@ routines += ieee128-vprintf_chk
routines += ieee128-vsnprintf_chk
routines += ieee128-vsprintf_chk

+routines += ieee128-fwprintf_chk
+routines += ieee128-swprintf_chk
+routines += ieee128-wprintf_chk
+
+routines += ieee128-vfwprintf_chk
+routines += ieee128-vswprintf_chk
+routines += ieee128-vwprintf_chk
+
# 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
@@ -58,6 +66,10 @@ 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-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
+
ifeq ($(run-built-tests),yes)
tests-special += $(objpfx)test-printf-ieee128.out
tests-special += $(objpfx)test-printf-ibm128.out
@@ -67,6 +79,9 @@ tests-special += $(objpfx)test-wprintf-ibm128.out

tests-special += $(objpfx)test-printf-chk-ieee128.out
tests-special += $(objpfx)test-printf-chk-ibm128.out
+
+tests-special += $(objpfx)test-wprintf-chk-ieee128.out
+tests-special += $(objpfx)test-wprintf-chk-ibm128.out
endif

$(objpfx)test-printf-ieee128.out: \
@@ -104,4 +119,16 @@ $(objpfx)test-printf-chk-ibm128.out: \
$(objpfx)test-printf-chk-ibm128
$(SHELL) $^ '$(test-program-prefix)' $@; \
$(evaluate-test)
+
+$(objpfx)test-wprintf-chk-ieee128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.sh \
+ $(objpfx)test-wprintf-chk-ieee128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-wprintf-chk-ibm128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.sh \
+ $(objpfx)test-wprintf-chk-ibm128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 540237d6d4..583c05cca7 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -148,5 +148,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..bdf48633de
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __fwprintf_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_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..411da9a0de
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c
@@ -0,0 +1,42 @@
+/* Wrapper for __swprintf_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_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..2d6fe6d429
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c
@@ -0,0 +1,31 @@
+/* Wrapper for __vfwprintf_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_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..702fdda0c7
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c
@@ -0,0 +1,34 @@
+/* Wrapper for __vswprintf_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_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..54f763bc58
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c
@@ -0,0 +1,30 @@
+/* Wrapper for __vwprintf_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_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..82b6d85c23
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c
@@ -0,0 +1,38 @@
+/* Wrapper for __wprintf_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_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..d68e7fd7eb
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c
@@ -0,0 +1,89 @@
+/* Test for the long double variants of *w*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 <wchar.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 int
+do_test (void)
+{
+ long double ld = -1;
+
+ /* Print in decimal notation. */
+ do_test_call_rarg (stdout, L"%.60Lf", ld);
+ do_test_call_varg (stdout, L"%.60Lf", ld);
+
+ /* Print in hexadecimal notation. */
+ do_test_call_rarg (stdout, L"%.60La", ld);
+ do_test_call_varg (stdout, L"%.60La", ld);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.sh
new file mode 100644
index 0000000000..e87a2eef2e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.sh
@@ -0,0 +1,52 @@
+#!/bin/sh
+# Testing of *w*printf_chk. IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+ ${test_program} \
+ > ${test_program_output} || status=1
+
+cat <<'EOF' |
+ __fwprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __swprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __wprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vfwprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vswprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __vwprintf_chk: -1.000000000000000000000000000000000000000000000000000000000000
+ __fwprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __swprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __wprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vfwprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vswprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ __vwprintf_chk: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
--
2.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:17 UTC
Permalink
A single format string can take double and long double parameters at the
same time. Internally, these parameters are routed to the same
function, which correctly reads them and calls the underlying functions
responsible for the actual conversion to string. This patch adds a new
case to test this scenario.

Tested for powerpc64le.

* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c:
(do_test_call_rarg): Add parameter and use it in the calls
to *printf functions under test.
(do_test): Add variable and use it in the calls to
do_test_call_rarg and do_test_call_varg.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh:
Modify expected result.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh:
Likewise.
---
.../ldbl-128ibm-compat/test-printf-ldbl-compat.c | 23 ++++++-----
.../ldbl-128ibm-compat/test-printf-ldbl-compat.sh | 48 +++++++++++-----------
.../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c | 18 ++++----
.../ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh | 24 +++++------
4 files changed, 58 insertions(+), 55 deletions(-)

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 936e85f8d6..eece753c0d 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -76,13 +76,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 ("%20s", "asprintf: ");
- asprintf (&buffer, format, ld);
+ asprintf (&buffer, format, ld, d);
if (buffer == NULL)
printf ("Error using asprintf\n");
else
@@ -93,24 +93,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld)
printf ("\n");

printf ("%20s", "dprintf: ");
- dprintf (1, format, ld);
+ dprintf (1, format, ld, d);
printf ("\n");

printf ("%20s", "fprintf: ");
- fprintf (stdout, format, ld);
+ fprintf (stdout, format, ld, d);
printf ("\n");

printf ("%20s", "printf: ");
- printf (format, ld);
+ printf (format, ld, d);
printf ("\n");

printf ("%20s", "snprintf: ");
- snprintf (string, 127, format, ld);
+ snprintf (string, 127, format, ld, d);
printf ("%s", string);
printf ("\n");

printf ("%20s", "sprintf: ");
- sprintf (string, format, ld);
+ sprintf (string, format, ld, d);
printf ("%s", string);
printf ("\n");
}
@@ -119,14 +119,15 @@ static int
do_test (void)
{
long double ld = -1;
+ double d = -1;

/* Print in decimal notation. */
- do_test_call_rarg (stdout, "%.60Lf", ld);
- do_test_call_varg (stdout, "%.60Lf", ld);
+ do_test_call_rarg (stdout, "%.60Lf, %f", ld, d);
+ do_test_call_varg (stdout, "%.60Lf, %f", ld, d);

/* Print in hexadecimal notation. */
- do_test_call_rarg (stdout, "%.60La", ld);
- do_test_call_varg (stdout, "%.60La", ld);
+ do_test_call_rarg (stdout, "%.60La, %a", ld, d);
+ do_test_call_varg (stdout, "%.60La, %a", ld, d);

return 0;
}
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
index 62bc5d03a6..b728c32e40 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh
@@ -30,30 +30,30 @@ ${test_program_prefix} \
Post by Gabriel F. T. Gomes
${test_program_output} || status=1
cat <<'EOF' |
- asprintf: -1.000000000000000000000000000000000000000000000000000000000000
- dprintf: -1.000000000000000000000000000000000000000000000000000000000000
- fprintf: -1.000000000000000000000000000000000000000000000000000000000000
- printf: -1.000000000000000000000000000000000000000000000000000000000000
- snprintf: -1.000000000000000000000000000000000000000000000000000000000000
- sprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vasprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vdprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vfprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vsnprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vsprintf: -1.000000000000000000000000000000000000000000000000000000000000
- asprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- dprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- fprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- printf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- snprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- sprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vasprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vdprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vfprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vsnprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vsprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ asprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ dprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ fprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ printf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ snprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ sprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vasprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vdprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vfprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vsnprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vsprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ asprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ dprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ fprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ printf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ snprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ sprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vasprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vdprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vfprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vsnprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vsprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
EOF
cmp - ${test_program_output} > /dev/null 2>&1 ||
{
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 67ddbc9194..71ac3e27fa 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c
@@ -50,21 +50,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: ");
- fwprintf (stream, format, ld);
+ fwprintf (stream, format, ld, d);
wprintf (L"\n");

wprintf (L"%20Ls", L"swprintf: ");
- swprintf (string, 127, format, ld);
+ swprintf (string, 127, format, ld, d);
wprintf (L"%Ls", string);
wprintf (L"\n");

wprintf (L"%20Ls", L"wprintf: ");
- wprintf (format, ld);
+ wprintf (format, ld, d);
wprintf (L"\n");
}

@@ -72,14 +73,15 @@ static int
do_test (void)
{
long double ld = -1;
+ double d = -1;

/* Print in decimal notation. */
- do_test_call_rarg (stdout, L"%.60Lf", ld);
- do_test_call_varg (stdout, L"%.60Lf", ld);
+ do_test_call_rarg (stdout, L"%.60Lf, %f", ld, d);
+ do_test_call_varg (stdout, L"%.60Lf, %f", ld, d);

/* Print in hexadecimal notation. */
- do_test_call_rarg (stdout, L"%.60La", ld);
- do_test_call_varg (stdout, L"%.60La", ld);
+ do_test_call_rarg (stdout, L"%.60La, %a", ld, d);
+ do_test_call_varg (stdout, L"%.60La, %a", ld, d);

return 0;
}
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
index 029006eb5e..d05b3bdb71 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.sh
@@ -30,18 +30,18 @@ ${test_program_prefix} \
Post by Gabriel F. T. Gomes
${test_program_output} || status=1
cat <<'EOF' |
- fwprintf: -1.000000000000000000000000000000000000000000000000000000000000
- swprintf: -1.000000000000000000000000000000000000000000000000000000000000
- wprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vfwprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vswprintf: -1.000000000000000000000000000000000000000000000000000000000000
- vwprintf: -1.000000000000000000000000000000000000000000000000000000000000
- fwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- swprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- wprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vfwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vswprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
- vwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0
+ fwprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ swprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ wprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vfwprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vswprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ vwprintf: -1.000000000000000000000000000000000000000000000000000000000000, -1.000000
+ fwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ swprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ wprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vfwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vswprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
+ vwprintf: -0x1.000000000000000000000000000000000000000000000000000000000000p+0, -0x1p+0
EOF
cmp - ${test_program_output} > /dev/null 2>&1 ||
{
--
2.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:18 UTC
Permalink
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 (routines): Add
ieee128-fscanf, ieee128-scanf, ieee128-sscanf, ieee128-vfscanf,
ieee128-vscanf, and ieee128-vsscanf.
(CFLAGS-vfscanf-internal.c): Add -mfloat128 to the compiler
command used to build vfscanf-internal.c. This is needed to
extend __vfscanf_internal with the support to redirect the call
to __strtold_internal to __strtof128_internal.
(tests-internal): Add test-scanf-ieee128 and test-scanf-ibm128.
(CFLAGS-test-scanf-ieee128.c): New variable.
(CFLAGS-test-scanf-ibm128.c): Likewise.
($(objpfx)test-scanf-ieee128): Link the loader after libgcc.
[run-built-tests] (tests-special): Add
$(objpfx)test-scanf-ieee128.out and
$(objpfx)test-scanf-ibm128.out.
($(objpfx)test-scanf-ieee128.out): New build and run rule.
($(objpfx)test-scanf-ibm128.out): Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__fscanfieee128, __scanfieee128, __sscanfieee128,
__vfscanfieee128, __vscanfieee128, and __vsscanfieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 35 +++++-
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++
.../ieee754/ldbl-128ibm-compat/ieee128-fscanf.c | 34 ++++++
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c | 34 ++++++
.../ieee754/ldbl-128ibm-compat/ieee128-sscanf.c | 38 +++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c | 26 +++++
.../ieee754/ldbl-128ibm-compat/ieee128-vscanf.c | 26 +++++
.../ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c | 29 +++++
.../ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-scanf-ieee128.c | 1 +
.../test-scanf-ldbl-compat-template.c | 117 +++++++++++++++++++++
.../ldbl-128ibm-compat/test-scanf-ldbl-compat.c | 10 ++
.../ldbl-128ibm-compat/test-scanf-ldbl-compat.sh | 63 +++++++++++
13 files changed, 420 insertions(+), 2 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 88cb36576b..10fd6bbffc 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -45,12 +45,22 @@ routines += ieee128-vfwprintf_chk
routines += ieee128-vswprintf_chk
routines += ieee128-vwprintf_chk

+routines += ieee128-fscanf
+routines += ieee128-scanf
+routines += ieee128-sscanf
+
+routines += ieee128-vfscanf
+routines += ieee128-vscanf
+routines += ieee128-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 passed to the compiler.
+# and __float128 variables and union members). Likewise, reading these
+# values reuses __strtof128_internal. Thus, the compilation of the
+# following functions, must have -mfloat128 passed to the compiler.
CFLAGS-vfprintf-internal.c += -mfloat128
CFLAGS-vfwprintf-internal.c += -mfloat128
+CFLAGS-vfscanf-internal.c += -mfloat128

# Basic tests for the implementation of long double with IEEE binary128
# format and for the related redirections in installed headers.
@@ -70,6 +80,12 @@ 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-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-printf-ieee128.out
tests-special += $(objpfx)test-printf-ibm128.out
@@ -82,6 +98,9 @@ tests-special += $(objpfx)test-printf-chk-ibm128.out

tests-special += $(objpfx)test-wprintf-chk-ieee128.out
tests-special += $(objpfx)test-wprintf-chk-ibm128.out
+
+tests-special += $(objpfx)test-scanf-ieee128.out
+tests-special += $(objpfx)test-scanf-ibm128.out
endif

$(objpfx)test-printf-ieee128.out: \
@@ -131,4 +150,16 @@ $(objpfx)test-wprintf-chk-ibm128.out: \
$(objpfx)test-wprintf-chk-ibm128
$(SHELL) $^ '$(test-program-prefix)' $@; \
$(evaluate-test)
+
+$(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)
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 583c05cca7..26cb9aa692 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -156,5 +156,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..f766897da4
--- /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) \
+ printf ("OK"); \
+ else \
+ printf ("ERROR (%.60Lf)", *ld); \
+ printf ("\n");
+
+#define CHECK_VALUE \
+ if (value == -1) \
+ 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.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:19 UTC
Permalink
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 (routines): Add
ieee128-fwscanf, ieee128-swscanf, ieee128-wscanf,
ieee128-vfwscanf, ieee128-vswscanf, and ieee128-vwscanf
(CFLAGS-vfwscanf-internal.c): Add -mfloat128 to the compiler
command used to build vfwscanf-internal.c. This is needed to
extend __vfwscanf_internal with the support to redirect the call
to __wcstold_internal to __wcstof128_internal.
(tests-internal): Add test-wscanf-ieee128 and test-wscanf-ibm128.
(CFLAGS-test-wscanf-ieee128.c): New variable.
(CFLAGS-test-wscanf-ibm128.c): Likewise.
($(objpfx)test-wscanf-ieee128): Link the loader after libgcc.
[run-built-tests] (tests-special): Add
$(objpfx)test-wscanf-ieee128.out and
$(objpfx)test-wscanf-ibm128.out.
($(objpfx)test-wscanf-ieee128.out): New build and run rules.
($(objpfx)test-wscanf-ibm128.out): Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add
__fwscanfieee128, __swscanfieee128, __wscanfieee128,
__vfwscanfieee128, __vswscanfieee128, and __vwscanfieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 30 ++++++++++++++++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 +++++
.../ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c | 35 +++++++++++++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-swscanf.c | 40 ++++++++++++++++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c | 27 +++++++++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c | 31 +++++++++++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c | 27 +++++++++++++++
.../ieee754/ldbl-128ibm-compat/ieee128-wscanf.c | 35 +++++++++++++++++++
.../ldbl-128ibm-compat/test-wscanf-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-wscanf-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-wscanf-ldbl-compat.c | 10 ++++++
11 files changed, 245 insertions(+)
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 10fd6bbffc..5cb6fd4f73 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -53,6 +53,14 @@ routines += ieee128-vfscanf
routines += ieee128-vscanf
routines += ieee128-vsscanf

+routines += ieee128-fwscanf
+routines += ieee128-swscanf
+routines += ieee128-wscanf
+
+routines += ieee128-vfwscanf
+routines += ieee128-vswscanf
+routines += ieee128-vwscanf
+
# 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). Likewise, reading these
@@ -61,6 +69,7 @@ routines += ieee128-vsscanf
CFLAGS-vfprintf-internal.c += -mfloat128
CFLAGS-vfwprintf-internal.c += -mfloat128
CFLAGS-vfscanf-internal.c += -mfloat128
+CFLAGS-vfwscanf-internal.c += -mfloat128

# Basic tests for the implementation of long double with IEEE binary128
# format and for the related redirections in installed headers.
@@ -86,6 +95,12 @@ 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-printf-ieee128.out
tests-special += $(objpfx)test-printf-ibm128.out
@@ -101,6 +116,9 @@ tests-special += $(objpfx)test-wprintf-chk-ibm128.out

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-printf-ieee128.out: \
@@ -162,4 +180,16 @@ $(objpfx)test-scanf-ibm128.out: \
$(objpfx)test-scanf-ibm128
$(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)
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 26cb9aa692..e0e7e74160 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -164,5 +164,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..a70e94ba98
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c
@@ -0,0 +1,31 @@
+/* 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 (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.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:20 UTC
Permalink
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.

* argp/argpP.h: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/Makefile
[subdir == argp] (routines): Add ieee128-argp_error and
ieee128-argp_failure.
[subdir == argp] (tests-internal): Add test-argp-error-ieee128,
test-argp-error-ibm128, test-argp-failure-ieee128, and
test-argp-failure-ibm128.
[subdir == argp] (CFLAGS-test-argp-error-ieee128.c): New variable.
[subdir == argp] (CFLAGS-test-argp-error-ibm128.c): Likewise.
[subdir == argp] (CFLAGS-test-argp-failure-ieee128.c): Likewise.
[subdir == argp] (CFLAGS-test-argp-failure-ibm128): Likewise.
[subdir == argp && run-built-tests == yes] (tests-special): Add
$(objpfx)test-argp-error-ieee128.out,
$(objpfx)test-argp-error-ibm128.out,
$(objpfx)test-argp-failure-ieee128.out,
$(objpfx)test-argp-failure-ibm128.out.
[subdir == argp] ($(objpfx)test-argp-error-ieee128.out)
($(objpfx)test-argp-error-ibm128.out)
($(objpfx)test-argp-failure-ieee128.out)
($(objpfx)test-argp-failure-ibm128.out): New build and run rule.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__argp_errorieee128 and __argp_failureieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_error.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_failure.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ibm128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ieee128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ibm128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ieee128.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-argp-ldbl-compat.c:
Likewise.
---
argp/argpP.h | 29 +++++++++
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 46 +++++++++++++++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 3 +
.../ldbl-128ibm-compat/ieee128-argp_error.c | 30 ++++++++++
.../ldbl-128ibm-compat/ieee128-argp_failure.c | 32 ++++++++++
.../ldbl-128ibm-compat/test-argp-error-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-argp-error-ieee128.c | 1 +
.../test-argp-error-ldbl-compat.c | 3 +
.../test-argp-error-ldbl-compat.sh | 46 +++++++++++++++
.../ldbl-128ibm-compat/test-argp-failure-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-argp-failure-ieee128.c | 1 +
.../test-argp-failure-ldbl-compat.c | 3 +
.../test-argp-failure-ldbl-compat.sh | 45 ++++++++++++++
.../ldbl-128ibm-compat/test-argp-ldbl-compat.c | 69 ++++++++++++++++++++++
14 files changed, 310 insertions(+)
create mode 100644 argp/argpP.h
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_error.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_failure.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-argp-ldbl-compat.c

diff --git a/argp/argpP.h b/argp/argpP.h
new file mode 100644
index 0000000000..da77c6840c
--- /dev/null
+++ b/argp/argpP.h
@@ -0,0 +1,29 @@
+/* Prototypes for internal argp.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 <argp.h>
+
+void
+__argp_error_internal (const struct argp_state *state, const char *fmt,
+ va_list ap, unsigned int mode_flags);
+
+void
+__argp_failure_internal (const struct argp_state *state, int status,
+ int errnum, const char *fmt, va_list ap,
+ unsigned int mode_flags);
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 5cb6fd4f73..b37bb05b0f 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -193,3 +193,49 @@ $(objpfx)test-wscanf-ibm128.out: \
$(SHELL) $^ '$(test-program-prefix)' $@; \
$(evaluate-test)
endif
+
+ifeq ($(subdir),argp)
+# Wrappers for argp functions that take long double arguments with
+# IEEE binary128 format
+routines += ieee128-argp_error
+routines += ieee128-argp_failure
+
+tests-internal += test-argp-error-ieee128 test-argp-error-ibm128
+CFLAGS-test-argp-error-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-argp-error-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-argp-failure-ieee128 test-argp-failure-ibm128
+CFLAGS-test-argp-failure-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-argp-failure-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)test-argp-error-ieee128.out
+tests-special += $(objpfx)test-argp-error-ibm128.out
+tests-special += $(objpfx)test-argp-failure-ieee128.out
+tests-special += $(objpfx)test-argp-failure-ibm128.out
+endif
+
+$(objpfx)test-argp-error-ieee128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh \
+ $(objpfx)test-argp-error-ieee128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-argp-error-ibm128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh \
+ $(objpfx)test-argp-error-ibm128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-argp-failure-ieee128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh \
+ $(objpfx)test-argp-failure-ieee128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-argp-failure-ibm128.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh \
+ $(objpfx)test-argp-failure-ibm128
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index e0e7e74160..21a1f28694 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -172,5 +172,8 @@ libc {
__vfwscanfieee128;
__vswscanfieee128;
__vwscanfieee128;
+
+ __argp_errorieee128;
+ __argp_failureieee128;
}
}
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_error.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_error.c
new file mode 100644
index 0000000000..35c467b471
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_error.c
@@ -0,0 +1,30 @@
+/* Wrapper for argp_error. 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/argpP.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)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_failure.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_failure.c
new file mode 100644
index 0000000000..0abe88f538
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp_failure.c
@@ -0,0 +1,32 @@
+/* Wrapper for 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/argpP.h>
+#include <libio/libioP.h>
+
+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)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ibm128.c
new file mode 100644
index 0000000000..a201323cd9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ibm128.c
@@ -0,0 +1 @@
+#include <test-argp-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ieee128.c
new file mode 100644
index 0000000000..a201323cd9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ieee128.c
@@ -0,0 +1 @@
+#include <test-argp-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.c
new file mode 100644
index 0000000000..049f8af7a0
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ARGP_FUNCTION argp_error
+#define ARGP_FUNCTION_PARAMS (state, arg, (long double) -1)
+#include <test-argp-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh
new file mode 100644
index 0000000000..5327bf5274
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-error-ldbl-compat.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+# Testing of argp_error. 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
+
+# Allow argp_error to end with non-zero exit status, run the test
+# program, then restore the exit-on-error behavior
+set +e
+${test_program_prefix} \
+ ${test_program} \
+ 2> ${test_program_output}
+set -e
+
+cat <<'EOF' |
+test-argp: -1.000000000000000000000000000000000000000000000000000000000000
+Try `test-argp --help' or `test-argp --usage' for more information.
+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-argp-failure-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ibm128.c
new file mode 100644
index 0000000000..2983bc3f6c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ibm128.c
@@ -0,0 +1 @@
+#include <test-argp-failure-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ieee128.c
new file mode 100644
index 0000000000..2983bc3f6c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ieee128.c
@@ -0,0 +1 @@
+#include <test-argp-failure-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.c
new file mode 100644
index 0000000000..e43d3373bc
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ARGP_FUNCTION argp_failure
+#define ARGP_FUNCTION_PARAMS (state, 0, 0, arg, (long double) -1)
+#include <test-argp-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh
new file mode 100644
index 0000000000..132bc5f96c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-failure-ldbl-compat.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+# Testing of argp_failure. 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
+
+# Allow argp_failure to end with non-zero exit status, run the test
+# program, then restore the exit-on-error behavior
+set +e
+${test_program_prefix} \
+ ${test_program} \
+ 2> ${test_program_output}
+set -e
+
+cat <<'EOF' |
+test-argp: -1.000000000000000000000000000000000000000000000000000000000000
+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-argp-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-ldbl-compat.c
new file mode 100644
index 0000000000..ca008b507c
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-argp-ldbl-compat.c
@@ -0,0 +1,69 @@
+/* Test for the long double variants of argp* 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 <argp.h>
+#include <string.h>
+
+#include <support/check.h>
+
+static const struct argp_option
+options[] =
+{
+ { "test", 't', "format", 0, "Run argp function with a format string", 0 },
+ { NULL, 0, NULL, 0, NULL }
+};
+
+static error_t
+parser (int key, char *arg, struct argp_state *state)
+{
+ switch (key)
+ {
+ case 't':
+ ARGP_FUNCTION ARGP_FUNCTION_PARAMS;
+ break;
+ default:
+ return ARGP_ERR_UNKNOWN;
+ }
+ return 0;
+}
+
+static struct argp
+argp =
+{
+ options, parser
+};
+
+static int
+do_test (void)
+{
+ int remaining;
+ int argc = 3;
+ char *argv[4] =
+ {
+ (char *) "test-argp",
+ (char *) "--test",
+ (char *) "%.60Lf",
+ NULL
+ };
+
+ argp_parse (&argp, argc, argv, 0, &remaining, NULL);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
--
2.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:21 UTC
Permalink
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: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/Makefile
[subdir == misc] (routines): Add ieee128-err.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__warnieee128, __warnxieee128, __vwarnieee128, __vwarnxieee128
__errieee128, __errxieee128, __verrieee128, and __verrxieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c: New file.
---
misc/errP.h | 28 +++++++
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 6 ++
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 9 +++
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c | 93 ++++++++++++++++++++++++
4 files changed, 136 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 b37bb05b0f..ed5e4190fb 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -239,3 +239,9 @@ $(objpfx)test-argp-failure-ibm128.out: \
$(SHELL) $^ '$(test-program-prefix)' $@; \
$(evaluate-test)
endif
+
+ifeq ($(subdir),misc)
+# Wrappers for err.h functions that take long double arguments with
+# IEEE binary128 format
+routines += ieee128-err
+endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index 21a1f28694..b2ce31fcf3 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -175,5 +175,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.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:22 UTC
Permalink
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: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/Makefile
[subdir == misc] (routines): Add ieee128-error.
* sysdeps/ieee754/ldbl-128ibm-compat/Versions (libc): Add
__error_at_lineieee128 and __errorieee128.
* sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c: New file.
---
misc/errorP.h | 28 ++++++++++++
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 1 +
sysdeps/ieee754/ldbl-128ibm-compat/Versions | 3 ++
sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c | 51 ++++++++++++++++++++++
4 files changed, 83 insertions(+)
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 ed5e4190fb..33ac2193a6 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -244,4 +244,5 @@ ifeq ($(subdir),misc)
# Wrappers for err.h functions that take long double arguments with
# IEEE binary128 format
routines += ieee128-err
+routines += ieee128-error
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
index b2ce31fcf3..4c813c6246 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
@@ -184,5 +184,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.14.4
Gabriel F. T. Gomes
2018-06-21 02:10:23 UTC
Permalink
Add tests for the functions from err.h and error.h that can take
positional long double parameters. Most of the functions tested by this
patch do not return, so each have an independent test.

Tested for powerpc64le.

* sysdeps/ieee754/ldbl-128ibm-compat/Makefile
(tests-internal): Add test-warn-ibm128, test-warn-ieee128,
test-err-ibm128, test-err-ieee128, test-errx-ibm128,
test-errx-ieee128, test-verr-ibm128, test-verr-ieee128,
test-verrx-ibm128, test-verrx-ieee128, test-error1-ibm128,
test-error1-ieee128, test-error2-ibm128, and test-error2-ieee128.
(CFLAGS-test-err-ieee128.c): New variable.
(CFLAGS-test-err-ibm128.c): Likewise.
(CFLAGS-test-errx-ieee128.c): Likewise.
(CFLAGS-test-errx-ibm128.c): Likewise.
(CFLAGS-test-verr-ieee128.c): Likewise.
(CFLAGS-test-verr-ibm128.c): Likewise.
(CFLAGS-test-verrx-ieee128.c): Likewise.
(CFLAGS-test-verrx-ibm128.c): Likewise.
(CFLAGS-test-error1-ieee128.c): Likewise.
(CFLAGS-test-error1-ibm128.c): Likewise.
(CFLAGS-test-error2-ieee128.c): Likewise.
(CFLAGS-test-error2-ibm128.c): Likewise.
[run-built-tests == yes] (tests-special): Add
$(objpfx)test-warn-ieee128.out, $(objpfx)test-warn-ibm128.out,
$(objpfx)test-err-ieee128.out, $(objpfx)test-err-ibm128.out,
$(objpfx)test-errx-ieee128.out, $(objpfx)test-errx-ibm128.out,
$(objpfx)test-verr-ieee128.out, $(objpfx)test-verr-ibm128.out,
$(objpfx)test-verrx-ieee128.out, $(objpfx)test-verrx-ibm128.out,
$(objpfx)test-error1-ieee128.out, $(objpfx)test-error1-ibm128.out,
$(objpfx)test-error2-ieee128.out, $(objpfx)test-error2-ibm128.out.
($(objpfx)test-warn-%.out, $(objpfx)test-err-%.out)
($(objpfx)test-errx-%.out, $(objpfx)test-verr-%.out)
($(objpfx)test-verrx-%.out, $(objpfx)test-error1-%.out)
($(objpfx)test-error2-%.out): New build and run rule.
* sysdeps/ieee754/ldbl-128ibm-compat/test-err-ibm128.c: New file.
* sysdeps/ieee754/ldbl-128ibm-compat/test-err-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ldbl-compat.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ldbl-compat.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ldbl-compat.c:
Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ibm128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ieee128.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.c: Likewise.
* sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh:
Likewise.
---
sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 85 ++++++++++++++++++++++
.../ieee754/ldbl-128ibm-compat/test-err-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-err-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-err-ldbl-compat.c | 3 +
.../ldbl-128ibm-compat/test-err-ldbl-compat.sh | 44 +++++++++++
.../ldbl-128ibm-compat/test-error-ldbl-compat.c | 45 ++++++++++++
.../ldbl-128ibm-compat/test-error1-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-error1-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-error1-ldbl-compat.c | 3 +
.../ldbl-128ibm-compat/test-error2-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-error2-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-error2-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-errx-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-errx-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-errx-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-verr-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-verr-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-verr-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c | 1 +
.../ldbl-128ibm-compat/test-verrx-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-verrx-ldbl-compat.c | 3 +
.../ieee754/ldbl-128ibm-compat/test-warn-ibm128.c | 1 +
.../ieee754/ldbl-128ibm-compat/test-warn-ieee128.c | 1 +
.../ldbl-128ibm-compat/test-warn-ldbl-compat.c | 61 ++++++++++++++++
.../ldbl-128ibm-compat/test-warn-ldbl-compat.sh | 50 +++++++++++++
25 files changed, 317 insertions(+)
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ibm128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ieee128.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.c
create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh

diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
index 33ac2193a6..fe87f92d0c 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
@@ -245,4 +245,89 @@ ifeq ($(subdir),misc)
# IEEE binary128 format
routines += ieee128-err
routines += ieee128-error
+
+tests-internal += test-warn-ibm128 test-warn-ieee128
+CFLAGS-test-warn-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-warn-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-err-ibm128 test-err-ieee128
+tests-internal += test-errx-ibm128 test-errx-ieee128
+tests-internal += test-verr-ibm128 test-verr-ieee128
+tests-internal += test-verrx-ibm128 test-verrx-ieee128
+CFLAGS-test-err-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-err-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-test-errx-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-errx-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-test-verr-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-verr-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-test-verrx-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-verrx-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+tests-internal += test-error1-ibm128 test-error1-ieee128
+tests-internal += test-error2-ibm128 test-error2-ieee128
+CFLAGS-test-error1-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-error1-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+CFLAGS-test-error2-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi
+CFLAGS-test-error2-ibm128.c += -mabi=ibmlongdouble -Wno-psabi
+
+ifeq ($(run-built-tests),yes)
+tests-special += $(objpfx)test-warn-ieee128.out
+tests-special += $(objpfx)test-warn-ibm128.out
+
+tests-special += $(objpfx)test-err-ieee128.out
+tests-special += $(objpfx)test-err-ibm128.out
+tests-special += $(objpfx)test-errx-ieee128.out
+tests-special += $(objpfx)test-errx-ibm128.out
+tests-special += $(objpfx)test-verr-ieee128.out
+tests-special += $(objpfx)test-verr-ibm128.out
+tests-special += $(objpfx)test-verrx-ieee128.out
+tests-special += $(objpfx)test-verrx-ibm128.out
+
+tests-special += $(objpfx)test-error1-ieee128.out
+tests-special += $(objpfx)test-error1-ibm128.out
+tests-special += $(objpfx)test-error2-ieee128.out
+tests-special += $(objpfx)test-error2-ibm128.out
+endif
+
+$(objpfx)test-warn-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh \
+ $(objpfx)test-warn-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-err-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh \
+ $(objpfx)test-err-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-errx-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh \
+ $(objpfx)test-errx-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-verr-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh \
+ $(objpfx)test-verr-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-verrx-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh \
+ $(objpfx)test-verrx-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-error1-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh \
+ $(objpfx)test-error1-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
+
+$(objpfx)test-error2-%.out: \
+ ../sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh \
+ $(objpfx)test-error2-%
+ $(SHELL) $^ '$(test-program-prefix)' $@; \
+ $(evaluate-test)
endif
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ibm128.c
new file mode 100644
index 0000000000..6884ea4b77
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ibm128.c
@@ -0,0 +1 @@
+#include <test-err-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ieee128.c
new file mode 100644
index 0000000000..6884ea4b77
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ieee128.c
@@ -0,0 +1 @@
+#include <test-err-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.c
new file mode 100644
index 0000000000..9f3fe28c47
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ERROR_FUNCTION err
+#define ERROR_FUNCTION_PARAMS (0, format, ld)
+#include <test-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh
new file mode 100644
index 0000000000..a30e550553
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-err-ldbl-compat.sh
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Testing of *err*. IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+ ${test_program} \
+ 2> ${test_program_output} || status=1
+
+sed -i ${test_program_output} -e "s/.*128: //"
+sed -i ${test_program_output} -e "s/: Success//"
+
+cat <<'EOF' |
+-1.000000000000000000000000000000000000000000000000000000000000
+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-error-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error-ldbl-compat.c
new file mode 100644
index 0000000000..4d637a4144
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error-ldbl-compat.c
@@ -0,0 +1,45 @@
+/* Test for the long double variants of *err* 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 <err.h>
+#include <error.h>
+#include <stdarg.h>
+
+#include <support/check.h>
+
+static void
+do_test_call (long double ld, const char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ ERROR_FUNCTION ERROR_FUNCTION_PARAMS;
+ va_end (args);
+}
+
+static int
+do_test (void)
+{
+ long double ld = -1;
+
+ do_test_call (ld, "%.60Lf", ld);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ibm128.c
new file mode 100644
index 0000000000..04bd3bd9b8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ibm128.c
@@ -0,0 +1 @@
+#include <test-error1-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ieee128.c
new file mode 100644
index 0000000000..04bd3bd9b8
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ieee128.c
@@ -0,0 +1 @@
+#include <test-error1-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ldbl-compat.c
new file mode 100644
index 0000000000..8a78fa7c42
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error1-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ERROR_FUNCTION error
+#define ERROR_FUNCTION_PARAMS (0, 0, format, ld)
+#include <test-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ibm128.c
new file mode 100644
index 0000000000..00eae5fb05
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ibm128.c
@@ -0,0 +1 @@
+#include <test-error2-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ieee128.c
new file mode 100644
index 0000000000..00eae5fb05
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ieee128.c
@@ -0,0 +1 @@
+#include <test-error2-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ldbl-compat.c
new file mode 100644
index 0000000000..cc7af7e31b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-error2-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ERROR_FUNCTION error_at_line
+#define ERROR_FUNCTION_PARAMS (0, 0, "", 128, format, ld)
+#include <test-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ibm128.c
new file mode 100644
index 0000000000..e54e3b6c5a
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ibm128.c
@@ -0,0 +1 @@
+#include <test-errx-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ieee128.c
new file mode 100644
index 0000000000..e54e3b6c5a
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ieee128.c
@@ -0,0 +1 @@
+#include <test-errx-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ldbl-compat.c
new file mode 100644
index 0000000000..c804202650
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-errx-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ERROR_FUNCTION errx
+#define ERROR_FUNCTION_PARAMS (0, format, ld)
+#include <test-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ibm128.c
new file mode 100644
index 0000000000..302cf70a7d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ibm128.c
@@ -0,0 +1 @@
+#include <test-verr-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ieee128.c
new file mode 100644
index 0000000000..302cf70a7d
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ieee128.c
@@ -0,0 +1 @@
+#include <test-verr-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ldbl-compat.c
new file mode 100644
index 0000000000..32a229d7c9
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-verr-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ERROR_FUNCTION verr
+#define ERROR_FUNCTION_PARAMS (0, format, args)
+#include <test-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c
new file mode 100644
index 0000000000..767cb2bc89
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ibm128.c
@@ -0,0 +1 @@
+#include <test-verrx-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ieee128.c
new file mode 100644
index 0000000000..767cb2bc89
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ieee128.c
@@ -0,0 +1 @@
+#include <test-verrx-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ldbl-compat.c
new file mode 100644
index 0000000000..407607835b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-verrx-ldbl-compat.c
@@ -0,0 +1,3 @@
+#define ERROR_FUNCTION verrx
+#define ERROR_FUNCTION_PARAMS (0, format, args)
+#include <test-error-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ibm128.c
new file mode 100644
index 0000000000..e47a8eebbc
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ibm128.c
@@ -0,0 +1 @@
+#include <test-warn-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ieee128.c
new file mode 100644
index 0000000000..e47a8eebbc
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ieee128.c
@@ -0,0 +1 @@
+#include <test-warn-ldbl-compat.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.c
new file mode 100644
index 0000000000..85589deec1
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.c
@@ -0,0 +1,61 @@
+/* Test for the long double variants of *warn* 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 <err.h>
+#include <stdarg.h>
+
+#include <support/check.h>
+
+static void
+do_test_call_varg (const char *format, ...)
+{
+ va_list args;
+
+ va_start (args, format);
+ vwarn (format, args);
+ va_end (args);
+
+ va_start (args, format);
+ vwarnx (format, args);
+ va_end (args);
+}
+
+static void
+do_test_call_rarg (const char *format, long double ld)
+{
+ warn (format, ld);
+ warnx (format, ld);
+}
+
+static int
+do_test (void)
+{
+ long double ld = -1;
+
+ /* Print in decimal notation. */
+ do_test_call_rarg ("%.60Lf", ld);
+ do_test_call_varg ("%.60Lf", ld);
+
+ /* Print in hexadecimal notation. */
+ do_test_call_rarg ("%.60La", ld);
+ do_test_call_varg ("%.60La", ld);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh
new file mode 100644
index 0000000000..017449a062
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-warn-ldbl-compat.sh
@@ -0,0 +1,50 @@
+#!/bin/sh
+# Testing of *warn*. IEEE binary128 for powerpc64le version.
+# Copyright (C) 2018 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <http://www.gnu.org/licenses/>.
+
+set -e
+
+test_program=$1; shift
+test_program_prefix=$1; shift
+test_program_output=$1; shift
+
+status=0
+
+${test_program_prefix} \
+ ${test_program} \
+ 2> ${test_program_output} || status=1
+
+sed -i "s/^test.*128: //" ${test_program_output}
+
+cat <<'EOF' |
+-1.000000000000000000000000000000000000000000000000000000000000: Success
+-1.000000000000000000000000000000000000000000000000000000000000
+-1.000000000000000000000000000000000000000000000000000000000000: Success
+-1.000000000000000000000000000000000000000000000000000000000000
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0: Success
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0: Success
+-0x1.000000000000000000000000000000000000000000000000000000000000p+0
+EOF
+cmp - ${test_program_output} > /dev/null 2>&1 ||
+{
+ status=1
+ echo "*** output comparison failed"
+}
+
+exit $status
--
2.14.4
Joseph Myers
2018-06-21 16:44:29 UTC
Permalink
Post by Gabriel F. T. Gomes
As a follow-up to my previous message on this topic [1], this patch set
adds more functions that need new versions on powerpc64le for the long
double format transition. There are functions that are still missing
(__isoc99_*scanf, printf_size, obstack_*printf, obstack_*printf_chk,
strfmon, as well as strfromld and strtold), thus, the redirections are
And presumably strfmon_l, strtold_l, wcstold, wcstold_l, q[efg]cvt{,_r},
at least. And syslog functions.

I have a general comment on the approach for testing in these patches.
Most of the tests seem to have a common file included in a wrapper file
for each long double format, which makes sense. I would suggest that
those common files should actually be in the relevant non-sysdeps
directories (misc/ in the case of err.h functions, for example) - and that
the tests should be built and run generically for the default long double
for all platforms, since after all they look like they should work for all
platforms. Then, the sysdeps directory would add the wrappers that are
specifically for particular formats and the makefile code to run the tests
for those formats (so you'd end up with each such test getting run three
or four times for powerpc64le, for the default format and for each format
that's explicitlyy tested).

This has the following benefits:

* It fixes the problem that err.h functions (maybe others as well) have
zero generic test coverage, by adding some tests that do at least get
built and run everywhere. (The coverage would still be inadequate for
testing most of the semantics of those functions, but that's not your
problem to fix.)

* It makes it easy to add more -mlong-double-64 test coverage in
sysdeps/ieee754/ldbl-opt (again not your problem, except in the cases,
such as for err.h, where adding the redirections for IEEE long double also
means adding the missing redirections for -mlong-double-64), as wrapper
files and makefile logic could be added in that directory that reuse the
main test implementations outside of sysdeps.

I would also suggest that, in the cases where they don't already do so,
it's helpful for the tests of printing functions to output e.g. two long
double values from a single format string rather than just one - that
would help ensure more possible failure modes are detected (if the code
tries reading the wrong one of double and IBM long double from the
arguments, that might sometimes just happen to work when there's only a
single argument).
--
Joseph S. Myers
***@codesourcery.com
Loading...