[PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions
Paul E Murphy
murphyp@linux.ibm.com
Tue Oct 29 15:42:00 GMT 2019
On 10/25/19 10:33 AM, Gabriel F. T. Gomes wrote:
> From: "Gabriel F. T. Gomes" <gabrielftg@linux.ibm.com>
>
> No changes since v1.
>
> -- 8< --
> The 'mode' argument to __vfprintf_internal allows the selection of the
> long double format for all long double arguments requested by the format
> string. Currently, there are two possibilities: long double with the
> same format as double or long double as something else. The 'something
> else' format varies between architectures, and on powerpc64le, it means
> IBM Extended Precision format.
>
> In preparation for the third option of long double format on
> powerpc64le, this patch uses the new mode mask,
> PRINTF_LDBL_USES_FLOAT128, which tells __vfprintf_internal to save the
> floating-point values into variables of type __float128 and adjusts the
> parameters to __printf_fp and __printf_fphex as if it was a call from
> strfromf128.
>
> Many files from the stdio-common, wcsmbs, argp, misc, and libio
> directories will have IEEE binary128 counterparts. Setting the correct
> compiler options to these files (original and counterparts) would
> produce a large amount of repetitive Makefile rules. To avoid this
> repetition, this patch adds a Makefile routine that iterates over the
> files adding or removing the appropriate flags.
>
> Tested for powerpc64le.
> ---
> elf/tst-addr1.c | 7 +-
> sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 47 ++++-
> sysdeps/ieee754/ldbl-128ibm-compat/Versions | 15 ++
> .../ldbl-128ibm-compat/ieee128-asprintf.c | 35 ++++
> .../ldbl-128ibm-compat/ieee128-dprintf.c | 34 ++++
> .../ldbl-128ibm-compat/ieee128-fprintf.c | 34 ++++
> .../ldbl-128ibm-compat/ieee128-printf.c | 35 ++++
> .../ldbl-128ibm-compat/ieee128-snprintf.c | 35 ++++
> .../ldbl-128ibm-compat/ieee128-sprintf.c | 35 ++++
> .../ldbl-128ibm-compat/ieee128-vasprintf.c | 27 +++
> .../ldbl-128ibm-compat/ieee128-vdprintf.c | 26 +++
> .../ldbl-128ibm-compat/ieee128-vfprintf.c | 26 +++
> .../ldbl-128ibm-compat/ieee128-vprintf.c | 27 +++
> .../ldbl-128ibm-compat/ieee128-vsnprintf.c | 28 +++
> .../ldbl-128ibm-compat/ieee128-vsprintf.c | 27 +++
> .../ldbl-128ibm-compat/test-printf-ibm128.c | 1 +
> .../ldbl-128ibm-compat/test-printf-ieee128.c | 1 +
> .../test-printf-ldbl-compat.c | 171 ++++++++++++++++++
> .../powerpc64/le/ldbl-128ibm-compat-abi.h | 8 +
> 19 files changed, 617 insertions(+), 2 deletions(-)
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
> create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
> create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
>
> diff --git a/elf/tst-addr1.c b/elf/tst-addr1.c
> index 68ff74aabd..ee81acda5b 100644
> --- a/elf/tst-addr1.c
> +++ b/elf/tst-addr1.c
> @@ -19,7 +19,12 @@ do_test (void)
> rather than in the binary. printf and _IO_printf
> are aliased and which one comes first in the
> hash table is up to the linker. */
> - && strcmp (i.dli_sname, "_IO_printf") != 0);
> + && strcmp (i.dli_sname, "_IO_printf") != 0
> + /* On architectures where long double with IEEE binary128
> + format is available as a third option (initially, true
> + for powerpc64le), printf may be redirected to
> + __printfieee128. */
> + && strcmp (i.dli_sname, "__printfieee128") != 0);
Should there be a guard against this test for architectures which will
never support this symbol?
> }
>
> #include <support/test-driver.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> index 412beb5b5c..89059f37e2 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile
OK, those make rules take a little time to digest.
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> index 4aa34dbe59..6a27befed2 100644
> --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions
OK. This seems to be the accepted approach to expose the new ieee128 ABI.
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c
... the ieee128-*printf.c wrappers all look OK.
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
> new file mode 100644
> index 0000000000..5de4ea3e7f
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c
> @@ -0,0 +1 @@
> +#include <test-printf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
> new file mode 100644
> index 0000000000..5de4ea3e7f
> --- /dev/null
> +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c
> @@ -0,0 +1 @@
> +#include <test-printf-ldbl-compat.c>
> diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
...
> + long double ld = -1;
Is this the best value to use for compat tests? Would a value which
produces unique output for the respective format if the wrong compiler
flags are used? Or, maybe an extra header in *-ibm128.c and *-ieee128.c
variants to sanity check __LDBL_MANT_DIG__?
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
> new file mode 100644
> index 0000000000..285216b231
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h
> @@ -0,0 +1,8 @@
> +/* ABI version for long double switch to IEEE 128-bit floating point..
> + This is used by the Versions and math_ldbl_opt.h files in
> + sysdeps/ieee754/ldbl-128ibm-compat/. It gives the ABI version where
> + long double == ibm128 was replaced with long double == _Float128
> + for libm *l functions and libc functions using long double. */
> +
> +#define LDBL_IBM128_VERSION GLIBC_2.31
> +#define LDBL_IBM128_COMPAT_VERSION GLIBC_2_31
>
Should this part of the change be held off until all ldbl == ieee128
changes are in?
More information about the Libc-alpha
mailing list