From patchwork Tue Jun 5 22:21:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 925655 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-92915-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.eti.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="cHt5OV/5"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 410mW65BGsz9s08 for ; Wed, 6 Jun 2018 08:21:54 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=JtkcS JbgfqSB1MIuysdjo2cf9HoKp9jRQm5GKY6uLpzfVlJLHYRGTGKY6kkftztWicUwx 4ZIVYI8a6X1FCZLfZofNPWJadNiOmHNxDXs71mCE1864BOp3/0hBRTIDbVuG7m5o NIHVRoQkk3XI4Pi0F5PArLctf941XcdO4JrTw4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=3vrc41RISrZ vMPO+N7TrboyRH3s=; b=cHt5OV/5MiUBK7meXissNYAP/cAoJwkO7cSkzn9CjM2 81A4XgaALp1Nw1us0Ai1nRNULdAzU3broPTBITtoMMYpANuAMxJfedGQUHGQaW7j X9VlkOX7AGS4x0FKtzm1U1qudXblPDzDz/gpVKg5BHuVQL1TsY/P1Wu0yuQBoI1Q = Received: (qmail 50057 invoked by alias); 5 Jun 2018 22:21:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 49924 invoked by uid 89); 5 Jun 2018 22:21:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=H*r:Wed, formats, H*F:D*br X-HELO: mo19.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [RFC PATCH v2 1/3] Prepare vfprintf to use __printf_fp/__printf_fphex with float128 arg Date: Tue, 5 Jun 2018 19:21:18 -0300 Message-ID: <20180605222120.24696-2-gabriel@inconstante.eti.br> In-Reply-To: <20180605222120.24696-1-gabriel@inconstante.eti.br> References: <20180605222120.24696-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 X-ClientProxiedBy: EX3.emp.local (172.16.2.3) To EX4.emp.local (172.16.2.4) X-Ovh-Tracer-Id: 931119226902269635 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrjeeggddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu 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 07b60e3e26..a0353f76fe 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..7f2fd56049 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..fb784f538c 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) == 1) #define DO_FORTIFY ((mode_flags & PRINTF_FORTIFY) != 0) +#if __HAVE_FLOAT128_UNLIKE_LDBL +# define PARSE_FLOAT_VA_ARG_EXTENDED(INFO) \ + if (LDBL_USES_FLOAT128) \ + { \ + 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 = 1; \ + 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 From patchwork Tue Jun 5 22:21:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 925656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-92916-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.eti.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="hvE+pjWl"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 410mWN0Q2Bz9s01 for ; Wed, 6 Jun 2018 08:22:07 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=ZJkBW 1K26YJChZYLBdGQDx2+jW0pM9swb2zQeWRfzF/uHwppBoG4qyZhSL1dT5WXbUSNX Uft+9vBEV39LXLHlJ/ncjzOUIm26q7zQ9eEQOL8Wx4BaugEA7VNCUZmd8SpFFqag JpK73r2+o1ObHSr0Wb5amxsXbUR9WKrMK0+cvk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=eKuz4g/uC5F 41DC30X3/ZXVgj6s=; b=hvE+pjWlTMSp9hZLbwgE+lbvYFiUjyE5AHFc/WSXVFD ltzJHN/CSl3OMdgiG7NltOa4Hb8cylU/IVvuzDe/5vyHpALXOWO7yaOptFkAUv+P uttqvY+HBJlYddCxWfMxVgtR9RShz8xwkBUCReGbgoJk4xDaex/fuX6lNeKw+sKo = Received: (qmail 50623 invoked by alias); 5 Jun 2018 22:21:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50446 invoked by uid 89); 5 Jun 2018 22:21:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=varies, reuses, notation X-HELO: mo19.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [RFC PATCH v2 2/3] ldbl-128ibm-compat: Use __vfprintf_internal for ieee128-vfprintf on powerpc64le Date: Tue, 5 Jun 2018 19:21:19 -0300 Message-ID: <20180605222120.24696-3-gabriel@inconstante.eti.br> In-Reply-To: <20180605222120.24696-1-gabriel@inconstante.eti.br> References: <20180605222120.24696-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 X-ClientProxiedBy: EX3.emp.local (172.16.2.3) To EX4.emp.local (172.16.2.4) X-Ovh-Tracer-Id: 931963651768635075 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrjeeggddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu 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 adds a new mode mask, PRINTF_LDBL_USES_IEEE128, and code to correctly parse floating-point values from the variable arguments. Support for printing floating-point values with binary128 format is already available on powerpc64le for use by the implementation of strfromf128, thus, the new code saves 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: New file. [subdir == stdio-common] (routines): Add ieee128-vfprintf. [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: New file. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.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 | 34 +++++++++++++++ sysdeps/ieee754/ldbl-128ibm-compat/Versions | 10 +++++ .../ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c | 25 +++++++++++ .../ldbl-128ibm-compat/test-printf-ibm128.c | 1 + .../ldbl-128ibm-compat/test-printf-ieee128.c | 1 + .../ldbl-128ibm-compat/test-printf-ldbl-compat.c | 51 ++++++++++++++++++++++ .../ldbl-128ibm-compat/test-printf-ldbl-compat.sh | 42 ++++++++++++++++++ .../powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h | 8 ++++ 8 files changed, 172 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Makefile create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/Versions create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.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..87c3241622 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -0,0 +1,34 @@ +ifeq ($(subdir),stdio-common) +# Wrappers for *printf functions that take long double arguments with +# IEEE binary128 format +routines += ieee128-vfprintf + +# Printing long double values with IEEE binary128 format reuses the 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 new file mode 100644 index 0000000000..d6eaf4e649 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -0,0 +1,10 @@ +%include +%ifndef LDBL_IBM128_VERSION +% error "ldbl-128ibm-compat-abi.h must define LDBL_IBM128_VERSION" +%endif + +libc { + LDBL_IBM128_VERSION { + __ieee128_vfprintf; + } +} 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..811e6f324e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c @@ -0,0 +1,25 @@ +/* Wrapper for vfprintf. IEEE128 version. + Copyright (C) 1991-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 + . */ + +#include + +extern int +__ieee128_vfprintf (FILE *fp, const char *format, va_list ap) +{ + return __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128); +} 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 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 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..03014507b4 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c @@ -0,0 +1,51 @@ +/* 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 + . */ + +#include +#include +#include + +#include + +static void +do_test_call_varg (FILE *stream, const char *format, ...) +{ + va_list args; + + printf ("%20s", "vfprintf: "); + va_start (args, format); + vfprintf (stream, format, args); + va_end (args); + printf ("\n"); +} + +static int +do_test (void) +{ + long double ld = -1; + + /* Print in decimal notation. */ + do_test_call_varg (stdout, "%.60Lf", ld); + + /* Print in hexadecimal notation. */ + do_test_call_varg (stdout, "%.60La", ld); + + return 0; +} + +#include 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..d5a8463935 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.sh @@ -0,0 +1,42 @@ +#!/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 +# . + +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' | + vfprintf: -1.000000000000000000000000000000000000000000000000000000000000 + vfprintf: -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 From patchwork Tue Jun 5 22:21:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 925657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-92917-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.eti.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="QjMSgR+S"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 410mWd5ZLwz9s01 for ; Wed, 6 Jun 2018 08:22:21 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=LFVbX +IQnsWHKc1ioSHNr72mxG8VW+x2V6UJbDZdRm7pIRr2pRkge7Usi8LX5bk/QRovj pyncXyXao35TIddQXHyAahy6pOMSJIVv6oZnogvkH9Xhxt4sdFhK72vnD3bAKA8s /tkxLos9aASLLZuHQLOKtY2EM07SH1Ub5ENkVQ= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=qILgWEM/6p0 aUP28YcKLpsV5peg=; b=QjMSgR+SS5Ga73Al6DUJ1MSBXdr0vkf/q24ZTTS4buA QsZSfgLq5Yu2Al9u4v3oa/AgjEHCJwf/DsRVcwti4Aq9DAtzih+XOe68TA68QXXt nwZGGvZEnkMKtpbTKeZlbCpOfuQvIfxY9/bOA0Xz1Kx2MqxvS1dT2p7Fs93YFQTk = Received: (qmail 51389 invoked by alias); 5 Jun 2018 22:21:49 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50936 invoked by uid 89); 5 Jun 2018 22:21:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=wishes X-HELO: mo20.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [RFC PATCH v2 3/3] RFC: powerpc64le: Convert default long double format to IEEE binary128 Date: Tue, 5 Jun 2018 19:21:20 -0300 Message-ID: <20180605222120.24696-4-gabriel@inconstante.eti.br> In-Reply-To: <20180605222120.24696-1-gabriel@inconstante.eti.br> References: <20180605222120.24696-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 X-ClientProxiedBy: EX3.emp.local (172.16.2.3) To EX4.emp.local (172.16.2.4) X-Ovh-Tracer-Id: 933371022916112067 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrjeeggddutdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu Do not commit! A commit similar to this would be added only when all other changes are ready, but without the temporary header redirections (explained below). I'm sending this in the RFC in case someone wishes to test the previous patches. A note about temporary header redirections: On powerpc64le, the implementation of long double with IEEE binary128 format is not complete. The redirections of the stdio.h functions are supposed to be implemented in bits/stdio-ldbl.h, however, we can only redirect all or none. In the meantime, bits/stdio-ieee128.h allows us to redirect part of them for testing purposes. */ --- libio/stdio.h | 13 ++++++++ sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 9 +++++ .../ldbl-128ibm-compat/bits/stdio-ieee128.h | 38 ++++++++++++++++++++++ sysdeps/powerpc/powerpc64/le/Implies-before | 1 + .../sysv/linux/powerpc/powerpc64/libc-le.abilist | 1 + 5 files changed, 62 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/bits/stdio-ieee128.h diff --git a/libio/stdio.h b/libio/stdio.h index 731f8e56f4..002f2ef33b 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -864,6 +864,19 @@ extern int __overflow (FILE *, int); # include #endif +/* XXX: DO NOT COMMIT. + + On powerpc64le, the implementation of long double with IEEE binary128 + format is not complete. The redirections of the stdio.h functions + are supposed to be implemented in bits/stdio-ldbl.h, however, we can + only redirect all or none. In the meantime, bits/stdio-ieee128.h + allows us to redirect part of them for testing purposes. */ +#include +#if __HAVE_DISTINCT_FLOAT128 && __LDBL_MANT_DIG__ == 113 && \ + ! defined __BUILDING_EXTRA_LDBL_FORMAT +# include +#endif + __END_DECLS #endif /* included. */ diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 87c3241622..ad82b42585 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -31,4 +31,13 @@ $(objpfx)test-printf-ibm128.out: \ $(objpfx)test-printf-ibm128 $(SHELL) $^ '$(test-program-prefix)' $@; \ $(evaluate-test) + +# XXX: DO NOT COMMIT. +# +# On powerpc64le, the implementation of long double with IEEE binary128 +# format is not complete. The redirections of the stdio.h functions +# are supposed to be implemented in bits/stdio-ldbl.h, however, we can +# only redirect all or none. In the meantime, bits/stdio-ieee128.h +# allows us to redirect part of them for testing purposes. */ +headers += bits/stdio-ieee128.h endif diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/bits/stdio-ieee128.h b/sysdeps/ieee754/ldbl-128ibm-compat/bits/stdio-ieee128.h new file mode 100644 index 0000000000..f3fa782a78 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/bits/stdio-ieee128.h @@ -0,0 +1,38 @@ +/* Redirections for stdio functions for -mabi=ieeelongdouble. + 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 + . */ + +/* XXX: DO NOT COMMIT. + + On powerpc64le, the implementation of long double with IEEE binary128 + format is not complete. The redirections of the stdio.h functions + are supposed to be implemented in bits/stdio-ldbl.h, however, we can + only redirect all or none. In the meantime, bits/stdio-ieee128.h + allows us to redirect part of them for testing purposes. */ + +#ifndef _STDIO_H +# error "Never include directly; use instead." +#endif + +#include + +#define __IBM128_REDIR(name) \ + extern __typeof (name) __ieee128_##name; \ + extern __typeof (name) name __asm (__ASMNAME ("__ieee128_" #name)); + +__IBM128_REDIR (vfprintf) +/* To be completed with the other functions. */ diff --git a/sysdeps/powerpc/powerpc64/le/Implies-before b/sysdeps/powerpc/powerpc64/le/Implies-before index 7c20db4e97..2139f4dae8 100644 --- a/sysdeps/powerpc/powerpc64/le/Implies-before +++ b/sysdeps/powerpc/powerpc64/le/Implies-before @@ -1,4 +1,5 @@ # On PowerPC we use the IBM extended long double format. +ieee754/ldbl-128ibm-compat ieee754/ldbl-128ibm ieee754/ldbl-opt ieee754/dbl-64 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist index 9869feb56b..d8e028ed13 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist @@ -2221,3 +2221,4 @@ GLIBC_2.27 wcstof64 F GLIBC_2.27 wcstof64_l F GLIBC_2.27 wcstof64x F GLIBC_2.27 wcstof64x_l F +GLIBC_2.28 __ieee128_vfprintf F