From patchwork Fri Oct 25 15:33:41 2019 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: 1184237 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106309-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="aCATm3ZB"; 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 4707TG6rp1z9sQn for ; Sat, 26 Oct 2019 02:34:42 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=EOSPAPgOGZwMgTiaE17SlPfTPU1J1EPJQh4jm29QF8J NJzcVmomt0c/nIRkPPAjVKORRKte2Bb6eRzhCtB41v5ofFL7eILQy/YgFpYsK37A eyKKpo19F1sEoLuPe2bZaCHs4Op/Tj+NNae+SZQfTFC5TbyBOmPb+zir1zCb/tDQ = 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-transfer-encoding:content-type; s=default; bh=91ScvZW9owe9dlNlVcQoogo+m3w=; b=aCATm3ZBfVwZOPmvM 1oY0b2oRw33N2SHqpyM5j7wWaSutzhcXx9zRPeV+5uc2F2TXVklaA+QCFqgYJ163 AXWLdty7ena2PA1afyhcKrJKaq1l0uvon+rLdGkfgJVrNTlK2+E1isL43tZGQuzJ siwV5qZwO9RmH4nHb+dvvk5DqI= Received: (qmail 101446 invoked by alias); 25 Oct 2019 15:34:35 -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 101380 invoked by uid 89); 25 Oct 2019 15:34:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=varies, _Float128, _float128 X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 01/30] ldbl-128ibm-compat: Add regular character printing functions Date: Fri, 25 Oct 2019 12:33:41 -0300 Message-ID: <20191025153410.15405-2-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1585267071261134531 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- The 'mode' argument to __vfprintf_internal allows the selection of the long double format for all long double arguments requested by the format string. Currently, there are two possibilities: long double with the same format as double or long double as something else. The 'something else' format varies between architectures, and on powerpc64le, it means IBM Extended Precision format. In preparation for the third option of long double format on powerpc64le, this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, which tells __vfprintf_internal to save the floating-point values into variables of type __float128 and adjusts the parameters to __printf_fp and __printf_fphex as if it was a call from strfromf128. Many files from the stdio-common, wcsmbs, argp, misc, and libio directories will have IEEE binary128 counterparts. Setting the correct compiler options to these files (original and counterparts) would produce a large amount of repetitive Makefile rules. To avoid this repetition, this patch adds a Makefile routine that iterates over the files adding or removing the appropriate flags. Tested for powerpc64le. --- elf/tst-addr1.c | 7 +- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 47 ++++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 15 ++ .../ldbl-128ibm-compat/ieee128-asprintf.c | 35 ++++ .../ldbl-128ibm-compat/ieee128-dprintf.c | 34 ++++ .../ldbl-128ibm-compat/ieee128-fprintf.c | 34 ++++ .../ldbl-128ibm-compat/ieee128-printf.c | 35 ++++ .../ldbl-128ibm-compat/ieee128-snprintf.c | 35 ++++ .../ldbl-128ibm-compat/ieee128-sprintf.c | 35 ++++ .../ldbl-128ibm-compat/ieee128-vasprintf.c | 27 +++ .../ldbl-128ibm-compat/ieee128-vdprintf.c | 26 +++ .../ldbl-128ibm-compat/ieee128-vfprintf.c | 26 +++ .../ldbl-128ibm-compat/ieee128-vprintf.c | 27 +++ .../ldbl-128ibm-compat/ieee128-vsnprintf.c | 28 +++ .../ldbl-128ibm-compat/ieee128-vsprintf.c | 27 +++ .../ldbl-128ibm-compat/test-printf-ibm128.c | 1 + .../ldbl-128ibm-compat/test-printf-ieee128.c | 1 + .../test-printf-ldbl-compat.c | 171 ++++++++++++++++++ .../powerpc64/le/ldbl-128ibm-compat-abi.h | 8 + 19 files changed, 617 insertions(+), 2 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c create mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc64/le/ldbl-128ibm-compat-abi.h diff --git a/elf/tst-addr1.c b/elf/tst-addr1.c index 68ff74aabd..ee81acda5b 100644 --- a/elf/tst-addr1.c +++ b/elf/tst-addr1.c @@ -19,7 +19,12 @@ do_test (void) rather than in the binary. printf and _IO_printf are aliased and which one comes first in the hash table is up to the linker. */ - && strcmp (i.dli_sname, "_IO_printf") != 0); + && strcmp (i.dli_sname, "_IO_printf") != 0 + /* On architectures where long double with IEEE binary128 + format is available as a third option (initially, true + for powerpc64le), printf may be redirected to + __printfieee128. */ + && strcmp (i.dli_sname, "__printfieee128") != 0); } #include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 412beb5b5c..89059f37e2 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -1,5 +1,30 @@ ifeq ($(subdir),stdio-common) -routines += ieee128-printf_size +ldbl-extra-routines += printf_size \ + asprintf \ + dprintf \ + fprintf \ + printf \ + snprintf \ + sprintf \ + vasprintf \ + vdprintf \ + vfprintf \ + vprintf \ + vsnprintf \ + vsprintf + +# Printing long double values with IEEE binary128 format reuses part +# of the internal float128 implementation (__printf_fp, __printf_fphex, +# and __float128 variables and union members). Thus, the compilation of +# the following functions, must have -mfloat128 and -mabi=ibmlongdouble +# passed to the compiler. +CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble + +# Basic tests for the implementation of long double with IEEE binary128 +# format and for the related redirections in installed headers. +tests-internal += test-printf-ieee128 test-printf-ibm128 +CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi tests-internal += test-printf-size-ieee128 test-printf-size-ibm128 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi @@ -20,3 +45,23 @@ $(objpfx)test-printf-size-ibm128.out: \ $(SHELL) $^ '$(test-program-prefix)' $@; \ $(evaluate-test) endif + +# Add IEEE binary128 files as make targets. +routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) + +# On powerpc64le, the routines responsible for converting between long +# double and string (e.g.: printf, scanf, strtold, strfroml) default to +# IBM long double mode. When support for TS 18661-3 was added, several +# internal functions were modified so that they could also handle +# floating-point variables with IEEE binary128 format, but as an +# additional type, _Float128. +# +# The following rule ensures that the string conversion routines will +# always be built in IBM long double mode, with additional support for +# IEEE binary128, through the use of -mabi=ibmlongdouble and -mfloat128. +ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \ + $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \ + $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^) +obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1))) +$(call obj-suf-foreach,$(ldbl-ibm128-files)): \ + sysdep-CFLAGS += -mabi=ibmlongdouble diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 4aa34dbe59..6a27befed2 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -120,4 +120,19 @@ libc { __wcstoieee128_l; __printf_sizeieee128; + + __asprintfieee128; + __dprintfieee128; + __fprintfieee128; + __printfieee128; + __snprintfieee128; + __sprintfieee128; + + __vasprintfieee128; + __vdprintfieee128; + __vfprintfieee128; + __vprintfieee128; + __vsnprintfieee128; + __vsprintfieee128; } +} diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c new file mode 100644 index 0000000000..35c909b124 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf.c @@ -0,0 +1,35 @@ +/* Wrapper for asprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_asprintf (char **string_ptr, const char *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vasprintf_internal (string_ptr, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_asprintf, __asprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c new file mode 100644 index 0000000000..0c66c9758b --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf.c @@ -0,0 +1,34 @@ +/* Wrapper for dprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_dprintf (int d, const char *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vdprintf_internal (d, format, ap, PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_dprintf, __dprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c new file mode 100644 index 0000000000..b4b945092a --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf.c @@ -0,0 +1,34 @@ +/* Wrapper for fprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_fprintf (FILE *fp, const char *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_fprintf, __fprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c new file mode 100644 index 0000000000..a1c6d7e0cf --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf.c @@ -0,0 +1,35 @@ +/* Wrapper for printf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_printf (const char *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vfprintf_internal (stdout, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_printf, __printfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c new file mode 100644 index 0000000000..2c09a75d59 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf.c @@ -0,0 +1,35 @@ +/* Wrapper for snprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_snprintf (char *s, size_t maxlen, const char *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vsnprintf_internal (s, maxlen, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_snprintf, __snprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c new file mode 100644 index 0000000000..727a403634 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf.c @@ -0,0 +1,35 @@ +/* Wrapper for sprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_sprintf (char *s, const char *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vsprintf_internal (s, -1, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_sprintf, __sprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c new file mode 100644 index 0000000000..650e40affb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf.c @@ -0,0 +1,27 @@ +/* Wrapper for vasprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vasprintf (char **result_ptr, const char *format, va_list ap) +{ + return __vasprintf_internal (result_ptr, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vasprintf, __vasprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c new file mode 100644 index 0000000000..88fbb3743d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf.c @@ -0,0 +1,26 @@ +/* Wrapper for vdprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vdprintf (int d, const char *format, va_list ap) +{ + return __vdprintf_internal (d, format, ap, PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vdprintf, __vdprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c new file mode 100644 index 0000000000..ecc2fd36da --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf.c @@ -0,0 +1,26 @@ +/* Wrapper for vfprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vfprintf (FILE *fp, const char *format, va_list ap) +{ + return __vfprintf_internal (fp, format, ap, PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vfprintf, __vfprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c new file mode 100644 index 0000000000..35347c60be --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf.c @@ -0,0 +1,27 @@ +/* Wrapper for vprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vprintf (const char *format, va_list ap) +{ + return __vfprintf_internal (stdout, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vprintf, __vprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c new file mode 100644 index 0000000000..963b0cb228 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf.c @@ -0,0 +1,28 @@ +/* Wrapper for vsnprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vsnprintf (char *string, size_t maxlen, const char *format, + va_list ap) +{ + return __vsnprintf_internal (string, maxlen, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vsnprintf, __vsnprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c new file mode 100644 index 0000000000..822cc31c16 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf.c @@ -0,0 +1,27 @@ +/* Wrapper for vsprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +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 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..939a6aad9c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c @@ -0,0 +1,171 @@ +/* Test for the long double variants of *printf functions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include +#include + +static void +do_test_call_varg (FILE *stream, const char *format, ...) +{ + char *buffer = NULL; + char string[128]; + va_list args; + + printf ("%15s", "vasprintf: "); + va_start (args, format); + vasprintf (&buffer, format, args); + va_end (args); + if (buffer == NULL) + printf ("Error using vasprintf\n"); + else + { + printf ("%s", buffer); + free (buffer); + } + printf ("\n"); + + printf ("%15s", "vdprintf: "); + va_start (args, format); + vdprintf (fileno (stream), format, args); + va_end (args); + printf ("\n"); + + printf ("%15s", "vfprintf: "); + va_start (args, format); + vfprintf (stream, format, args); + va_end (args); + printf ("\n"); + + printf ("%15s", "vprintf: "); + va_start (args, format); + vprintf (format, args); + va_end (args); + printf ("\n"); + + printf ("%15s", "vsnprintf: "); + va_start (args, format); + vsnprintf (string, 127, format, args); + va_end (args); + printf ("%s", string); + printf ("\n"); + + printf ("%15s", "vsprintf: "); + va_start (args, format); + vsprintf (string, format, args); + va_end (args); + printf ("%s", string); + printf ("\n"); +} + +static void +do_test_call_rarg (FILE *stream, const char *format, long double ld) +{ + char *buffer = NULL; + char string[128]; + + printf ("%15s", "asprintf: "); + asprintf (&buffer, format, ld); + if (buffer == NULL) + printf ("Error using asprintf\n"); + else + { + printf ("%s", buffer); + free (buffer); + } + printf ("\n"); + + printf ("%15s", "dprintf: "); + dprintf (fileno (stream), format, ld); + printf ("\n"); + + printf ("%15s", "fprintf: "); + fprintf (stream, format, ld); + printf ("\n"); + + printf ("%15s", "printf: "); + printf (format, ld); + printf ("\n"); + + printf ("%15s", "snprintf: "); + snprintf (string, 127, format, ld); + printf ("%s", string); + printf ("\n"); + + printf ("%15s", "sprintf: "); + sprintf (string, format, ld); + printf ("%s", string); + printf ("\n"); +} + +static void +do_test_call (void) +{ + long double ld = -1; + + /* Print in decimal notation. */ + do_test_call_rarg (stdout, "%.10Lf", ld); + do_test_call_varg (stdout, "%.10Lf", ld); + + /* Print in hexadecimal notation. */ + do_test_call_rarg (stdout, "%.10La", ld); + do_test_call_varg (stdout, "%.10La", ld); +} + +static int +do_test (void) +{ + struct support_capture_subprocess result; + result = support_capture_subprocess ((void *) &do_test_call, NULL); + + /* Compare against the expected output. */ + const char *expected = + " asprintf: -1.0000000000\n" + " dprintf: -1.0000000000\n" + " fprintf: -1.0000000000\n" + " printf: -1.0000000000\n" + " snprintf: -1.0000000000\n" + " sprintf: -1.0000000000\n" + " vasprintf: -1.0000000000\n" + " vdprintf: -1.0000000000\n" + " vfprintf: -1.0000000000\n" + " vprintf: -1.0000000000\n" + " vsnprintf: -1.0000000000\n" + " vsprintf: -1.0000000000\n" + " asprintf: -0x1.0000000000p+0\n" + " dprintf: -0x1.0000000000p+0\n" + " fprintf: -0x1.0000000000p+0\n" + " printf: -0x1.0000000000p+0\n" + " snprintf: -0x1.0000000000p+0\n" + " sprintf: -0x1.0000000000p+0\n" + " vasprintf: -0x1.0000000000p+0\n" + " vdprintf: -0x1.0000000000p+0\n" + " vfprintf: -0x1.0000000000p+0\n" + " vprintf: -0x1.0000000000p+0\n" + " vsnprintf: -0x1.0000000000p+0\n" + " vsprintf: -0x1.0000000000p+0\n"; + TEST_COMPARE_STRING (expected, result.out.buffer); + + return 0; +} + +#include 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 From patchwork Fri Oct 25 15:33:42 2019 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: 1184239 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106310-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="elAKfSXe"; 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 4707TW6MCgz9sQq for ; Sat, 26 Oct 2019 02:34:55 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=R++opY+5ltRrw17Chmj2BSMBwdgYMIQY67Lm6hp9XgO rSme8vbSr+Po6ZTgDIjbClIqY3GTTmx71atoZpsW6gGLeb/u/mnyCiTV+F0ytrqk GF5WUMXqmE0elSthzM0PMfwKW27BNd7Q5IkEPNmqlop0met01nXiSafGzYx1hnb4 = 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-transfer-encoding:content-type; s=default; bh=Ox+AUdMqGD13nd6qvp3B+KR7iTY=; b=elAKfSXeu0Nup8VZX lvd/dwjlyEODDRVivKA52sVtSeZn+6gmn5HtWMA9ln5EfX+/74XcAcF5uk8Yydg8 srnYH8B8duenY6A5qhlsK6BqsArouFOWjcU/hjLlKL7LEz2XgQyPb+A3d8TkFe1D yL9sWS05pfreNdgafyLYzNe7GY= Received: (qmail 102410 invoked by alias); 25 Oct 2019 15:34:42 -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 102344 invoked by uid 89); 25 Oct 2019 15:34:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 02/30] ldbl-128ibm-compat: Add wide character printing functions Date: Fri, 25 Oct 2019 12:33:42 -0300 Message-ID: <20191025153410.15405-3-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1588644768669093571 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Similarly to what was done for regular character printing functions, this patch uses the new mode mask, PRINTF_LDBL_USES_FLOAT128, in the 'mode' argument of the wide characters printing function, __vfwprintf_internal (which is also extended to support printing floating-point values with IEEE binary128, by saving floating-point values into variables of type __float128 and adjusting the parameters to __printf_fp and __printf_fphex as if it was a call from a wide-character version of strfromf128 (even though such version does not exist)). Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 13 +- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++ .../ldbl-128ibm-compat/ieee128-fwprintf.c | 35 ++++++ .../ldbl-128ibm-compat/ieee128-swprintf.c | 36 ++++++ .../ldbl-128ibm-compat/ieee128-vfwprintf.c | 27 +++++ .../ldbl-128ibm-compat/ieee128-vswprintf.c | 28 +++++ .../ldbl-128ibm-compat/ieee128-vwprintf.c | 27 +++++ .../ldbl-128ibm-compat/ieee128-wprintf.c | 35 ++++++ .../ldbl-128ibm-compat/test-wprintf-ibm128.c | 1 + .../ldbl-128ibm-compat/test-wprintf-ieee128.c | 1 + .../test-wprintf-ldbl-compat.c | 111 ++++++++++++++++++ 11 files changed, 321 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 89059f37e2..0f2f58d5b9 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -11,7 +11,13 @@ ldbl-extra-routines += printf_size \ vfprintf \ vprintf \ vsnprintf \ - vsprintf + vsprintf \ + fwprintf \ + swprintf \ + wprintf \ + vfwprintf \ + vswprintf \ + vwprintf # Printing long double values with IEEE binary128 format reuses part # of the internal float128 implementation (__printf_fp, __printf_fphex, @@ -19,6 +25,7 @@ ldbl-extra-routines += printf_size \ # the following functions, must have -mfloat128 and -mabi=ibmlongdouble # passed to the compiler. CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble +CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble # Basic tests for the implementation of long double with IEEE binary128 # format and for the related redirections in installed headers. @@ -26,6 +33,10 @@ tests-internal += test-printf-ieee128 test-printf-ibm128 CFLAGS-test-printf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-printf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +tests-internal += test-wprintf-ieee128 test-wprintf-ibm128 +CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + tests-internal += test-printf-size-ieee128 test-printf-size-ibm128 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 6a27befed2..0485a2b5d4 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -134,5 +134,13 @@ libc { __vprintfieee128; __vsnprintfieee128; __vsprintfieee128; + + __fwprintfieee128; + __swprintfieee128; + __wprintfieee128; + + __vfwprintfieee128; + __vswprintfieee128; + __vwprintfieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c new file mode 100644 index 0000000000..4b350a6e0b --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf.c @@ -0,0 +1,35 @@ +/* Wrapper for fwprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_fwprintf (FILE *fp, const wchar_t *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vfwprintf_internal (fp, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_fwprintf, __fwprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c new file mode 100644 index 0000000000..4fb40e3c42 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf.c @@ -0,0 +1,36 @@ +/* Wrapper for swprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_swprintf (wchar_t *string, size_t maxlen, + const wchar_t *format, ...) +{ + va_list ap; + int done; + + va_start (ap, format); + done = __vswprintf_internal (string, maxlen, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + + return done; +} +strong_alias (___ieee128_swprintf, __swprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c new file mode 100644 index 0000000000..757f4b31a8 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf.c @@ -0,0 +1,27 @@ +/* Wrapper for vfwprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vfwprintf (FILE *fp, const wchar_t *format, va_list ap) +{ + return __vfwprintf_internal (fp, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vfwprintf, __vfwprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c new file mode 100644 index 0000000000..9bb36cfae9 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf.c @@ -0,0 +1,28 @@ +/* Wrapper for vswprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vswprintf (wchar_t *string, size_t maxlen, + const wchar_t *format, va_list ap) +{ + return __vswprintf_internal (string, maxlen, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vswprintf, __vswprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c new file mode 100644 index 0000000000..44ec37e24f --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf.c @@ -0,0 +1,27 @@ +/* Wrapper for vwprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vwprintf (const wchar_t *format, va_list ap) +{ + return __vfwprintf_internal (stdout, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vwprintf, __vwprintfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c new file mode 100644 index 0000000000..c949f328c2 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf.c @@ -0,0 +1,35 @@ +/* Wrapper for wprintf. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +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 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 diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c new file mode 100644 index 0000000000..71edfec235 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c @@ -0,0 +1,111 @@ +/* Test for the long double variants of *w*printf functions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +#include +#include + +static void +do_test_call_varg (FILE *stream, const wchar_t *format, ...) +{ + wchar_t string[128]; + va_list args; + + wprintf (L"%15Ls", L"vfwprintf: "); + va_start (args, format); + vfwprintf (stream, format, args); + va_end (args); + wprintf (L"\n"); + + wprintf (L"%15Ls", L"vswprintf: "); + va_start (args, format); + vswprintf (string, 127, format, args); + va_end (args); + wprintf (L"%Ls", string); + wprintf (L"\n"); + + wprintf (L"%15Ls", L"vwprintf: "); + va_start (args, format); + vwprintf (format, args); + va_end (args); + wprintf (L"\n"); +} + +static void +do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld) +{ + wchar_t string[128]; + + wprintf (L"%15Ls", L"fwprintf: "); + fwprintf (stream, format, ld); + wprintf (L"\n"); + + wprintf (L"%15Ls", L"swprintf: "); + swprintf (string, 127, format, ld); + wprintf (L"%Ls", string); + wprintf (L"\n"); + + wprintf (L"%15Ls", L"wprintf: "); + wprintf (format, ld); + wprintf (L"\n"); +} + +static void +do_test_call (void) +{ + long double ld = -1; + + /* Print in decimal notation. */ + do_test_call_rarg (stdout, L"%.10Lf", ld); + do_test_call_varg (stdout, L"%.10Lf", ld); + + /* Print in hexadecimal notation. */ + do_test_call_rarg (stdout, L"%.10La", ld); + do_test_call_varg (stdout, L"%.10La", ld); +} + +static int +do_test (void) +{ + struct support_capture_subprocess result; + result = support_capture_subprocess ((void *) &do_test_call, NULL); + + /* Compare against the expected output. */ + const char *expected = + " fwprintf: -1.0000000000\n" + " swprintf: -1.0000000000\n" + " wprintf: -1.0000000000\n" + " vfwprintf: -1.0000000000\n" + " vswprintf: -1.0000000000\n" + " vwprintf: -1.0000000000\n" + " fwprintf: -0x1.0000000000p+0\n" + " swprintf: -0x1.0000000000p+0\n" + " wprintf: -0x1.0000000000p+0\n" + " vfwprintf: -0x1.0000000000p+0\n" + " vswprintf: -0x1.0000000000p+0\n" + " vwprintf: -0x1.0000000000p+0\n"; + TEST_COMPARE_STRING (expected, result.out.buffer); + + return 0; +} + +#include From patchwork Fri Oct 25 15:33:43 2019 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: 1184240 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106311-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="nabTF5fO"; 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 4707Tq5g8xz9sQm for ; Sat, 26 Oct 2019 02:35:11 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=H1Ij5QGLTUBXOgrqneK5yw2E8lTD6LOV8+eUG5SpjhL B86Zn9WHSqhQg8KZ82bsAH5SKGRvGPPbmT2jOF2nnGFtFM6KC5EmfsdZavdqJ0V+ BRPKw5pD98zGIyzcexClP5nMY95RcT24LDaQR2nRwNeIe/bdut0Ve1n+0O6IPlTU = 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-transfer-encoding:content-type; s=default; bh=O8kOzVPDwoh4s79zU9C6a6CnGVk=; b=nabTF5fOUq7Eph6+R 1XAb2PZ6JDyCLnLd0lS5LpNla8pYnUDRWJLOFzzqqxPiBjxbuN6yHZ9Af2aVNGv2 jZS0V45L32NL0UKsDTx5k/IbnGJcvLbQd8PXEWneeQwA275osbXwKeLwnSmGOnOE PwFkz6drKPP6DtK1/6D6WpPPak= Received: (qmail 103659 invoked by alias); 25 Oct 2019 15:34:53 -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 103563 invoked by uid 89); 25 Oct 2019 15:34:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 03/30] ldbl-128ibm-compat: Add regular character, fortified printing functions Date: Fri, 25 Oct 2019 12:33:43 -0300 Message-ID: <20191025153410.15405-4-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1590333618664558275 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Since the introduction of internal functions with explicit flags for the printf family of functions, the 'mode' parameter can be used to select which format long double parameters have (with the mode flags: PRINTF_LDBL_IS_DBL and PRINTF_LDBL_USES_FLOAT128), as well as to select whether to check for overflows (mode flag: PRINTF_FORTIFY). This patch combines PRINTF_LDBL_USES_FLOAT128 and PRINTF_FORTIFY to provide the IEEE binary128 version of printf-like function for platforms where long double can take this format, in addition to the double format and to some non-ieee format (currently, this means powerpc64le). There are two flavors of test cases provided with this patch: one that explicitly calls the fortified functions, for instance __asprintf_chk, and another that reuses the non-fortified test, but defining _FORTIFY_SOURCE as 2. The first guarantees that the implementations are actually being tested (in bits/stdio2.h, vprintf gets redirected to __vfprintf_chk, which would leave __vprintf_chk untested), whereas the second guarantees that the redirections calls the correct function in the IBM and IEEE long double cases. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 25 +++ sysdeps/ieee754/ldbl-128ibm-compat/Versions | 14 ++ .../ldbl-128ibm-compat/ieee128-asprintf_chk.c | 38 ++++ .../ldbl-128ibm-compat/ieee128-dprintf_chk.c | 38 ++++ .../ldbl-128ibm-compat/ieee128-fprintf_chk.c | 38 ++++ .../ldbl-128ibm-compat/ieee128-printf_chk.c | 38 ++++ .../ldbl-128ibm-compat/ieee128-snprintf_chk.c | 42 ++++ .../ldbl-128ibm-compat/ieee128-sprintf_chk.c | 42 ++++ .../ieee128-vasprintf_chk.c | 31 +++ .../ldbl-128ibm-compat/ieee128-vdprintf_chk.c | 30 +++ .../ldbl-128ibm-compat/ieee128-vfprintf_chk.c | 30 +++ .../ldbl-128ibm-compat/ieee128-vprintf_chk.c | 30 +++ .../ieee128-vsnprintf_chk.c | 34 ++++ .../ldbl-128ibm-compat/ieee128-vsprintf_chk.c | 34 ++++ .../test-printf-chk-ibm128.c | 1 + .../test-printf-chk-ieee128.c | 1 + .../test-printf-chk-ldbl-compat.c | 179 ++++++++++++++++++ .../test-printf-chk-redir-ibm128.c | 2 + .../test-printf-chk-redir-ieee128.c | 2 + 19 files changed, 649 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 0f2f58d5b9..21056e38da 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -57,6 +57,31 @@ $(objpfx)test-printf-size-ibm128.out: \ $(evaluate-test) endif +ifeq ($(subdir),debug) +ldbl-extra-routines += asprintf_chk \ + dprintf_chk \ + fprintf_chk \ + printf_chk \ + snprintf_chk \ + sprintf_chk \ + vasprintf_chk \ + vdprintf_chk \ + vfprintf_chk \ + vprintf_chk \ + vsnprintf_chk \ + vsprintf_chk + +tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128 +CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-printf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +tests-internal += test-printf-chk-redir-ieee128 test-printf-chk-redir-ibm128 +CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \ + -Wno-psabi -Wno-unused-result +CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + -Wno-unused-result +endif + # Add IEEE binary128 files as make targets. routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 0485a2b5d4..aac08a3ad3 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -142,5 +142,19 @@ libc { __vfwprintfieee128; __vswprintfieee128; __vwprintfieee128; + + __asprintf_chkieee128; + __dprintf_chkieee128; + __fprintf_chkieee128; + __printf_chkieee128; + __snprintf_chkieee128; + __sprintf_chkieee128; + + __vasprintf_chkieee128; + __vdprintf_chkieee128; + __vfprintf_chkieee128; + __vprintf_chkieee128; + __vsnprintf_chkieee128; + __vsprintf_chkieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c new file mode 100644 index 0000000000..149fc046b6 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-asprintf_chk.c @@ -0,0 +1,38 @@ +/* Wrapper for __asprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_asprintf_chk (char **string_ptr, int flag, const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, format); + done = __vasprintf_internal (string_ptr, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_asprintf_chk, __asprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c new file mode 100644 index 0000000000..724fb0bd43 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-dprintf_chk.c @@ -0,0 +1,38 @@ +/* Wrapper for __dprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_dprintf_chk (int d, int flag, const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, format); + done = __vdprintf_internal (d, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_dprintf_chk, __dprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c new file mode 100644 index 0000000000..fc15b0bfbd --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fprintf_chk.c @@ -0,0 +1,38 @@ +/* Wrapper for __fprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_fprintf_chk (FILE *fp, int flag, const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, format); + done = __vfprintf_internal (fp, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_fprintf_chk, __fprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c new file mode 100644 index 0000000000..f3fe2900c3 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-printf_chk.c @@ -0,0 +1,38 @@ +/* Wrapper for __printf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_printf_chk (int flag, const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, format); + done = __vfprintf_internal (stdout, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_printf_chk, __printf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c new file mode 100644 index 0000000000..7f19962dd5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-snprintf_chk.c @@ -0,0 +1,42 @@ +/* Wrapper for __snprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_snprintf_chk (char *s, size_t maxlen, int flag, size_t slen, + const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + if (__glibc_unlikely (slen < maxlen)) + __chk_fail (); + + va_start (ap, format); + done = __vsnprintf_internal (s, maxlen, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_snprintf_chk, __snprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c new file mode 100644 index 0000000000..7cea1225c0 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sprintf_chk.c @@ -0,0 +1,42 @@ +/* Wrapper for __sprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_sprintf_chk (char *s, int flag, size_t slen, + const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + if (slen == 0) + __chk_fail (); + + va_start (ap, format); + done = __vsprintf_internal (s, slen, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_sprintf_chk, __sprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c new file mode 100644 index 0000000000..c496ebe5a3 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vasprintf_chk.c @@ -0,0 +1,31 @@ +/* Wrapper for __vasprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vasprintf_chk (char **result_ptr, int flag, const char *format, + va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vasprintf_internal (result_ptr, format, ap, mode); +} +strong_alias (___ieee128_vasprintf_chk, __vasprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c new file mode 100644 index 0000000000..1b96f5fd21 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vdprintf_chk.c @@ -0,0 +1,30 @@ +/* Wrapper for __vdprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vdprintf_chk (int d, int flag, const char *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vdprintf_internal (d, format, ap, mode); +} +strong_alias (___ieee128_vdprintf_chk, __vdprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c new file mode 100644 index 0000000000..67b29b5e55 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfprintf_chk.c @@ -0,0 +1,30 @@ +/* Wrapper for __vfprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vfprintf_chk (FILE *fp, int flag, const char *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vfprintf_internal (fp, format, ap, mode); +} +strong_alias (___ieee128_vfprintf_chk, __vfprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c new file mode 100644 index 0000000000..15d3e82d76 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vprintf_chk.c @@ -0,0 +1,30 @@ +/* Wrapper for __vprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vprintf_chk (int flag, const char *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vfprintf_internal (stdout, format, ap, mode); +} +strong_alias (___ieee128_vprintf_chk, __vprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c new file mode 100644 index 0000000000..8df93abf33 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsnprintf_chk.c @@ -0,0 +1,34 @@ +/* Wrapper for __vsnprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vsnprintf_chk (char *string, size_t maxlen, int flag, + size_t slen, const char *format, va_list ap) +{ + if (__glibc_unlikely (slen < maxlen)) + __chk_fail (); + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vsnprintf_internal (string, maxlen, format, ap, mode); +} +strong_alias (___ieee128_vsnprintf_chk, __vsnprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c new file mode 100644 index 0000000000..3de4c12199 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsprintf_chk.c @@ -0,0 +1,34 @@ +/* Wrapper for __vsprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vsprintf_chk (char *string, int flag, size_t slen, + const char *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + if (slen == 0) + __chk_fail (); + + return __vsprintf_internal (string, slen, format, ap, mode); +} +strong_alias (___ieee128_vsprintf_chk, __vsprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c new file mode 100644 index 0000000000..7d50284d9c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ibm128.c @@ -0,0 +1 @@ +#include 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 diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c new file mode 100644 index 0000000000..f3d18c92ec --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c @@ -0,0 +1,179 @@ +/* Test for the long double variants of *printf_chk functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define _FORTIFY_SOURCE 2 + +#include +#include +#include +#include + +#include +#include + +static void +do_test_call_varg (FILE *stream, const char *format, ...) +{ + char *buffer = NULL; + char string[128]; + int res; + va_list args; + + printf ("%20s", "__vasprintf_chk: "); + va_start (args, format); + res = __vasprintf_chk (&buffer, 1, format, args); + va_end (args); + if (res == -1) + printf ("Error using vasprintf\n"); + if (buffer == NULL) + printf ("Error using vasprintf\n"); + else + { + printf ("%s", buffer); + free (buffer); + } + printf ("\n"); + + printf ("%20s", "__vdprintf_chk: "); + va_start (args, format); + __vdprintf_chk (fileno (stream), 1, format, args); + va_end (args); + printf ("\n"); + + printf ("%20s", "__vfprintf_chk: "); + va_start (args, format); + __vfprintf_chk (stream, 1, format, args); + va_end (args); + printf ("\n"); + + printf ("%20s", "__vprintf_chk: "); + va_start (args, format); + __vprintf_chk (1, format, args); + va_end (args); + printf ("\n"); + + printf ("%20s", "__vsnprintf_chk: "); + va_start (args, format); + __vsnprintf_chk (string, 79, 1, 127, format, args); + va_end (args); + printf ("%s", string); + printf ("\n"); + + printf ("%20s", "__vsprintf_chk: "); + va_start (args, format); + __vsprintf_chk (string, 1, 127, format, args); + va_end (args); + printf ("%s", string); + printf ("\n"); +} + +static void +do_test_call_rarg (FILE *stream, const char *format, long double ld) +{ + char *buffer = NULL; + char string[128]; + int res; + + printf ("%20s", "__asprintf_chk: "); + res = __asprintf_chk (&buffer, 1, format, ld); + if (res == -1) + printf ("Error using vasprintf\n"); + if (buffer == NULL) + printf ("Error using asprintf\n"); + else + { + printf ("%s", buffer); + free (buffer); + } + printf ("\n"); + + printf ("%20s", "__dprintf_chk: "); + __dprintf_chk (fileno (stream), 1, format, ld); + printf ("\n"); + + printf ("%20s", "__fprintf_chk: "); + __fprintf_chk (stdout, 1, format, ld); + printf ("\n"); + + printf ("%20s", "__printf_chk: "); + __printf_chk (1, format, ld); + printf ("\n"); + + printf ("%20s", "__snprintf_chk: "); + __snprintf_chk (string, 79, 1, 127, format, ld); + printf ("%s", string); + printf ("\n"); + + printf ("%20s", "__sprintf_chk: "); + __sprintf_chk (string, 1, 127, format, ld); + printf ("%s", string); + printf ("\n"); +} + +static void +do_test_call (void) +{ + long double ld = -1; + + /* Print in decimal notation. */ + do_test_call_rarg (stdout, "%.10Lf", ld); + do_test_call_varg (stdout, "%.10Lf", ld); + + /* Print in hexadecimal notation. */ + do_test_call_rarg (stdout, "%.10La", ld); + do_test_call_varg (stdout, "%.10La", ld); +} + +static int +do_test (void) +{ + struct support_capture_subprocess result; + result = support_capture_subprocess ((void *) &do_test_call, NULL); + + /* Compare against the expected output. */ + const char *expected = + " __asprintf_chk: -1.0000000000\n" + " __dprintf_chk: -1.0000000000\n" + " __fprintf_chk: -1.0000000000\n" + " __printf_chk: -1.0000000000\n" + " __snprintf_chk: -1.0000000000\n" + " __sprintf_chk: -1.0000000000\n" + " __vasprintf_chk: -1.0000000000\n" + " __vdprintf_chk: -1.0000000000\n" + " __vfprintf_chk: -1.0000000000\n" + " __vprintf_chk: -1.0000000000\n" + " __vsnprintf_chk: -1.0000000000\n" + " __vsprintf_chk: -1.0000000000\n" + " __asprintf_chk: -0x1.0000000000p+0\n" + " __dprintf_chk: -0x1.0000000000p+0\n" + " __fprintf_chk: -0x1.0000000000p+0\n" + " __printf_chk: -0x1.0000000000p+0\n" + " __snprintf_chk: -0x1.0000000000p+0\n" + " __sprintf_chk: -0x1.0000000000p+0\n" + " __vasprintf_chk: -0x1.0000000000p+0\n" + " __vdprintf_chk: -0x1.0000000000p+0\n" + " __vfprintf_chk: -0x1.0000000000p+0\n" + " __vprintf_chk: -0x1.0000000000p+0\n" + " __vsnprintf_chk: -0x1.0000000000p+0\n" + " __vsprintf_chk: -0x1.0000000000p+0\n"; + TEST_COMPARE_STRING (expected, result.out.buffer); + + return 0; +} + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c new file mode 100644 index 0000000000..aeab22412b --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ibm128.c @@ -0,0 +1,2 @@ +#define _FORTIFY_SOURCE 2 +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c new file mode 100644 index 0000000000..aeab22412b --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-redir-ieee128.c @@ -0,0 +1,2 @@ +#define _FORTIFY_SOURCE 2 +#include From patchwork Fri Oct 25 15:33:44 2019 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: 1184241 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106312-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="yJrQgM5w"; 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 4707V50S2gz9sQm for ; Sat, 26 Oct 2019 02:35:24 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=yd+sHIIlWYHD6OTwPfdJ3UIxhbPwFynXOL8O0ycOFtJ gobXtF6YeomcAUbvA+KgvzyxWHGKIXBpmWOb0B5U/MVzNC76jEKUS6WdITIE7II6 Qnot1yP3YDkmCTuh4lKL+uMKQpqZysWg2q6z/1fm4CBO+9oF11zYtx5eDyBo66jo = 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-transfer-encoding:content-type; s=default; bh=maClcTIWP/CuRSBKTH8IdK8fm70=; b=yJrQgM5wNzcyM1rjs vjpGW7sytSqODCXYPrsw/wP5etdL9LMzREJgFaCfvW19q0pFNek19GEeVIeq52nt uu+P/4ooL3vjRtHOghy3iekgIdqw1TZj1nb+CmZ6WR3pRx0DrkbMvYXCUuWpufXY 7rvczGqLfes6jzsH+AmcCA0/Do= Received: (qmail 104113 invoked by alias); 25 Oct 2019 15:34:56 -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 104043 invoked by uid 89); 25 Oct 2019 15:34:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 04/30] ldbl-128ibm-compat: Add wide character, fortified printing functions Date: Fri, 25 Oct 2019 12:33:44 -0300 Message-ID: <20191025153410.15405-5-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1592022468921577155 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Similarly to what was done for the regular character, fortified printing functions, this patch combines the mode masks PRINTF_LDBL_USES_FLOAT128 and PRINTF_FORTIFY to provide wide character versions of fortified printf functions. It also adds two flavors of test cases: one that explicitly calls the fortified functions, and another that reuses the non-fortified test, but defining _FORTIFY_SOURCE as 2. The first guarantees that the implementations are actually being tested (independently of what's in bits/wchar2.h), whereas the second guarantees that the redirections calls the correct function in the IBM and IEEE long double cases. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 18 ++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++ .../ldbl-128ibm-compat/ieee128-fwprintf_chk.c | 38 ++++++ .../ldbl-128ibm-compat/ieee128-swprintf_chk.c | 42 +++++++ .../ieee128-vfwprintf_chk.c | 31 +++++ .../ieee128-vswprintf_chk.c | 34 ++++++ .../ldbl-128ibm-compat/ieee128-vwprintf_chk.c | 30 +++++ .../ldbl-128ibm-compat/ieee128-wprintf_chk.c | 38 ++++++ .../test-wprintf-chk-ibm128.c | 1 + .../test-wprintf-chk-ieee128.c | 1 + .../test-wprintf-chk-ldbl-compat.c | 113 ++++++++++++++++++ .../test-wprintf-chk-redir-ibm128.c | 2 + .../test-wprintf-chk-redir-ieee128.c | 2 + 13 files changed, 357 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 21056e38da..7217987aa5 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -69,7 +69,13 @@ ldbl-extra-routines += asprintf_chk \ vfprintf_chk \ vprintf_chk \ vsnprintf_chk \ - vsprintf_chk + vsprintf_chk \ + fwprintf_chk \ + swprintf_chk \ + wprintf_chk \ + vfwprintf_chk \ + vswprintf_chk \ + vwprintf_chk tests-internal += test-printf-chk-ieee128 test-printf-chk-ibm128 CFLAGS-test-printf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi @@ -80,6 +86,16 @@ CFLAGS-test-printf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \ -Wno-psabi -Wno-unused-result CFLAGS-test-printf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ -Wno-unused-result + +tests-internal += test-wprintf-chk-ieee128 test-wprintf-chk-ibm128 +CFLAGS-test-wprintf-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-wprintf-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +tests-internal += test-wprintf-chk-redir-ieee128 test-wprintf-chk-redir-ibm128 +CFLAGS-test-wprintf-chk-redir-ieee128.c += -mfloat128 -mabi=ieeelongdouble \ + -Wno-psabi -Wno-unused-result +CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ + -Wno-unused-result endif # Add IEEE binary128 files as make targets. diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index aac08a3ad3..e438c7c306 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -156,5 +156,13 @@ libc { __vprintf_chkieee128; __vsnprintf_chkieee128; __vsprintf_chkieee128; + + __fwprintf_chkieee128; + __swprintf_chkieee128; + __wprintf_chkieee128; + + __vfwprintf_chkieee128; + __vswprintf_chkieee128; + __vwprintf_chkieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c new file mode 100644 index 0000000000..04d2632e6c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwprintf_chk.c @@ -0,0 +1,38 @@ +/* Wrapper for __fwprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_fwprintf_chk (FILE *fp, int flag, const wchar_t *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, format); + done = __vfwprintf_internal (fp, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_fwprintf_chk, __fwprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c new file mode 100644 index 0000000000..854ff2ef2c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swprintf_chk.c @@ -0,0 +1,42 @@ +/* Wrapper for __swprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_swprintf_chk (wchar_t *string, size_t maxlen, int flag, + size_t slen, const wchar_t *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + if (__glibc_unlikely (slen < maxlen)) + __chk_fail (); + + va_start (ap, format); + done = __vswprintf_internal (string, maxlen, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_swprintf_chk, __swprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c new file mode 100644 index 0000000000..2f880930ff --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwprintf_chk.c @@ -0,0 +1,31 @@ +/* Wrapper for __vfwprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vfwprintf_chk (FILE *fp, int flag, const wchar_t *format, + va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vfwprintf_internal (fp, format, ap, mode); +} +strong_alias (___ieee128_vfwprintf_chk, __vfwprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c new file mode 100644 index 0000000000..0d995cacf4 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswprintf_chk.c @@ -0,0 +1,34 @@ +/* Wrapper for __vswprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vswprintf_chk (wchar_t *string, size_t maxlen, int flag, + size_t slen, const wchar_t *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + if (__glibc_unlikely (slen < maxlen)) + __chk_fail (); + + return __vswprintf_internal (string, maxlen, format, ap, mode); +} +strong_alias (___ieee128_vswprintf_chk, __vswprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c new file mode 100644 index 0000000000..5e47dccc0d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwprintf_chk.c @@ -0,0 +1,30 @@ +/* Wrapper for __vwprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_vwprintf_chk (int flag, const wchar_t *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __vfwprintf_internal (stdout, format, ap, mode); +} +strong_alias (___ieee128_vwprintf_chk, __vwprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c new file mode 100644 index 0000000000..ba00b7be54 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wprintf_chk.c @@ -0,0 +1,38 @@ +/* Wrapper for __wprintf_chk. IEEE128 version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +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 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 diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c new file mode 100644 index 0000000000..f614004f27 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c @@ -0,0 +1,113 @@ +/* Test for the long double variants of *w*printf_chk functions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define _FORTIFY_SOURCE 2 + +#include +#include +#include +#include + +#include +#include + +static void +do_test_call_varg (FILE *stream, const wchar_t *format, ...) +{ + wchar_t string[128]; + va_list args; + + wprintf (L"%20Ls", L"__vfwprintf_chk: "); + va_start (args, format); + __vfwprintf_chk (stream, 1, format, args); + va_end (args); + wprintf (L"\n"); + + wprintf (L"%20Ls", L"__vswprintf_chk: "); + va_start (args, format); + __vswprintf_chk (string, 79, 1, 127, format, args); + va_end (args); + wprintf (L"%Ls", string); + wprintf (L"\n"); + + wprintf (L"%20Ls", L"__vwprintf_chk: "); + va_start (args, format); + __vwprintf_chk (1, format, args); + va_end (args); + wprintf (L"\n"); +} + +static void +do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld) +{ + wchar_t string[128]; + + wprintf (L"%20Ls", L"__fwprintf_chk: "); + __fwprintf_chk (stream, 1, format, ld); + wprintf (L"\n"); + + wprintf (L"%20Ls", L"__swprintf_chk: "); + __swprintf_chk (string, 79, 1, 127, format, ld); + wprintf (L"%Ls", string); + wprintf (L"\n"); + + wprintf (L"%20Ls", L"__wprintf_chk: "); + __wprintf_chk (1, format, ld); + wprintf (L"\n"); +} + +static void +do_test_call (void) +{ + long double ld = -1; + + /* Print in decimal notation. */ + do_test_call_rarg (stdout, L"%.10Lf", ld); + do_test_call_varg (stdout, L"%.10Lf", ld); + + /* Print in hexadecimal notation. */ + do_test_call_rarg (stdout, L"%.10La", ld); + do_test_call_varg (stdout, L"%.10La", ld); +} + +static int +do_test (void) +{ + struct support_capture_subprocess result; + result = support_capture_subprocess ((void *) &do_test_call, NULL); + + /* Compare against the expected output. */ + const char *expected = + " __fwprintf_chk: -1.0000000000\n" + " __swprintf_chk: -1.0000000000\n" + " __wprintf_chk: -1.0000000000\n" + " __vfwprintf_chk: -1.0000000000\n" + " __vswprintf_chk: -1.0000000000\n" + " __vwprintf_chk: -1.0000000000\n" + " __fwprintf_chk: -0x1.0000000000p+0\n" + " __swprintf_chk: -0x1.0000000000p+0\n" + " __wprintf_chk: -0x1.0000000000p+0\n" + " __vfwprintf_chk: -0x1.0000000000p+0\n" + " __vswprintf_chk: -0x1.0000000000p+0\n" + " __vwprintf_chk: -0x1.0000000000p+0\n"; + TEST_COMPARE_STRING (expected, result.out.buffer); + + return 0; +} + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c new file mode 100644 index 0000000000..a12186a945 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ibm128.c @@ -0,0 +1,2 @@ +#define _FORTIFY_SOURCE 2 +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c new file mode 100644 index 0000000000..a12186a945 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-redir-ieee128.c @@ -0,0 +1,2 @@ +#define _FORTIFY_SOURCE 2 +#include From patchwork Fri Oct 25 15:33:45 2019 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: 1184242 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106313-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="xBXSNGr/"; 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 4707VJ5mtjz9sPh for ; Sat, 26 Oct 2019 02:35:36 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=IJFwZavTABXLJvzqRRVvyJEJ4aRYXA8/oc3k2+ZekCN yWJGEAvqa459G7QlcPifR8o9KgxrWyb/hfVCJzK0MzqQ/QOUan0WW75+kxORUE+I 4ZJBBKXYVjD5ROuhdeSkHbjzLCJKFkO1ot6wi0yhJ1QsUwP7vqInyBW8iv6/yie8 = 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-transfer-encoding:content-type; s=default; bh=hWyTdrM+yHHAz2Mfq3KhP04GbcQ=; b=xBXSNGr/oN+AWFdVt +uYtMAidjx3GbBpYgyBf1Wu1qd2IcRSsD2neasJ7H4C9/OTgoOGeWYp0Zb+sR/WQ XIlGqph/kE2RTFVQm5GTPhRv/CgPA7OBtyDW92kJfCqIA4Cj5hrkUfjgnGH3wfAY 9mAFLdueokNcNnd3fGP57VG5AE= Received: (qmail 104608 invoked by alias); 25 Oct 2019 15:35:00 -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 104565 invoked by uid 89); 25 Oct 2019 15:35:00 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=9524 X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 05/30] ldbl-128ibm-compat: Test double values Date: Fri, 25 Oct 2019 12:33:45 -0300 Message-ID: <20191025153410.15405-6-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1593711319728115395 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- A single format string can take double and long double parameters at the same time. Internally, these parameters are routed to the same function, which correctly reads them and calls the underlying functions responsible for the actual conversion to string. This patch adds a new case to test this scenario. Tested for powerpc64le. --- .../test-printf-chk-ldbl-compat.c | 72 ++++++++++--------- .../test-printf-ldbl-compat.c | 71 +++++++++--------- .../test-wprintf-chk-ldbl-compat.c | 42 +++++------ .../test-wprintf-ldbl-compat.c | 42 +++++------ 4 files changed, 117 insertions(+), 110 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c index f3d18c92ec..e8e124425b 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c @@ -83,14 +83,15 @@ do_test_call_varg (FILE *stream, const char *format, ...) } static void -do_test_call_rarg (FILE *stream, const char *format, long double ld) +do_test_call_rarg (FILE *stream, const char *format, long double ld, + double d) { char *buffer = NULL; char string[128]; int res; printf ("%20s", "__asprintf_chk: "); - res = __asprintf_chk (&buffer, 1, format, ld); + res = __asprintf_chk (&buffer, 1, format, ld, d); if (res == -1) printf ("Error using vasprintf\n"); if (buffer == NULL) @@ -103,24 +104,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld) printf ("\n"); printf ("%20s", "__dprintf_chk: "); - __dprintf_chk (fileno (stream), 1, format, ld); + __dprintf_chk (fileno (stream), 1, format, ld, d); printf ("\n"); printf ("%20s", "__fprintf_chk: "); - __fprintf_chk (stdout, 1, format, ld); + __fprintf_chk (stdout, 1, format, ld, d); printf ("\n"); printf ("%20s", "__printf_chk: "); - __printf_chk (1, format, ld); + __printf_chk (1, format, ld, d); printf ("\n"); printf ("%20s", "__snprintf_chk: "); - __snprintf_chk (string, 79, 1, 127, format, ld); + __snprintf_chk (string, 79, 1, 127, format, ld, d); printf ("%s", string); printf ("\n"); printf ("%20s", "__sprintf_chk: "); - __sprintf_chk (string, 1, 127, format, ld); + __sprintf_chk (string, 1, 127, format, ld, d); printf ("%s", string); printf ("\n"); } @@ -129,14 +130,15 @@ static void do_test_call (void) { long double ld = -1; + double d = -1; /* Print in decimal notation. */ - do_test_call_rarg (stdout, "%.10Lf", ld); - do_test_call_varg (stdout, "%.10Lf", ld); + do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d); + do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d); /* Print in hexadecimal notation. */ - do_test_call_rarg (stdout, "%.10La", ld); - do_test_call_varg (stdout, "%.10La", ld); + do_test_call_rarg (stdout, "%.10La, %.10a", ld, d); + do_test_call_varg (stdout, "%.10La, %.10a", ld, d); } static int @@ -147,30 +149,30 @@ do_test (void) /* Compare against the expected output. */ const char *expected = - " __asprintf_chk: -1.0000000000\n" - " __dprintf_chk: -1.0000000000\n" - " __fprintf_chk: -1.0000000000\n" - " __printf_chk: -1.0000000000\n" - " __snprintf_chk: -1.0000000000\n" - " __sprintf_chk: -1.0000000000\n" - " __vasprintf_chk: -1.0000000000\n" - " __vdprintf_chk: -1.0000000000\n" - " __vfprintf_chk: -1.0000000000\n" - " __vprintf_chk: -1.0000000000\n" - " __vsnprintf_chk: -1.0000000000\n" - " __vsprintf_chk: -1.0000000000\n" - " __asprintf_chk: -0x1.0000000000p+0\n" - " __dprintf_chk: -0x1.0000000000p+0\n" - " __fprintf_chk: -0x1.0000000000p+0\n" - " __printf_chk: -0x1.0000000000p+0\n" - " __snprintf_chk: -0x1.0000000000p+0\n" - " __sprintf_chk: -0x1.0000000000p+0\n" - " __vasprintf_chk: -0x1.0000000000p+0\n" - " __vdprintf_chk: -0x1.0000000000p+0\n" - " __vfprintf_chk: -0x1.0000000000p+0\n" - " __vprintf_chk: -0x1.0000000000p+0\n" - " __vsnprintf_chk: -0x1.0000000000p+0\n" - " __vsprintf_chk: -0x1.0000000000p+0\n"; + " __asprintf_chk: -1.0000000000, -1.0000000000\n" + " __dprintf_chk: -1.0000000000, -1.0000000000\n" + " __fprintf_chk: -1.0000000000, -1.0000000000\n" + " __printf_chk: -1.0000000000, -1.0000000000\n" + " __snprintf_chk: -1.0000000000, -1.0000000000\n" + " __sprintf_chk: -1.0000000000, -1.0000000000\n" + " __vasprintf_chk: -1.0000000000, -1.0000000000\n" + " __vdprintf_chk: -1.0000000000, -1.0000000000\n" + " __vfprintf_chk: -1.0000000000, -1.0000000000\n" + " __vprintf_chk: -1.0000000000, -1.0000000000\n" + " __vsnprintf_chk: -1.0000000000, -1.0000000000\n" + " __vsprintf_chk: -1.0000000000, -1.0000000000\n" + " __asprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __dprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __fprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __printf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __snprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __sprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vasprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vdprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vfprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vsnprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c index 939a6aad9c..2b8d424473 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c @@ -78,13 +78,13 @@ do_test_call_varg (FILE *stream, const char *format, ...) } static void -do_test_call_rarg (FILE *stream, const char *format, long double ld) +do_test_call_rarg (FILE *stream, const char *format, long double ld, double d) { char *buffer = NULL; char string[128]; printf ("%15s", "asprintf: "); - asprintf (&buffer, format, ld); + asprintf (&buffer, format, ld, d); if (buffer == NULL) printf ("Error using asprintf\n"); else @@ -95,24 +95,24 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld) printf ("\n"); printf ("%15s", "dprintf: "); - dprintf (fileno (stream), format, ld); + dprintf (fileno (stream), format, ld, d); printf ("\n"); printf ("%15s", "fprintf: "); - fprintf (stream, format, ld); + fprintf (stream, format, ld, d); printf ("\n"); printf ("%15s", "printf: "); - printf (format, ld); + printf (format, ld, d); printf ("\n"); printf ("%15s", "snprintf: "); - snprintf (string, 127, format, ld); + snprintf (string, 127, format, ld, d); printf ("%s", string); printf ("\n"); printf ("%15s", "sprintf: "); - sprintf (string, format, ld); + sprintf (string, format, ld, d); printf ("%s", string); printf ("\n"); } @@ -121,14 +121,15 @@ static void do_test_call (void) { long double ld = -1; + double d = -1; /* Print in decimal notation. */ - do_test_call_rarg (stdout, "%.10Lf", ld); - do_test_call_varg (stdout, "%.10Lf", ld); + do_test_call_rarg (stdout, "%.10Lf, %.10f", ld, d); + do_test_call_varg (stdout, "%.10Lf, %.10f", ld, d); /* Print in hexadecimal notation. */ - do_test_call_rarg (stdout, "%.10La", ld); - do_test_call_varg (stdout, "%.10La", ld); + do_test_call_rarg (stdout, "%.10La, %.10a", ld, d); + do_test_call_varg (stdout, "%.10La, %.10a", ld, d); } static int @@ -139,30 +140,30 @@ do_test (void) /* Compare against the expected output. */ const char *expected = - " asprintf: -1.0000000000\n" - " dprintf: -1.0000000000\n" - " fprintf: -1.0000000000\n" - " printf: -1.0000000000\n" - " snprintf: -1.0000000000\n" - " sprintf: -1.0000000000\n" - " vasprintf: -1.0000000000\n" - " vdprintf: -1.0000000000\n" - " vfprintf: -1.0000000000\n" - " vprintf: -1.0000000000\n" - " vsnprintf: -1.0000000000\n" - " vsprintf: -1.0000000000\n" - " asprintf: -0x1.0000000000p+0\n" - " dprintf: -0x1.0000000000p+0\n" - " fprintf: -0x1.0000000000p+0\n" - " printf: -0x1.0000000000p+0\n" - " snprintf: -0x1.0000000000p+0\n" - " sprintf: -0x1.0000000000p+0\n" - " vasprintf: -0x1.0000000000p+0\n" - " vdprintf: -0x1.0000000000p+0\n" - " vfprintf: -0x1.0000000000p+0\n" - " vprintf: -0x1.0000000000p+0\n" - " vsnprintf: -0x1.0000000000p+0\n" - " vsprintf: -0x1.0000000000p+0\n"; + " asprintf: -1.0000000000, -1.0000000000\n" + " dprintf: -1.0000000000, -1.0000000000\n" + " fprintf: -1.0000000000, -1.0000000000\n" + " printf: -1.0000000000, -1.0000000000\n" + " snprintf: -1.0000000000, -1.0000000000\n" + " sprintf: -1.0000000000, -1.0000000000\n" + " vasprintf: -1.0000000000, -1.0000000000\n" + " vdprintf: -1.0000000000, -1.0000000000\n" + " vfprintf: -1.0000000000, -1.0000000000\n" + " vprintf: -1.0000000000, -1.0000000000\n" + " vsnprintf: -1.0000000000, -1.0000000000\n" + " vsprintf: -1.0000000000, -1.0000000000\n" + " asprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " dprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " fprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " printf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " snprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " sprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vasprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vdprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vfprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vsnprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c index f614004f27..0dcabec38a 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c @@ -53,21 +53,22 @@ do_test_call_varg (FILE *stream, const wchar_t *format, ...) } static void -do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld) +do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld, + double d) { wchar_t string[128]; wprintf (L"%20Ls", L"__fwprintf_chk: "); - __fwprintf_chk (stream, 1, format, ld); + __fwprintf_chk (stream, 1, format, ld, d); wprintf (L"\n"); wprintf (L"%20Ls", L"__swprintf_chk: "); - __swprintf_chk (string, 79, 1, 127, format, ld); + __swprintf_chk (string, 79, 1, 127, format, ld, d); wprintf (L"%Ls", string); wprintf (L"\n"); wprintf (L"%20Ls", L"__wprintf_chk: "); - __wprintf_chk (1, format, ld); + __wprintf_chk (1, format, ld, d); wprintf (L"\n"); } @@ -75,14 +76,15 @@ static void do_test_call (void) { long double ld = -1; + double d = -1; /* Print in decimal notation. */ - do_test_call_rarg (stdout, L"%.10Lf", ld); - do_test_call_varg (stdout, L"%.10Lf", ld); + do_test_call_rarg (stdout, L"%.10Lf, %.10f", ld, d); + do_test_call_varg (stdout, L"%.10Lf, %.10f", ld, d); /* Print in hexadecimal notation. */ - do_test_call_rarg (stdout, L"%.10La", ld); - do_test_call_varg (stdout, L"%.10La", ld); + do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d); + do_test_call_varg (stdout, L"%.10La, %.10a", ld, d); } static int @@ -93,18 +95,18 @@ do_test (void) /* Compare against the expected output. */ const char *expected = - " __fwprintf_chk: -1.0000000000\n" - " __swprintf_chk: -1.0000000000\n" - " __wprintf_chk: -1.0000000000\n" - " __vfwprintf_chk: -1.0000000000\n" - " __vswprintf_chk: -1.0000000000\n" - " __vwprintf_chk: -1.0000000000\n" - " __fwprintf_chk: -0x1.0000000000p+0\n" - " __swprintf_chk: -0x1.0000000000p+0\n" - " __wprintf_chk: -0x1.0000000000p+0\n" - " __vfwprintf_chk: -0x1.0000000000p+0\n" - " __vswprintf_chk: -0x1.0000000000p+0\n" - " __vwprintf_chk: -0x1.0000000000p+0\n"; + " __fwprintf_chk: -1.0000000000, -1.0000000000\n" + " __swprintf_chk: -1.0000000000, -1.0000000000\n" + " __wprintf_chk: -1.0000000000, -1.0000000000\n" + " __vfwprintf_chk: -1.0000000000, -1.0000000000\n" + " __vswprintf_chk: -1.0000000000, -1.0000000000\n" + " __vwprintf_chk: -1.0000000000, -1.0000000000\n" + " __fwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __swprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __wprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vfwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vswprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c index 71edfec235..def4337571 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c @@ -51,21 +51,22 @@ do_test_call_varg (FILE *stream, const wchar_t *format, ...) } static void -do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld) +do_test_call_rarg (FILE *stream, const wchar_t *format, long double ld, + double d) { wchar_t string[128]; wprintf (L"%15Ls", L"fwprintf: "); - fwprintf (stream, format, ld); + fwprintf (stream, format, ld, d); wprintf (L"\n"); wprintf (L"%15Ls", L"swprintf: "); - swprintf (string, 127, format, ld); + swprintf (string, 127, format, ld, d); wprintf (L"%Ls", string); wprintf (L"\n"); wprintf (L"%15Ls", L"wprintf: "); - wprintf (format, ld); + wprintf (format, ld, d); wprintf (L"\n"); } @@ -73,14 +74,15 @@ static void do_test_call (void) { long double ld = -1; + double d = -1; /* Print in decimal notation. */ - do_test_call_rarg (stdout, L"%.10Lf", ld); - do_test_call_varg (stdout, L"%.10Lf", ld); + do_test_call_rarg (stdout, L"%.10Lf, %.10f", ld, d); + do_test_call_varg (stdout, L"%.10Lf, %.10f", ld, d); /* Print in hexadecimal notation. */ - do_test_call_rarg (stdout, L"%.10La", ld); - do_test_call_varg (stdout, L"%.10La", ld); + do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d); + do_test_call_varg (stdout, L"%.10La, %.10a", ld, d); } static int @@ -91,18 +93,18 @@ do_test (void) /* Compare against the expected output. */ const char *expected = - " fwprintf: -1.0000000000\n" - " swprintf: -1.0000000000\n" - " wprintf: -1.0000000000\n" - " vfwprintf: -1.0000000000\n" - " vswprintf: -1.0000000000\n" - " vwprintf: -1.0000000000\n" - " fwprintf: -0x1.0000000000p+0\n" - " swprintf: -0x1.0000000000p+0\n" - " wprintf: -0x1.0000000000p+0\n" - " vfwprintf: -0x1.0000000000p+0\n" - " vswprintf: -0x1.0000000000p+0\n" - " vwprintf: -0x1.0000000000p+0\n"; + " fwprintf: -1.0000000000, -1.0000000000\n" + " swprintf: -1.0000000000, -1.0000000000\n" + " wprintf: -1.0000000000, -1.0000000000\n" + " vfwprintf: -1.0000000000, -1.0000000000\n" + " vswprintf: -1.0000000000, -1.0000000000\n" + " vwprintf: -1.0000000000, -1.0000000000\n" + " fwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " swprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " wprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vfwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vswprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; From patchwork Fri Oct 25 15:33:46 2019 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: 1184243 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106314-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="LYd9xFA+"; 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 4707VZ4XN6z9sPZ for ; Sat, 26 Oct 2019 02:35:50 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=iSDeXqUvAJ7bBp+ttQ5P8Pf8omrXmNrJdWJytkdINrs +qxX8lZfy0GzyA6SvYJfCRtpSuYcoVJtfCTMp7PIqQggi7Fxjsg5096xukDYWDEe afvTO0OjnyaN03SMZgfrz3OeHyfWkRDGwWxX94K9IsiWzukw5qLTwH/zgLX9o9cQ = 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-transfer-encoding:content-type; s=default; bh=Nlhj0lFiSinqk7mOLwJXh/y1/pY=; b=LYd9xFA+mLvGEczM4 Ahjywmbk+w5CnE9ev+nNFx4CUlLazhHdR1sQFzhQWNgRpVEn8M9BBRXDaXjUCc0b 6D7+fkXL/lvgNDGYpha1LFpbGo6jvi1KZk/EgDHyktROwMhLoEKQNzLkDf6OhB0x oqcrlZMjHDG+unNj3++Y6DqzTo= Received: (qmail 105401 invoked by alias); 25 Oct 2019 15:35:06 -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 105333 invoked by uid 89); 25 Oct 2019 15:35:06 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*F:D*br X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 06/30] ldbl-128ibm-compat: Test positional arguments Date: Fri, 25 Oct 2019 12:33:46 -0300 Message-ID: <20191025153410.15405-7-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1595400169169014467 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdeklecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- The format string can request positional parameters, instead of relying on the order in which they appear as arguments. Since this has an effect on how the type of each argument is determined, this patch extends the test cases to use positional parameters with mixed double and long double types, to verify that the IEEE long double implementations of *printf work correctly in this scenario. Tested for powerpc64le. --- .../ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c | 12 +++++++++++- .../ldbl-128ibm-compat/test-printf-ldbl-compat.c | 12 +++++++++++- .../test-wprintf-chk-ldbl-compat.c | 9 ++++++++- .../ldbl-128ibm-compat/test-wprintf-ldbl-compat.c | 9 ++++++++- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c index e8e124425b..153a35d451 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-chk-ldbl-compat.c @@ -139,6 +139,10 @@ do_test_call (void) /* Print in hexadecimal notation. */ do_test_call_rarg (stdout, "%.10La, %.10a", ld, d); do_test_call_varg (stdout, "%.10La, %.10a", ld, d); + + /* Test positional parameters. */ + do_test_call_varg (stdout, "%3$Lf, %2$Lf, %1$f", + (double) 1, (long double) 2, (long double) 3); } static int @@ -172,7 +176,13 @@ do_test (void) " __vfprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " __vprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " __vsnprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" - " __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; + " __vsprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vasprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vdprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vfprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vsnprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vsprintf_chk: 3.000000, 2.000000, 1.000000\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c index 2b8d424473..5b0e8d3bae 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c @@ -130,6 +130,10 @@ do_test_call (void) /* Print in hexadecimal notation. */ do_test_call_rarg (stdout, "%.10La, %.10a", ld, d); do_test_call_varg (stdout, "%.10La, %.10a", ld, d); + + /* Test positional parameters. */ + do_test_call_varg (stdout, "%3$Lf, %2$Lf, %1$f", + (double) 1, (long double) 2, (long double) 3); } static int @@ -163,7 +167,13 @@ do_test (void) " vfprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " vprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " vsnprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" - " vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; + " vsprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vasprintf: 3.000000, 2.000000, 1.000000\n" + " vdprintf: 3.000000, 2.000000, 1.000000\n" + " vfprintf: 3.000000, 2.000000, 1.000000\n" + " vprintf: 3.000000, 2.000000, 1.000000\n" + " vsnprintf: 3.000000, 2.000000, 1.000000\n" + " vsprintf: 3.000000, 2.000000, 1.000000\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c index 0dcabec38a..49174625d4 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-chk-ldbl-compat.c @@ -85,6 +85,10 @@ do_test_call (void) /* Print in hexadecimal notation. */ do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d); do_test_call_varg (stdout, L"%.10La, %.10a", ld, d); + + /* Test positional parameters. */ + do_test_call_varg (stdout, L"%3$Lf, %2$Lf, %1$f", + (double) 1, (long double) 2, (long double) 3); } static int @@ -106,7 +110,10 @@ do_test (void) " __wprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " __vfwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " __vswprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" - " __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; + " __vwprintf_chk: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " __vfwprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vswprintf_chk: 3.000000, 2.000000, 1.000000\n" + " __vwprintf_chk: 3.000000, 2.000000, 1.000000\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c index def4337571..008275f529 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wprintf-ldbl-compat.c @@ -83,6 +83,10 @@ do_test_call (void) /* Print in hexadecimal notation. */ do_test_call_rarg (stdout, L"%.10La, %.10a", ld, d); do_test_call_varg (stdout, L"%.10La, %.10a", ld, d); + + /* Test positional parameters. */ + do_test_call_varg (stdout, L"%3$Lf, %2$Lf, %1$f", + (double) 1, (long double) 2, (long double) 3); } static int @@ -104,7 +108,10 @@ do_test (void) " wprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " vfwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" " vswprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" - " vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n"; + " vwprintf: -0x1.0000000000p+0, -0x1.0000000000p+0\n" + " vfwprintf: 3.000000, 2.000000, 1.000000\n" + " vswprintf: 3.000000, 2.000000, 1.000000\n" + " vwprintf: 3.000000, 2.000000, 1.000000\n"; TEST_COMPARE_STRING (expected, result.out.buffer); return 0; From patchwork Fri Oct 25 15:33:47 2019 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: 1184244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106315-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="YkxIibHv"; 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 4707Vt06BHz9sPZ for ; Sat, 26 Oct 2019 02:36:05 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=jo4MzyHDxKCg/ypTCannfHF3nufhyRznJcHbHTmw1yn TVkrLqTjX9HUefntw5H6FZ9BWc2ZMXK+1quEnqDq9g/vBOIE8Lqrt2sPvHz/LdjB ujskQC4Tg3Ujts/Q065wMCTL524jAt5CkmPEGNblJfYjhU8waJYzUsIX3wAHj2zE = 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-transfer-encoding:content-type; s=default; bh=V/xIcB8UjV7F5LbwerDWgsciDbQ=; b=YkxIibHvtGKLSL6oD 3g3vIU62to/LAR7Im9nwPJP4dIu6JedJjy2JXaclwPTurtLUKXCk56zqFb5D0SA3 uFfVfyf6L6Qr2eUlsVRYbyWAPoJ7wnIU/7qqHo42DGpzJzAujS+jpoX5Dg+5O54J vFiBskeYUD/OpHAHzaFumDUyu0= Received: (qmail 106442 invoked by alias); 25 Oct 2019 15:35:16 -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 106375 invoked by uid 89); 25 Oct 2019 15:35:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LOTSOFHASH, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 07/30] ldbl-128ibm-compat: Add regular character scanning functions Date: Fri, 25 Oct 2019 12:33:47 -0300 Message-ID: <20191025153410.15405-8-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1597651970229456579 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- The 'mode' argument to __vfscanf_internal allows the selection of the long double format for all long double arguments requested by the format string. Currently, there are two possibilities: long double with the same format as double or long double as something else. The 'something else' format varies between architectures, and on powerpc64le, it means IBM Extended Precision format. In preparation for the third option of long double format on powerpc64le, this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, which tells __vfscanf_internal to call __strtof128_internal, instead of __strtold_internal, and save the output into a _Float128 variable. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 37 +++++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++ .../ldbl-128ibm-compat/ieee128-fscanf.c | 34 +++++ .../ldbl-128ibm-compat/ieee128-scanf.c | 34 +++++ .../ldbl-128ibm-compat/ieee128-sscanf.c | 38 ++++++ .../ldbl-128ibm-compat/ieee128-vfscanf.c | 26 ++++ .../ldbl-128ibm-compat/ieee128-vscanf.c | 26 ++++ .../ldbl-128ibm-compat/ieee128-vsscanf.c | 29 +++++ .../ldbl-128ibm-compat/test-scanf-ibm128.c | 1 + .../ldbl-128ibm-compat/test-scanf-ieee128.c | 1 + .../test-scanf-ldbl-compat-template.c | 117 ++++++++++++++++++ .../test-scanf-ldbl-compat.c | 10 ++ .../test-scanf-ldbl-compat.sh | 63 ++++++++++ 13 files changed, 421 insertions(+), 3 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-scanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-sscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vsscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 7217987aa5..a1f0f7d74e 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -17,15 +17,23 @@ ldbl-extra-routines += printf_size \ wprintf \ vfwprintf \ vswprintf \ - vwprintf + vwprintf \ + fscanf \ + scanf \ + sscanf \ + vfscanf \ + vscanf \ + vsscanf # Printing long double values with IEEE binary128 format reuses part # of the internal float128 implementation (__printf_fp, __printf_fphex, -# and __float128 variables and union members). Thus, the compilation of -# the following functions, must have -mfloat128 and -mabi=ibmlongdouble +# and __float128 variables and union members). Likewise, reading these +# values reuses __strtof128_internal. Thus, the compilation of the +# following functions, must have -mfloat128 and -mabi=ibmlongdouble # passed to the compiler. CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble +CFLAGS-vfscanf-internal.c += -mfloat128 -mabi=ibmlongdouble # Basic tests for the implementation of long double with IEEE binary128 # format and for the related redirections in installed headers. @@ -37,6 +45,29 @@ tests-internal += test-wprintf-ieee128 test-wprintf-ibm128 CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +tests-internal += test-scanf-ieee128 test-scanf-ibm128 +CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +$(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link) + +ifeq ($(run-built-tests),yes) +tests-special += $(objpfx)test-scanf-ieee128.out +tests-special += $(objpfx)test-scanf-ibm128.out +endif + +$(objpfx)test-scanf-ieee128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \ + $(objpfx)test-scanf-ieee128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + +$(objpfx)test-scanf-ibm128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \ + $(objpfx)test-scanf-ibm128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + tests-internal += test-printf-size-ieee128 test-printf-size-ibm128 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index e438c7c306..7971c7a7d1 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -164,5 +164,13 @@ libc { __vfwprintf_chkieee128; __vswprintf_chkieee128; __vwprintf_chkieee128; + + __fscanfieee128; + __scanfieee128; + __sscanfieee128; + + __vfscanfieee128; + __vscanfieee128; + __vsscanfieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c new file mode 100644 index 0000000000..f51e822094 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fscanf.c @@ -0,0 +1,34 @@ +/* Wrapper for fscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +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 + . */ + +#include +#include + +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 + . */ + +#include +#include +#include + +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 + . */ + +#include + +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 + . */ + +#include + +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 + . */ + +#include +#include + +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 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 diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c new file mode 100644 index 0000000000..4590e9da96 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c @@ -0,0 +1,117 @@ +/* Test for the long double variants of *scanf functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include + +#include + +#define CLEAR \ + va_start (args, format); \ + ld = va_arg (args, long double *); \ + *ld = 0; \ + va_end (args); + +#define CLEAR_VALUE value = 0; + +#define CHECK \ + va_start (args, format); \ + ld = va_arg (args, long double *); \ + va_end (args); \ + if (*ld == -1.0L) \ + printf ("OK"); \ + else \ + printf ("ERROR (%.60Lf)", *ld); \ + printf ("\n"); + +#define CHECK_VALUE \ + if (value == -1.0L) \ + printf ("OK"); \ + else \ + printf ("ERROR (%.60Lf)", value); \ + printf ("\n"); + +static void +do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) +{ + long double value; + long double *ld; + va_list args; + + CLEAR_VALUE + printf ("fscanf: "); + FSCANF (stream, format, &value); + CHECK_VALUE + + CLEAR_VALUE + printf ("scanf: "); + SCANF (format, &value); + CHECK_VALUE + + CLEAR_VALUE + printf ("sscanf: "); + SSCANF (string, format, &value); + CHECK_VALUE + + CLEAR + printf ("vfscanf: "); + va_start (args, format); + VFSCANF (stream, format, args); + va_end (args); + CHECK + + CLEAR + printf ("vscanf: "); + va_start (args, format); + VSCANF (format, args); + va_end (args); + CHECK + + CLEAR + printf ("vsscanf: "); + va_start (args, format); + VSSCANF (string, format, args); + va_end (args); + CHECK +} + +static int +do_test (void) +{ + CHAR string[256]; + long double ld; + + /* Scan in decimal notation. */ + STRCPY (string, + L ("-1.0\n") + L ("-1.0\n") ); + do_test_call (stdin, string, L("%Lf"), &ld); + + /* Scan in hexadecimal notation. */ + STRCPY (string, + L ("-0x1.0p+0\n") + L ("-0x1.0p+0\n") ); + do_test_call (stdin, string, L("%La"), &ld); + + return 0; +} + +#include 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 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 +# . + +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 From patchwork Fri Oct 25 15:33:48 2019 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: 1184245 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106316-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="hqymH52n"; 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 4707W74C2Sz9sPh for ; Sat, 26 Oct 2019 02:36:19 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=QL656s+9MSorfqF6bZeNAs68tTxgegK6zuMatrUd1xY itgJHShDUqTLvxe8ewxQ3FBwN1aIn34i+QCYswFHVcaML9MM8gFkVOFcBn9RI14i 54RQFeAACGz8Lf4nxyzl+lQM2vVeNXX8NuVuPYa5eGV6naFRvyKKnA19xH8x9K1A = 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-transfer-encoding:content-type; s=default; bh=eHZrLxwQ04EhR7xlaT2SClSgTOY=; b=hqymH52n2WTaWw7kd /ItYLxn41yzlULrEpr5Zh5mOdokJ8LL6F92oRdc6XZXhgJ9uUYwZ/9BDR5ZxlqFC Ef0Ov4t9X+WcP+vSAMls5W4PxI1CZxABPgf1Lg67DK6x7htY5CBefJeEBz3SHOgs 97ahxfRdRXOwgrdxr3UiYDvl5U= Received: (qmail 107121 invoked by alias); 25 Oct 2019 15:35:22 -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 107057 invoked by uid 89); 25 Oct 2019 15:35:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 08/30] ldbl-128ibm-compat: Add wide character scanning functions Date: Fri, 25 Oct 2019 12:33:48 -0300 Message-ID: <20191025153410.15405-9-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1599059346794794691 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Similarly to what was done for regular character scanning functions, this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, in the 'mode' argument of the wide characters scanning function, __vfwscanf_internal (which is also extended to support scanning floating-point values with IEEE binary128, by redirecting calls to __wcstold_internal to __wcstof128_internal). Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 33 ++++++++++++++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 ++++ .../ldbl-128ibm-compat/ieee128-fwscanf.c | 35 ++++++++++++++++ .../ldbl-128ibm-compat/ieee128-swscanf.c | 40 +++++++++++++++++++ .../ldbl-128ibm-compat/ieee128-vfwscanf.c | 27 +++++++++++++ .../ldbl-128ibm-compat/ieee128-vswscanf.c | 32 +++++++++++++++ .../ldbl-128ibm-compat/ieee128-vwscanf.c | 27 +++++++++++++ .../ldbl-128ibm-compat/ieee128-wscanf.c | 35 ++++++++++++++++ .../ldbl-128ibm-compat/test-wscanf-ibm128.c | 1 + .../ldbl-128ibm-compat/test-wscanf-ieee128.c | 1 + .../test-wscanf-ldbl-compat.c | 10 +++++ 11 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index a1f0f7d74e..031ee0b38f 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -1,3 +1,11 @@ +ifeq ($(subdir),libio) +ldbl-extra-routines += fwscanf \ + swscanf \ + wscanf \ + vswscanf \ + vwscanf +endif + ifeq ($(subdir),stdio-common) ldbl-extra-routines += printf_size \ asprintf \ @@ -23,7 +31,8 @@ ldbl-extra-routines += printf_size \ sscanf \ vfscanf \ vscanf \ - vsscanf + vsscanf \ + vfwscanf # Printing long double values with IEEE binary128 format reuses part # of the internal float128 implementation (__printf_fp, __printf_fphex, @@ -34,6 +43,7 @@ ldbl-extra-routines += printf_size \ CFLAGS-vfprintf-internal.c += -mfloat128 -mabi=ibmlongdouble CFLAGS-vfwprintf-internal.c += -mfloat128 -mabi=ibmlongdouble CFLAGS-vfscanf-internal.c += -mfloat128 -mabi=ibmlongdouble +CFLAGS-vfwscanf-internal.c += -mfloat128 -mabi=ibmlongdouble # Basic tests for the implementation of long double with IEEE binary128 # format and for the related redirections in installed headers. @@ -51,9 +61,18 @@ CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi $(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link) +tests-internal += test-wscanf-ieee128 test-wscanf-ibm128 +CFLAGS-test-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +$(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link) + ifeq ($(run-built-tests),yes) tests-special += $(objpfx)test-scanf-ieee128.out tests-special += $(objpfx)test-scanf-ibm128.out + +tests-special += $(objpfx)test-wscanf-ieee128.out +tests-special += $(objpfx)test-wscanf-ibm128.out endif $(objpfx)test-scanf-ieee128.out: \ @@ -68,6 +87,18 @@ $(objpfx)test-scanf-ibm128.out: \ $(SHELL) $^ '$(test-program-prefix)' $@; \ $(evaluate-test) +$(objpfx)test-wscanf-ieee128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \ + $(objpfx)test-wscanf-ieee128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + +$(objpfx)test-wscanf-ibm128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \ + $(objpfx)test-wscanf-ibm128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + tests-internal += test-printf-size-ieee128 test-printf-size-ibm128 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 7971c7a7d1..8b23fdf56f 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -172,5 +172,13 @@ libc { __vfscanfieee128; __vscanfieee128; __vsscanfieee128; + + __fwscanfieee128; + __swscanfieee128; + __wscanfieee128; + + __vfwscanfieee128; + __vswscanfieee128; + __vwscanfieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c new file mode 100644 index 0000000000..b4b10cf9f8 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c @@ -0,0 +1,35 @@ +/* Wrapper for fwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +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 + . */ + +#include +#include +#include + +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 + . */ + +#include + +extern int +___ieee128_vfwscanf (FILE *fp, const wchar_t *format, va_list ap) +{ + return __vfwscanf_internal (fp, format, ap, + SCANF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vfwscanf, __vfwscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c new file mode 100644 index 0000000000..a241d6bd5e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c @@ -0,0 +1,32 @@ +/* Wrapper for vswscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +extern int +___ieee128_vswscanf (const wchar_t *string, const wchar_t *format, + va_list ap) +{ + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *fp = _IO_strfile_readw (&sf, &wd, string); + return __vfwscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vswscanf, __vswscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c new file mode 100644 index 0000000000..0944794ac5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c @@ -0,0 +1,27 @@ +/* Wrapper for vwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +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 + . */ + +#include +#include + +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 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 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 From patchwork Fri Oct 25 15:33:49 2019 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: 1184246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106317-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="oFSvONjG"; 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 4707WL4bZ4z9sQn for ; Sat, 26 Oct 2019 02:36:30 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=STAN4sTUOwIruLxdTNy7h01e1OgFxtegxdfmuGlq6G9 dDflaLv7A6y5IcUlnli5oZinatI7/r0Ht5hwjhjS1q9i9HHntXqwrWHf051KL4SP h2Rdmlnl/HQMqZQ0G2Q9RKnNaAw0K9/CJjeaW+k5xqhhhPPFQ4Htz0B4CRqS7mog = 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-transfer-encoding:content-type; s=default; bh=0y0iN2h/kHknAQxLWQf/BVhWgI4=; b=oFSvONjGOGHgw91dv CaG84ij1UyWJfmx8nUBJ9muF/j0JiyNQBL647YlZ7L0ZaVW8p0U8igybM/5U/vpp 4NT0SlQhn9ICtx2whc69rMSb8k86T/oJAwVeHRLAh0xYMLbA9bRSo1zt/o4J59X2 sXKVkvyM8dBKM2MCNKXD9GAOJ0= Received: (qmail 107344 invoked by alias); 25 Oct 2019 15:35:23 -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 107246 invoked by uid 89); 25 Oct 2019 15:35:23 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:3754 X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 09/30] ldbl-128ibm-compat: Add argp_error and argp_failure Date: Fri, 25 Oct 2019 12:33:49 -0300 Message-ID: <20191025153410.15405-10-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1600466721758170819 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Use the recently added, internal functions, __argp_error_internal and __argp_failure_internal, to provide argp_error and argp_failure that can take long double arguments with IEEE binary128 format on platforms where long double can also take double format or some non-IEEE format (currently, this means powerpc64le). Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 14 +++++++ sysdeps/ieee754/ldbl-128ibm-compat/Versions | 3 ++ .../ldbl-128ibm-compat/ieee128-argp-help.c | 42 +++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 031ee0b38f..dc1ceaae7e 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -160,6 +160,20 @@ CFLAGS-test-wprintf-chk-redir-ibm128.c += -mabi=ibmlongdouble -Wno-psabi \ -Wno-unused-result endif +ifeq ($(subdir),argp) +ldbl-extra-routines += argp-help + +$(objpfx)tst-ieee128-argp.c: tst-ldbl-argp.c + cp $< $@ + +$(objpfx)tst-ibm128-argp.c: tst-ldbl-argp.c + cp $< $@ + +tests-internal += tst-ieee128-argp tst-ibm128-argp +CFLAGS-tst-ieee128-argp.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi +endif + # Add IEEE binary128 files as make targets. routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 8b23fdf56f..8e80b2bade 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -180,5 +180,8 @@ libc { __vfwscanfieee128; __vswscanfieee128; __vwscanfieee128; + + __argp_errorieee128; + __argp_failureieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c new file mode 100644 index 0000000000..fe77e633df --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-argp-help.c @@ -0,0 +1,42 @@ +/* Wrapper for argp_error and argp_failure. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +void +___ieee128_argp_error (const struct argp_state *state, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + __argp_error_internal (state, fmt, ap, PRINTF_LDBL_USES_FLOAT128); + va_end (ap); +} +strong_alias (___ieee128_argp_error, __argp_errorieee128) + +void +___ieee128_argp_failure (const struct argp_state *state, int status, + int errnum, const char *fmt, ...) +{ + va_list ap; + va_start (ap, fmt); + __argp_failure_internal (state, status, errnum, fmt, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); +} +strong_alias (___ieee128_argp_failure, __argp_failureieee128) From patchwork Fri Oct 25 15:33:50 2019 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: 1184247 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106318-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ucQbgPH+"; 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 4707WX6LZWz9sPf for ; Sat, 26 Oct 2019 02:36:40 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=sevZKYZi2OVKl/B9HIkzNZt7R0BYnCjWW1s4PK3yZHZ kuH8U0REgxdyo++SANzbBAjqi4/8uty0WibtMgRXCUAeTkF5VWx/Ua0zS/IM9x9E nx+VLGphUM2fTieW7EnJjQLQurwD0ruUcXxAJG8awxNkWzynACpwF2IzgM0tGXCA = 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-transfer-encoding:content-type; s=default; bh=pRx4vKeh3QPfFb8NdOgaLuTB5Lw=; b=ucQbgPH+Jbvxk6CQE 7nLW5OFuyi3FdgJ76ARN/pIsCR7KPedlJueEXGZ9Ayhwlx9dPOMpi6YiVg577ckd WMpnYOdZhdfoW/a9idK81OHNb3rEalvHSaEhTaRRk3IAEM3hyxilVKzWQXY2WA1d pA5jDgU96sTaiXDsXQ6DaRmO04= Received: (qmail 107866 invoked by alias); 25 Oct 2019 15:35:28 -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 107791 invoked by uid 89); 25 Oct 2019 15:35:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 10/30] ldbl-128ibm-compat: Add err.h functions Date: Fri, 25 Oct 2019 12:33:50 -0300 Message-ID: <20191025153410.15405-11-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1601874095374126787 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Use the recently added, internal functions, __vwarnx_internal and __vwarn_internal, to provide err.h functions that can take long double arguments with IEEE binary128 format on platforms where long double can also take double format or some non-IEEE format (currently, this means powerpc64le). Tested for powerpc64le. --- misc/errP.h | 28 ++++++ sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 4 + sysdeps/ieee754/ldbl-128ibm-compat/Versions | 9 ++ .../ieee754/ldbl-128ibm-compat/ieee128-err.c | 93 +++++++++++++++++++ 4 files changed, 134 insertions(+) create mode 100644 misc/errP.h create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c diff --git a/misc/errP.h b/misc/errP.h new file mode 100644 index 0000000000..09e1f72289 --- /dev/null +++ b/misc/errP.h @@ -0,0 +1,28 @@ +/* Prototypes for internal err.h functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +void +__vwarnx_internal (const char *format, __gnuc_va_list ap, + unsigned int mode_flags); + +void +__vwarn_internal (const char *format, __gnuc_va_list ap, + unsigned int mode_flags); diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index dc1ceaae7e..6bb0bed2fc 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -174,6 +174,10 @@ CFLAGS-tst-ieee128-argp.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi endif +ifeq ($(subdir),misc) +ldbl-extra-routines += err +endif + # Add IEEE binary128 files as make targets. routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 8e80b2bade..e2b3dda551 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -183,5 +183,14 @@ libc { __argp_errorieee128; __argp_failureieee128; + + __warnieee128; + __warnxieee128; + __vwarnieee128; + __vwarnxieee128; + __errieee128; + __errxieee128; + __verrieee128; + __verrxieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c new file mode 100644 index 0000000000..8a34508e5e --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-err.c @@ -0,0 +1,93 @@ +/* Wrappers for err.h functions. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#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) From patchwork Fri Oct 25 15:33:51 2019 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: 1184248 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106319-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="wL70D/We"; 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 4707Wl0Fw3z9sPf for ; Sat, 26 Oct 2019 02:36:50 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=q0PpznmUEBlRTpX1jxGLrhxVxxnzLmkP5qVSgvMQFq/ cWe7kigdfPggvQBaQI0YasX5CtALIlOwZYTXHADAhRHrwLO2suW39z57BmPPAanF jr7AIcqGFyPBfwnlVYMSRqikOChIH6XuXJT/35P8XQm6TLC5jzxPeoYs62aKhTfI = 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-transfer-encoding:content-type; s=default; bh=AIom0iXS6Wfzlg3VejwNoQutHSM=; b=wL70D/WeNmcW8wiJ3 quGhW/dE1vn11vIp8KWYXz5R+CbhVpi0scuPbutde3qJhzOGCHLSSR6DUUWzCNTS 0fl0UVENDc0pQNRQYgKIn8cniM8vNtiiT1BhKzv/9fpJN6Xz6gJPRcOg+fVxqbDK spjXcFzN6A/io8HGhuosDSKh2U= Received: (qmail 108553 invoked by alias); 25 Oct 2019 15:35:34 -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 108500 invoked by uid 89); 25 Oct 2019 15:35:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 11/30] ldbl-128ibm-compat: Add error.h functions Date: Fri, 25 Oct 2019 12:33:51 -0300 Message-ID: <20191025153410.15405-12-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1603281470435413699 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Use the recently added, internal functions, __error_at_line_internal and __error_internal, to provide error.h functions that can take long double arguments with IEEE binary128 format on platforms where long double can also take double format or some non-IEEE format (currently, this means powerpc64le). Tested for powerpc64le. --- misc/errorP.h | 28 ++++++++++ sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 3 +- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 3 ++ .../ldbl-128ibm-compat/ieee128-error.c | 51 +++++++++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 misc/errorP.h create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c diff --git a/misc/errorP.h b/misc/errorP.h new file mode 100644 index 0000000000..c61c49cd61 --- /dev/null +++ b/misc/errorP.h @@ -0,0 +1,28 @@ +/* Prototypes for internal error.h functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +void +__error_internal (int status, int errnum, const char *message, + va_list args, unsigned int mode_flags); + +void +__error_at_line_internal (int status, int errnum, const char *file_name, + unsigned int line_number, const char *message, + va_list args, unsigned int mode_flags); diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 6bb0bed2fc..a09209a2dd 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -175,7 +175,8 @@ CFLAGS-tst-ibm128-argp.c += -mabi=ibmlongdouble -Wno-psabi endif ifeq ($(subdir),misc) -ldbl-extra-routines += err +ldbl-extra-routines += err \ + error endif # Add IEEE binary128 files as make targets. diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index e2b3dda551..dead38cdcb 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -192,5 +192,8 @@ libc { __errxieee128; __verrieee128; __verrxieee128; + + __errorieee128; + __error_at_lineieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c new file mode 100644 index 0000000000..9c74e060d7 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-error.c @@ -0,0 +1,51 @@ +/* Wrappers for error.h functions. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#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) From patchwork Fri Oct 25 15:33:52 2019 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: 1184249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106320-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ZZpP7Rd8"; 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 4707Wx59DRz9sPk for ; Sat, 26 Oct 2019 02:37:01 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=I4Vg0asOaKPuPaboxHiJoBPFwJj5WZRBM0zYDtUqdFy lB2DflqA3Td/hFBiHBwxNFNEnt3Cub+tyrYS/pjLXrD/qlMjjvCMOWtDpZueEj11 51qcPs/WWwNDNKGO8g0vDtmCmemMMUBqXfrx/cspiU05Gts2bRPABKNZ25n0sIX4 = 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-transfer-encoding:content-type; s=default; bh=7b5C0EOUkB7fweHgUVPTT98uydM=; b=ZZpP7Rd8CutAbnOrN UXBbzAtAC2bRlDiKaglPDn7By3EtCO298/CP1ESJtfqwDO3XTUNpz0jp3L6gK4wG NSas92qYdWQl8sxsDe3U5hHcqHFPrbJrvvhj/260/t4IVKRtDVBU66SemTiFdbwY 4/GrBKHLeoG1X9sY3JJp6pA1eQ= Received: (qmail 109127 invoked by alias); 25 Oct 2019 15:35: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 109071 invoked by uid 89); 25 Oct 2019 15:35:38 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*F:D*br, HContent-Transfer-Encoding:8bit X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 12/30] ldbl-128ibm-compat: Reuse tests for err.h and error.h functions Date: Fri, 25 Oct 2019 12:33:52 -0300 Message-ID: <20191025153410.15405-13-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1604688846307315395 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Commit IDs 9771e6cb5102 and 7597b0c7f711 added tests for the functions from err.h and error.h that can take long double parameters. Afterwards, commit ID f0eaf8627654 reused them on architectures that changed the long double format from the same as double to something else (i.e.: architectures that imply ldbl-opt). This patch reuses it again for IEEE long double on powerpc64le. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index a09209a2dd..ed0e2ec098 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -177,6 +177,21 @@ endif ifeq ($(subdir),misc) ldbl-extra-routines += err \ error + +tests-internal += tst-ibm128-warn tst-ieee128-warn +tests-internal += tst-ibm128-error tst-ieee128-error + +$(objpfx)tst-ibm128-%.c: tst-ldbl-%.c + cp $< $@ + +$(objpfx)tst-ieee128-%.c: tst-ldbl-%.c + cp $< $@ + +CFLAGS-tst-ibm128-warn.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi + +CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi endif # Add IEEE binary128 files as make targets. From patchwork Fri Oct 25 15:33:53 2019 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: 1184250 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106321-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="oO7SRFLj"; 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 4707X75cD3z9sPl for ; Sat, 26 Oct 2019 02:37:11 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=jVgDe1fGOW8HaTciBP4WkZUahdl5TD71TbZ1vApb4wa 8j9zB90OJDNShXXpH9EF+liF4SPqV1YzFs8Bqdq4c9VyN7i+zUb4PVayEuaQUDYS 8Wu9qnqSyPEpIMaSFg3hp0llM7Kc2ZBWhIuBo12Ax716+g8EaV/qb+bWL6vvLPic = 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-transfer-encoding:content-type; s=default; bh=x8hCesjxFbjNEC2K9Wg4sp5f5Kc=; b=oO7SRFLjQ0SMaR2NM byh5/m0L0y8/qSwGrtAb581xm3IgohXQmrDU4d0hVux+/HXMoFG19j9uj4x3QHsf kM7LYZBQCySt32kXJIljYQoK/sVow6np/+pIxJwR8sxaIrh+lqbWpiLZBRju4tSC lP9uj/NpDzTwkrwBvBOedClRso= Received: (qmail 110270 invoked by alias); 25 Oct 2019 15:35: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 110205 invoked by uid 89); 25 Oct 2019 15:35:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 13/30] ldbl-128ibm-compat: Add ISO C99 versions of scanf functions Date: Fri, 25 Oct 2019 12:33:53 -0300 Message-ID: <20191025153410.15405-14-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1606377692939603651 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- In the format string for *scanf functions, the '%as', '%aS', and '%a[]' modifiers behave differently depending on ISO C99 compatibility and on _GNU_SOURCE. When _GNU_SOURCE is not set and when in compatibility with ISO C99, these modifiers consume a floating-point argument. Otherwise, they behave like ascanf, and allocate memory for the output. This patch adds the IEEE binary128 variant of these functions for the third long double format on powerpc64le. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 59 ++++++++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 16 +++ .../ieee128-isoc99_fscanf.c | 35 ++++++ .../ieee128-isoc99_fwscanf.c | 35 ++++++ .../ldbl-128ibm-compat/ieee128-isoc99_scanf.c | 35 ++++++ .../ieee128-isoc99_sscanf.c | 39 ++++++ .../ieee128-isoc99_swscanf.c | 40 ++++++ .../ieee128-isoc99_vfscanf.c | 27 ++++ .../ieee128-isoc99_vfwscanf.c | 27 ++++ .../ieee128-isoc99_vscanf.c | 27 ++++ .../ieee128-isoc99_vsscanf.c | 30 +++++ .../ieee128-isoc99_vswscanf.c | 32 +++++ .../ieee128-isoc99_vwscanf.c | 27 ++++ .../ieee128-isoc99_wscanf.c | 35 ++++++ .../test-isoc99-scanf-ibm128.c | 13 ++ .../test-isoc99-scanf-ieee128.c | 13 ++ .../test-isoc99-scanf-ldbl-compat-template.c | 119 ++++++++++++++++++ .../test-isoc99-scanf-ldbl-compat.c | 10 ++ .../test-isoc99-scanf-ldbl-compat.sh | 53 ++++++++ .../test-isoc99-wscanf-ibm128.c | 13 ++ .../test-isoc99-wscanf-ieee128.c | 13 ++ .../test-isoc99-wscanf-ldbl-compat.c | 10 ++ .../test-scanf-ldbl-compat-template.c | 4 + 23 files changed, 711 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index ed0e2ec098..1f944806e7 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -6,6 +6,15 @@ ldbl-extra-routines += fwscanf \ vwscanf endif +ifeq ($(subdir),wcsmbs) +ldbl-extra-routines += isoc99_fwscanf \ + isoc99_swscanf \ + isoc99_wscanf \ + isoc99_vfwscanf \ + isoc99_vswscanf \ + isoc99_vwscanf +endif + ifeq ($(subdir),stdio-common) ldbl-extra-routines += printf_size \ asprintf \ @@ -32,7 +41,13 @@ ldbl-extra-routines += printf_size \ vfscanf \ vscanf \ vsscanf \ - vfwscanf + vfwscanf \ + isoc99_fscanf \ + isoc99_scanf \ + isoc99_sscanf \ + isoc99_vfscanf \ + isoc99_vscanf \ + isoc99_vsscanf # Printing long double values with IEEE binary128 format reuses part # of the internal float128 implementation (__printf_fp, __printf_fphex, @@ -67,12 +82,30 @@ CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi $(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link) +tests-internal += test-isoc99-scanf-ieee128 test-isoc99-scanf-ibm128 +CFLAGS-test-isoc99-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c99 +CFLAGS-test-isoc99-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c99 + +$(objpfx)test-isoc99-scanf-ieee128: gnulib-tests += $(f128-loader-link) + +tests-internal += test-isoc99-wscanf-ieee128 test-isoc99-wscanf-ibm128 +CFLAGS-test-isoc99-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi -std=c99 +CFLAGS-test-isoc99-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi -std=c99 + +$(objpfx)test-isoc99-wscanf-ieee128: gnulib-tests += $(f128-loader-link) + ifeq ($(run-built-tests),yes) tests-special += $(objpfx)test-scanf-ieee128.out tests-special += $(objpfx)test-scanf-ibm128.out tests-special += $(objpfx)test-wscanf-ieee128.out tests-special += $(objpfx)test-wscanf-ibm128.out + +tests-special += $(objpfx)test-isoc99-scanf-ieee128.out +tests-special += $(objpfx)test-isoc99-scanf-ibm128.out + +tests-special += $(objpfx)test-isoc99-wscanf-ieee128.out +tests-special += $(objpfx)test-isoc99-wscanf-ibm128.out endif $(objpfx)test-scanf-ieee128.out: \ @@ -99,6 +132,30 @@ $(objpfx)test-wscanf-ibm128.out: \ $(SHELL) $^ '$(test-program-prefix)' $@; \ $(evaluate-test) +$(objpfx)test-isoc99-scanf-ieee128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \ + $(objpfx)test-isoc99-scanf-ieee128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + +$(objpfx)test-isoc99-scanf-ibm128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \ + $(objpfx)test-isoc99-scanf-ibm128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + +$(objpfx)test-isoc99-wscanf-ieee128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \ + $(objpfx)test-isoc99-wscanf-ieee128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + +$(objpfx)test-isoc99-wscanf-ibm128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh \ + $(objpfx)test-isoc99-wscanf-ibm128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + tests-internal += test-printf-size-ieee128 test-printf-size-ibm128 CFLAGS-test-printf-size-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-printf-size-ibm128.c += -mabi=ibmlongdouble -Wno-psabi diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index dead38cdcb..23c2fd9793 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -181,6 +181,22 @@ libc { __vswscanfieee128; __vwscanfieee128; + __isoc99_fscanfieee128; + __isoc99_scanfieee128; + __isoc99_sscanfieee128; + + __isoc99_vfscanfieee128; + __isoc99_vscanfieee128; + __isoc99_vsscanfieee128; + + __isoc99_fwscanfieee128; + __isoc99_swscanfieee128; + __isoc99_wscanfieee128; + + __isoc99_vfwscanfieee128; + __isoc99_vswscanfieee128; + __isoc99_vwscanfieee128; + __argp_errorieee128; __argp_failureieee128; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c new file mode 100644 index 0000000000..3930170878 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fscanf.c @@ -0,0 +1,35 @@ +/* Wrapper for __isoc99_fscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_isoc99_fscanf (FILE *fp, const char *format, ...) +{ + va_list arg; + int done; + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + + va_start (arg, format); + done = __vfscanf_internal (fp, format, arg, mode_flags); + va_end (arg); + + return done; +} +strong_alias (___ieee128_isoc99_fscanf, __isoc99_fscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c new file mode 100644 index 0000000000..d56ecfbaf2 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_fwscanf.c @@ -0,0 +1,35 @@ +/* Wrapper for __isoc99_fwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_isoc99_fwscanf (FILE *fp, const wchar_t *format, ...) +{ + va_list ap; + int done; + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + + va_start (ap, format); + done = __vfwscanf_internal (fp, format, ap, mode_flags); + va_end (ap); + + return done; +} +strong_alias (___ieee128_isoc99_fwscanf, __isoc99_fwscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c new file mode 100644 index 0000000000..5b643fb108 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_scanf.c @@ -0,0 +1,35 @@ +/* Wrapper for __isoc99_scanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_isoc99_scanf (const char *format, ...) +{ + va_list arg; + int done; + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + + va_start (arg, format); + done = __vfscanf_internal (stdin, format, arg, mode_flags); + va_end (arg); + + return done; +} +strong_alias (___ieee128_isoc99_scanf, __isoc99_scanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c new file mode 100644 index 0000000000..480357ccd5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_sscanf.c @@ -0,0 +1,39 @@ +/* Wrapper for __isoc99_sscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +extern int +___ieee128_isoc99_sscanf (const char *string, const char *format, ...) +{ + va_list arg; + int done; + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + + _IO_strfile sf; + FILE *fp = _IO_strfile_read (&sf, string); + + va_start (arg, format); + done = __vfscanf_internal (fp, format, arg, mode_flags); + va_end (arg); + + return done; +} +strong_alias (___ieee128_isoc99_sscanf, __isoc99_sscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c new file mode 100644 index 0000000000..e18779a986 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_swscanf.c @@ -0,0 +1,40 @@ +/* Wrapper for __isoc99_swscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +extern int +___ieee128_isoc99_swscanf (const wchar_t *string, const wchar_t *format, ...) +{ + va_list ap; + int done; + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *fp = _IO_strfile_readw (&sf, &wd, string); + + va_start (ap, format); + done = __vfwscanf_internal (fp, format, ap, mode_flags); + va_end (ap); + + return done; +} +strong_alias (___ieee128_isoc99_swscanf, __isoc99_swscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c new file mode 100644 index 0000000000..2d131f7fee --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfscanf.c @@ -0,0 +1,27 @@ +/* Wrapper for __isoc99_vfscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_isoc99_vfscanf (FILE *fp, const char *format, va_list ap) +{ + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + return __vfscanf_internal (fp, format, ap, mode_flags); +} +strong_alias (___ieee128_isoc99_vfscanf, __isoc99_vfscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c new file mode 100644 index 0000000000..a281ecc451 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vfwscanf.c @@ -0,0 +1,27 @@ +/* Wrapper for __isoc99_vfwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_isoc99_vfwscanf (FILE *fp, const wchar_t *format, va_list ap) +{ + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + return __vfwscanf_internal (fp, format, ap, mode_flags); +} +strong_alias (___ieee128_isoc99_vfwscanf, __isoc99_vfwscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c new file mode 100644 index 0000000000..6ec60d5dc0 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vscanf.c @@ -0,0 +1,27 @@ +/* Wrapper for __isoc99_vscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_isoc99_vscanf (const char *format, va_list ap) +{ + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + return __vfscanf_internal (stdin, format, ap, mode_flags); +} +strong_alias (___ieee128_isoc99_vscanf, __isoc99_vscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c new file mode 100644 index 0000000000..599e86820d --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vsscanf.c @@ -0,0 +1,30 @@ +/* Wrapper for __isoc99_vsscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_isoc99_vsscanf (const char *string, const char *format, va_list ap) +{ + _IO_strfile sf; + FILE *fp = _IO_strfile_read (&sf, string); + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + return __vfscanf_internal (fp, format, ap, mode_flags); +} +strong_alias (___ieee128_isoc99_vsscanf, __isoc99_vsscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c new file mode 100644 index 0000000000..3a28616c26 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vswscanf.c @@ -0,0 +1,32 @@ +/* Wrapper for __isoc99_vswscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +extern int +___ieee128_isoc99_vswscanf (wchar_t *string, const wchar_t *format, va_list ap) +{ + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *fp = _IO_strfile_readw (&sf, &wd, string); + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + return __vfwscanf_internal (fp, format, ap, mode_flags); +} +strong_alias (___ieee128_isoc99_vswscanf, __isoc99_vswscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c new file mode 100644 index 0000000000..b9bd4a78f0 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_vwscanf.c @@ -0,0 +1,27 @@ +/* Wrapper for __isoc99_vwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128_isoc99_vwscanf (const wchar_t *format, va_list ap) +{ + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + return __vfwscanf_internal (stdin, format, ap, mode_flags); +} +strong_alias (___ieee128_isoc99_vwscanf, __isoc99_vwscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c new file mode 100644 index 0000000000..e78b4a3143 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-isoc99_wscanf.c @@ -0,0 +1,35 @@ +/* Wrapper for __isoc99_wscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_isoc99_wscanf (const wchar_t *format, ...) +{ + va_list ap; + int done; + int mode_flags = SCANF_ISOC99_A | SCANF_LDBL_USES_FLOAT128; + + va_start (ap, format); + done = __vfwscanf_internal (stdin, format, ap, mode_flags); + va_end (ap); + + return done; +} +strong_alias (___ieee128_isoc99_wscanf, __isoc99_wscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c new file mode 100644 index 0000000000..70688ac2bb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ibm128.c @@ -0,0 +1,13 @@ +#undef _GNU_SOURCE +/* The following macro definitions are a hack. They word around disabling + the GNU extension while still using a few internal headers. */ +#define u_char unsigned char +#define u_short unsigned short +#define u_int unsigned int +#define u_long unsigned long +#include +#include +#include +#include + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c new file mode 100644 index 0000000000..70688ac2bb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ieee128.c @@ -0,0 +1,13 @@ +#undef _GNU_SOURCE +/* The following macro definitions are a hack. They word around disabling + the GNU extension while still using a few internal headers. */ +#define u_char unsigned char +#define u_short unsigned short +#define u_int unsigned int +#define u_long unsigned long +#include +#include +#include +#include + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c new file mode 100644 index 0000000000..ffc7ca2aaa --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat-template.c @@ -0,0 +1,119 @@ +/* Test for the long double variants of __isoc99_*scanf functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include + +#include + +#define CLEAR_VARGS \ + va_start (args, format); \ + ldptr = va_arg (args, long double *); \ + fptr = va_arg (args, float *); \ + *ldptr = 0; \ + *fptr = 0; \ + va_end (args); + +#define CHECK_VARGS \ + va_start (args, format); \ + ldptr = va_arg (args, long double *); \ + fptr = va_arg (args, float *); \ + va_end (args); \ + if (*ldptr == -1 && *fptr == -2) \ + printf ("OK"); \ + else \ + printf ("ERROR (%Lf %f)", *ldptr, *fptr); \ + printf ("\n"); + +#define CLEAR_VALUE \ + ld = 0; \ + f = 0; + +#define CHECK_VALUE \ + if (ld == -1 && f == -2) \ + printf ("OK"); \ + else \ + printf ("ERROR (%Lf %f)", ld, f); \ + printf ("\n"); + +static void +do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) +{ + float *fptr; + float f; + long double *ldptr; + long double ld; + va_list args; + + CLEAR_VALUE + printf ("fscanf: "); + FSCANF (stream, format, &ld, &f); + CHECK_VALUE + + CLEAR_VALUE + printf ("scanf: "); + SCANF (format, &ld, &f); + CHECK_VALUE + + CLEAR_VALUE + printf ("sscanf: "); + SSCANF (string, format, &ld, &f); + CHECK_VALUE + + CLEAR_VARGS + printf ("vfscanf: "); + va_start (args, format); + VFSCANF (stream, format, args); + va_end (args); + CHECK_VARGS + + CLEAR_VARGS + printf ("vscanf: "); + va_start (args, format); + VSCANF (format, args); + va_end (args); + CHECK_VARGS + + CLEAR_VARGS + printf ("vsscanf: "); + va_start (args, format); + VSSCANF (string, format, args); + va_end (args); + CHECK_VARGS +} + +static int +do_test (void) +{ + CHAR string[256]; + float f; + long double ld; + + /* Scan floating-point value with '%as'. */ + STRCPY (string, + L ("-0x1.0p+0 -0x2.0p+0\n") + L ("-0x1.0p+0 -0x2.0p+0\n") ); + do_test_call (stdin, string, L("%La %as"), &ld, &f); + + return 0; +} + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c new file mode 100644 index 0000000000..739b6bb479 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.c @@ -0,0 +1,10 @@ +#define CHAR char +#define L(x) x +#define FSCANF fscanf +#define SSCANF sscanf +#define SCANF scanf +#define VFSCANF vfscanf +#define VSSCANF vsscanf +#define VSCANF vscanf +#define STRCPY strcpy +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh new file mode 100644 index 0000000000..fc08beddc5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-scanf-ldbl-compat.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Testing of __isoc99_*scanf. IEEE binary128 for powerpc64le version. +# Copyright (C) 2018 Free Software Foundation, Inc. +# This file is part of the GNU C Library. + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, see +# . + +set -e + +test_program=$1; shift +test_program_prefix=$1; shift +test_program_output=$1; shift + +status=0 + +cat <<'EOF' | +-0x1.0p+0 -0x2.0p+0 +-0x1.0p+0 -0x2.0p+0 +-0x1.0p+0 -0x2.0p+0 +-0x1.0p+0 -0x2.0p+0 +EOF +${test_program_prefix} \ + ${test_program} \ + - \ + > ${test_program_output} || status=1 + +cat <<'EOF' | +fscanf: OK +scanf: OK +sscanf: OK +vfscanf: OK +vscanf: OK +vsscanf: OK +EOF +cmp - ${test_program_output} > /dev/null 2>&1 || +{ + status=1 + echo "*** output comparison failed" +} + +exit $status diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c new file mode 100644 index 0000000000..6be29624d9 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ibm128.c @@ -0,0 +1,13 @@ +#undef _GNU_SOURCE +/* The following macro definitions are a hack. They word around disabling + the GNU extension while still using a few internal headers. */ +#define u_char unsigned char +#define u_short unsigned short +#define u_int unsigned int +#define u_long unsigned long +#include +#include +#include +#include + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c new file mode 100644 index 0000000000..6be29624d9 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ieee128.c @@ -0,0 +1,13 @@ +#undef _GNU_SOURCE +/* The following macro definitions are a hack. They word around disabling + the GNU extension while still using a few internal headers. */ +#define u_char unsigned char +#define u_short unsigned short +#define u_int unsigned int +#define u_long unsigned long +#include +#include +#include +#include + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c new file mode 100644 index 0000000000..3ad29645f6 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-isoc99-wscanf-ldbl-compat.c @@ -0,0 +1,10 @@ +#define CHAR wchar_t +#define L(x) L##x +#define FSCANF fwscanf +#define SSCANF swscanf +#define SCANF wscanf +#define VFSCANF vfwscanf +#define VSSCANF vswscanf +#define VSCANF vwscanf +#define STRCPY wcscpy +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c index 4590e9da96..aea4f0d358 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c @@ -53,8 +53,10 @@ static void do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) { long double value; +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L long double *ld; va_list args; +#endif CLEAR_VALUE printf ("fscanf: "); @@ -71,6 +73,7 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) SSCANF (string, format, &value); CHECK_VALUE +#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L CLEAR printf ("vfscanf: "); va_start (args, format); @@ -91,6 +94,7 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...) VSSCANF (string, format, args); va_end (args); CHECK +#endif } static int From patchwork Fri Oct 25 15:33:54 2019 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: 1184251 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106322-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="DdKLwtUP"; 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 4707XP41Q8z9sPZ for ; Sat, 26 Oct 2019 02:37:25 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=pLtkqKQUXYWhrEXaribIWe3Mw9iSi9tEqR/ievWs1lZ 56wJqDVexmHgcPr4f2HownFTQ8jZHnZdpaCQag2UIjVRS/BBkMfWro8BmlHpPBvx 8XzKcXiOeCpz+g8nj7ArJ5j33zgieNGE0U/j2b42bCyZwAMasRUzzTH37RsQgtcI = 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-transfer-encoding:content-type; s=default; bh=MeiAwTdiqOE+7OdZHV7MgGaIgl8=; b=DdKLwtUPNUKBJjIH5 SE9RoRvWHSXc7+iSUzNSuu0yl+yyAw9MpKDSphFeRqkJUzCWdpL28kdt5Z9x6lq6 6t1PU+/rHBaW3LP/Vf06NFT4se9mDLYLFJDhmq6D0xIaREzlJSmpG91eG0xq7mOl d0auG5+57KqYsi18HPNvoWR238= Received: (qmail 110524 invoked by alias); 25 Oct 2019 15:35:51 -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 110474 invoked by uid 89); 25 Oct 2019 15:35:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 14/30] ldbl-128ibm-compat: Add obstack printing functions Date: Fri, 25 Oct 2019 12:33:54 -0300 Message-ID: <20191025153410.15405-15-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1608066543502216899 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Similarly to the functions from the *printf family, this patch adds implementations for __obstack_*printf* functions that set the 'mode_flags' parameter to PRINTF_LDBL_USES_FLOAT128, before making calls to __vfprintf_internal (indirectly through __obstack_vprintf_internal). Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 13 +++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 5 ++ .../ldbl-128ibm-compat/ieee128-obprintf.c | 42 ++++++++++++ .../ldbl-128ibm-compat/ieee128-obstack_chk.c | 39 +++++++++++ .../ldbl-128ibm-compat/ieee128-vobstack_chk.c | 31 +++++++++ .../test-obstack-chk-ibm128.c | 1 + .../test-obstack-chk-ieee128.c | 1 + .../test-obstack-chk-ldbl-compat.c | 6 ++ .../ldbl-128ibm-compat/test-obstack-ibm128.c | 1 + .../ldbl-128ibm-compat/test-obstack-ieee128.c | 1 + .../test-obstack-ldbl-compat-template.c | 64 +++++++++++++++++++ .../test-obstack-ldbl-compat.c | 6 ++ 12 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 1f944806e7..9e8237d075 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -47,7 +47,10 @@ ldbl-extra-routines += printf_size \ isoc99_sscanf \ isoc99_vfscanf \ isoc99_vscanf \ - isoc99_vsscanf + isoc99_vsscanf \ + obprintf \ + obstack_chk \ + vobstack_chk # Printing long double values with IEEE binary128 format reuses part # of the internal float128 implementation (__printf_fp, __printf_fphex, @@ -70,6 +73,14 @@ tests-internal += test-wprintf-ieee128 test-wprintf-ibm128 CFLAGS-test-wprintf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-wprintf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +tests-internal += test-obstack-ieee128 test-obstack-ibm128 +CFLAGS-test-obstack-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-obstack-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +tests-internal += test-obstack-chk-ieee128 test-obstack-chk-ibm128 +CFLAGS-test-obstack-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-obstack-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + tests-internal += test-scanf-ieee128 test-scanf-ibm128 CFLAGS-test-scanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 23c2fd9793..f59dfb59fe 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -165,6 +165,11 @@ libc { __vswprintf_chkieee128; __vwprintf_chkieee128; + __obstack_printfieee128; + __obstack_vprintfieee128; + __obstack_printf_chkieee128; + __obstack_vprintf_chkieee128; + __fscanfieee128; __scanfieee128; __sscanfieee128; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c new file mode 100644 index 0000000000..924838eed5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obprintf.c @@ -0,0 +1,42 @@ +/* Wrapper for obstack_vprintf and obstack_printf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +int +__ieee128_obstack_vprintf (struct obstack *obstack, const char *format, + va_list ap) +{ + return __obstack_vprintf_internal (obstack, format, ap, + PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (__ieee128_obstack_vprintf, __obstack_vprintfieee128) + +int +__ieee128_obstack_printf (struct obstack *obstack, const char *format, ...) +{ + int result; + va_list ap; + va_start (ap, format); + result = __obstack_vprintf_internal (obstack, format, ap, + PRINTF_LDBL_USES_FLOAT128); + va_end (ap); + return result; +} +strong_alias (__ieee128_obstack_printf, __obstack_printfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c new file mode 100644 index 0000000000..194589ca26 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-obstack_chk.c @@ -0,0 +1,39 @@ +/* Wrapper for __obstack_printf_chk. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +extern int +___ieee128_obstack_printf_chk (struct obstack *obstack, int flag, + const char *format, ...) +{ + va_list ap; + int done; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, format); + done = __obstack_vprintf_internal (obstack, format, ap, mode); + va_end (ap); + + return done; +} +strong_alias (___ieee128_obstack_printf_chk, __obstack_printf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c new file mode 100644 index 0000000000..fa5182aac9 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vobstack_chk.c @@ -0,0 +1,31 @@ +/* Wrapper for __obstack_vprintf_chk. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern int +___ieee128__obstack_vprintf_chk (struct obstack *obstack, int flag, + const char *format, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + return __obstack_vprintf_internal (obstack, format, ap, mode); +} +strong_alias (___ieee128__obstack_vprintf_chk, __obstack_vprintf_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c new file mode 100644 index 0000000000..ca4c9f2d22 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c new file mode 100644 index 0000000000..ca4c9f2d22 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c new file mode 100644 index 0000000000..feae8f21c6 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-chk-ldbl-compat.c @@ -0,0 +1,6 @@ +#define _FORTIFY_SOURCE 2 +#define OBSTACK_FUNCTION __obstack_printf_chk +#define OBSTACK_FUNCTION_PARAMS (&ob, 1, "%.30Lf", ld) +#define VOBSTACK_FUNCTION __obstack_vprintf_chk +#define VOBSTACK_FUNCTION_PARAMS (&ob, 1, "%.30Lf", ap) +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c new file mode 100644 index 0000000000..be88675030 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c new file mode 100644 index 0000000000..be88675030 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c new file mode 100644 index 0000000000..c82ddc4355 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat-template.c @@ -0,0 +1,64 @@ +/* Test for the long double variants of obstrack*printf functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include +#include + +#include + +#define obstack_chunk_alloc malloc +#define obstack_chunk_free free + +static void +do_test_call (void *last, ...) +{ + const char *expected = "-1.000000000000000000000000000000"; + char *actual = NULL; + long double ld = -1; + struct obstack ob; + va_list ap; + + obstack_init (&ob); + OBSTACK_FUNCTION OBSTACK_FUNCTION_PARAMS; + actual = (char *) obstack_finish (&ob); + TEST_VERIFY (strncmp (expected, actual, 33) == 0); + obstack_free (&ob, NULL); + actual = NULL; + + obstack_init (&ob); + va_start (ap, last); + VOBSTACK_FUNCTION VOBSTACK_FUNCTION_PARAMS; + va_end (ap); + actual = (char *) obstack_finish (&ob); + TEST_VERIFY (strncmp (expected, actual, 33) == 0); + obstack_free (&ob, NULL); + actual = NULL; +} + +static int +do_test (void) +{ + long double ld = -1; + do_test_call (NULL, ld); + return 0; +} + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c new file mode 100644 index 0000000000..3849d25ef1 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-obstack-ldbl-compat.c @@ -0,0 +1,6 @@ +#define _FORTIFY_SOURCE 0 +#define OBSTACK_FUNCTION obstack_printf +#define OBSTACK_FUNCTION_PARAMS (&ob, "%.30Lf", ld) +#define VOBSTACK_FUNCTION obstack_vprintf +#define VOBSTACK_FUNCTION_PARAMS (&ob, "%.30Lf", ap) +#include From patchwork Fri Oct 25 15:33:55 2019 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: 1184252 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106323-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ZfcYUH2e"; 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 4707Xb1bDhz9sPL for ; Sat, 26 Oct 2019 02:37:35 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=a0FTmh+HZuNXYtVlfnaNXTeIIxQzwCLaN/m3WJsyFY6 Akp7JupMlpB46zRIYdSdYXeUv1pR+xgGPEkYlWid5k/dOsYbkxcrT00ZBPuBJDxj DunTRQGTDRFvSwTSMfIj+PM/hjY+9NuU4FydH647sdOvEmGaefuXEMpc75s/Rh2E = 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-transfer-encoding:content-type; s=default; bh=E2Z09qeBWQJLhJKoCbkvZEelaEc=; b=ZfcYUH2etwEudvbhK 6VuFfN5FKouXbfITZykzU0R45/jrlwu0oHSqW14O9B89bRXljsdw0UAxZxA41gDq LL5RG5wzwmNyg/hEtJC3g/8Kh3KuycZaQG9zTsOkkzZcgRJns33I0wM67UakbNED UpuWxenLAr99RZAleFlodwyjm4= Received: (qmail 111070 invoked by alias); 25 Oct 2019 15:35:57 -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 111022 invoked by uid 89); 25 Oct 2019 15:35:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, UNSUBSCRIBE_BODY autolearn=ham version=3.3.1 spammy=disturb X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 15/30] ldbl-128ibm-compat: Add syslog functions Date: Fri, 25 Oct 2019 12:33:55 -0300 Message-ID: <20191025153410.15405-16-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1609755395398225603 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" Changes since v1: - Moved the test to a container, which stopped messages being written to the system log. Comment from v1: I'm using 'syslog (LOG_DEBUG, etc.);' and support_capture_subprocess in the test case, which I believe will not print to the console, but I'm not sure if changing some system setting to high verbosity will disturb people's lives. Please advise. :) -- 8< -- Similarly to __vfprintf_internal and __vfscanf_internal, the internal implementation of syslog functions (__vsyslog_internal) takes a 'mode_flags' parameter used to select the format of long double parameters. This patch adds variants of the syslog functions that set 'mode_flags' to PRINTF_LDBL_USES_FLOAT128, thus enabling the correct printing of long double values on powerpc64le, when long double has IEEE binary128 format (-mabi=ieeelongdouble). Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 11 ++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 5 ++ .../ldbl-128ibm-compat/ieee128-syslog.c | 65 ++++++++++++++++++ .../test-syslog-chk-ibm128.c | 1 + .../test-syslog-chk-ieee128.c | 1 + .../test-syslog-chk-ldbl-compat.c | 6 ++ .../ldbl-128ibm-compat/test-syslog-ibm128.c | 1 + .../ldbl-128ibm-compat/test-syslog-ieee128.c | 1 + .../test-syslog-ldbl-compat-template.c | 67 +++++++++++++++++++ .../test-syslog-ldbl-compat.c | 6 ++ 10 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 9e8237d075..d774c3b1d7 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -244,7 +244,8 @@ endif ifeq ($(subdir),misc) ldbl-extra-routines += err \ - error + error \ + syslog tests-internal += tst-ibm128-warn tst-ieee128-warn tests-internal += tst-ibm128-error tst-ieee128-error @@ -260,6 +261,14 @@ CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi + +tests-container += test-syslog-ieee128 test-syslog-ibm128 +CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-syslog-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +tests-container += test-syslog-chk-ieee128 test-syslog-chk-ibm128 +CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi endif # Add IEEE binary128 files as make targets. diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index f59dfb59fe..b7aa9f7993 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -170,6 +170,11 @@ libc { __obstack_printf_chkieee128; __obstack_vprintf_chkieee128; + __syslogieee128; + __vsyslogieee128; + __syslog_chkieee128; + __vsyslog_chkieee128; + __fscanfieee128; __scanfieee128; __sscanfieee128; diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c new file mode 100644 index 0000000000..fa16cc9aaf --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-syslog.c @@ -0,0 +1,65 @@ +/* Wrapper for syslog. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +void +___ieee128_syslog (int pri, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_USES_FLOAT128); + va_end (ap); +} +strong_alias (___ieee128_syslog, __syslogieee128) + +void +___ieee128_vsyslog (int pri, const char *fmt, va_list ap) +{ + __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vsyslog, __vsyslogieee128) + +void +___ieee128_syslog_chk (int pri, int flag, const char *fmt, ...) +{ + va_list ap; + + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + va_start (ap, fmt); + __vsyslog_internal (pri, fmt, ap, mode); + va_end (ap); +} +strong_alias (___ieee128_syslog_chk, __syslog_chkieee128) + +void +___ieee128_vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) +{ + unsigned int mode = PRINTF_LDBL_USES_FLOAT128; + if (flag > 0) + mode |= PRINTF_FORTIFY; + + __vsyslog_internal (pri, fmt, ap, mode); +} +strong_alias (___ieee128_vsyslog_chk, __vsyslog_chkieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c new file mode 100644 index 0000000000..bf42582687 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c new file mode 100644 index 0000000000..bf42582687 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c new file mode 100644 index 0000000000..513b2d2064 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-chk-ldbl-compat.c @@ -0,0 +1,6 @@ +#define _FORTIFY_SOURCE 2 +#define SYSLOG_FUNCTION __syslog_chk +#define SYSLOG_FUNCTION_PARAMS (LOG_DEBUG, 1, "%Lf\n", ld) +#define VSYSLOG_FUNCTION __vsyslog_chk +#define VSYSLOG_FUNCTION_PARAMS (LOG_DEBUG, 1, "%Lf\n", ap) +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c new file mode 100644 index 0000000000..8e64440e8c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c new file mode 100644 index 0000000000..8e64440e8c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c new file mode 100644 index 0000000000..11454a2245 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat-template.c @@ -0,0 +1,67 @@ +/* Test for the long double variants of *syslog* functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#include +#include + +static void +do_test_one_call (void *last, ...) +{ + long double ld = -1; + va_list ap; + + /* Make syslog functions write to stderr with LOG_PERROR, so that it + can be captured by support_capture_subprocess and verified. */ + openlog ("test-syslog", LOG_PERROR, LOG_USER); + + /* Call syslog functions that take a format string. */ + SYSLOG_FUNCTION SYSLOG_FUNCTION_PARAMS; + va_start (ap, last); + VSYSLOG_FUNCTION VSYSLOG_FUNCTION_PARAMS; + va_end (ap); +} + +static void +do_test_call (void) +{ + long double ld = -1; + do_test_one_call (NULL, ld); +} + +static int +do_test (void) +{ + struct support_capture_subprocess result; + result = support_capture_subprocess ((void *) &do_test_call, NULL); + + do_test_call (); + + /* Compare against the expected output. */ + const char *expected = + "test-syslog: -1.000000\n" + "test-syslog: -1.000000\n"; + TEST_COMPARE_STRING (expected, result.err.buffer); + + return 0; +} + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c new file mode 100644 index 0000000000..ff0c0a5813 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-syslog-ldbl-compat.c @@ -0,0 +1,6 @@ +#define _FORTIFY_SOURCE 0 +#define SYSLOG_FUNCTION syslog +#define SYSLOG_FUNCTION_PARAMS (LOG_DEBUG, "%Lf\n", ld) +#define VSYSLOG_FUNCTION vsyslog +#define VSYSLOG_FUNCTION_PARAMS (LOG_DEBUG, "%Lf\n", ap) +#include From patchwork Fri Oct 25 15:33:56 2019 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: 1184253 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106324-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Jf0UoUWG"; 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 4707Xn1YcXz9sPL for ; Sat, 26 Oct 2019 02:37:45 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=WQ8AOD1+FEqgT/FBY+yLDP95/KBSKrDpNOvtKvjFlF6 m0JP81+iHgSk4w8LudGHSKKtIL7guBaPK+xQil/Kh8ZM3EFOZB8urfInFSfXk6e+ TJiRJkeUXSilys3JPJjmIjzM1NbhY9qxDL2CB/W0ATYkI/CmLc8ot/3Uy6cg5EmE = 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-transfer-encoding:content-type; s=default; bh=nLorsGsLsv5ln1xSN5UoAzd5vIM=; b=Jf0UoUWGcpRMHFb3a VvP3f0Ji+j7yjgDzDgb10pIILIv/9rtNMpBad4sp8HPIHgY0XqOWI/W4TQgq5iuR 7BzMnwE1CzDp5bNZjkxP6OH4AaArYJvfTy01DLXZlaZdwIPPFlvaoqPOz2rcZw9J NrFYnGusaukvAClP2QbwcH4mMo= Received: (qmail 111683 invoked by alias); 25 Oct 2019 15:36:03 -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 111614 invoked by uid 89); 25 Oct 2019 15:36:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 16/30] ldbl-128ibm-compat: Add strfmon_l with IEEE long double format Date: Fri, 25 Oct 2019 12:33:56 -0300 Message-ID: <20191025153410.15405-17-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1611162769163734723 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: Rajalakshmi Srinivasaraghavan No changes since v1. -- 8< -- Similarly to what has been done for printf-like functions, more specifically to the internal implementation in __vfprintf_internal, this patch extends __vstrfmon_l_internal to deal with long double values with binary128 format (as a third format option and reusing the float128 implementation). Tested for powerpc64le and x86_64. --- include/monetary.h | 1 + stdlib/strfmon_l.c | 31 +++++++++++++--- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 12 +++++++ sysdeps/ieee754/ldbl-128ibm-compat/Versions | 3 ++ .../ldbl-128ibm-compat/ieee128-strfmon.c | 35 +++++++++++++++++++ .../ldbl-128ibm-compat/ieee128-strfmon_l.c | 35 +++++++++++++++++++ 6 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c diff --git a/include/monetary.h b/include/monetary.h index f59bdf9150..240925e87d 100644 --- a/include/monetary.h +++ b/include/monetary.h @@ -15,5 +15,6 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, same format as double, in which case the flag should be set to one, or as another format, otherwise. */ #define STRFMON_LDBL_IS_DBL 0x0001 +#define STRFMON_LDBL_USES_FLOAT128 0x0002 #endif diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c index 134dad6963..b26cec24e2 100644 --- a/stdlib/strfmon_l.c +++ b/stdlib/strfmon_l.c @@ -29,6 +29,7 @@ #include #include #include "../locale/localeinfo.h" +#include #define out_char(Ch) \ @@ -96,6 +97,9 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, { double dbl; long double ldbl; +#if __HAVE_DISTINCT_FLOAT128 + _Float128 f128; +#endif } fpnum; int int_format; @@ -106,6 +110,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, int group; char pad; int is_long_double; + int is_binary128; int p_sign_posn; int n_sign_posn; int sign_posn; @@ -150,6 +155,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, group = 1; /* Print digits grouped. */ pad = ' '; /* Fill character is . */ is_long_double = 0; /* Double argument by default. */ + is_binary128 = 0; /* Long double argument by default. */ p_sign_posn = -2; /* This indicates whether the */ n_sign_posn = -2; /* '(' flag is given. */ width = -1; /* No width specified so far. */ @@ -270,6 +276,10 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, ++fmt; if (__glibc_likely ((flags & STRFMON_LDBL_IS_DBL) == 0)) is_long_double = 1; +#if __HAVE_DISTINCT_FLOAT128 + if (__glibc_likely ((flags & STRFMON_LDBL_USES_FLOAT128) != 0)) + is_binary128 = is_long_double; +#endif } /* Handle format specifier. */ @@ -324,10 +334,22 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, /* Now it's time to get the value. */ if (is_long_double == 1) { - fpnum.ldbl = va_arg (ap, long double); - is_negative = fpnum.ldbl < 0; - if (is_negative) - fpnum.ldbl = -fpnum.ldbl; +#if __HAVE_DISTINCT_FLOAT128 + if (is_binary128 == 1) + { + fpnum.f128 = va_arg (ap, _Float128); + is_negative = fpnum.f128 < 0; + if (is_negative) + fpnum.f128 = -fpnum.f128; + } + else +#endif + { + fpnum.ldbl = va_arg (ap, long double); + is_negative = fpnum.ldbl < 0; + if (is_negative) + fpnum.ldbl = -fpnum.ldbl; + } } else { @@ -517,6 +539,7 @@ __vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc, info.width = left_prec + (right_prec ? (right_prec + 1) : 0); info.spec = 'f'; info.is_long_double = is_long_double; + info.is_binary128 = is_binary128; info.group = group; info.pad = pad; info.extra = 1; /* This means use values from LC_MONETARY. */ diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index d774c3b1d7..bea3823d1c 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -271,6 +271,18 @@ CFLAGS-test-syslog-chk-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-test-syslog-chk-ibm128.c += -mabi=ibmlongdouble -Wno-psabi endif +ifeq ($(subdir),stdlib) +ldbl-extra-routines += strfmon strfmon_l + +# Printing long double values with IEEE binary128 format reuses part +# of the internal float128 implementation (__printf_fp, __printf_fphex, +# and __float128 variables and union members). Thus, the compilation of +# the following files, must have -mfloat128 passed to the compiler. +# Also, guarantee that they are compiled in IBM long double mode. +CFLAGS-strfmon.c += -mfloat128 -mabi=ibmlongdouble +CFLAGS-strfmon_l.c += -mfloat128 -mabi=ibmlongdouble +endif + # Add IEEE binary128 files as make targets. routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index b7aa9f7993..da8e0ce7ee 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -221,5 +221,8 @@ libc { __errorieee128; __error_at_lineieee128; + + __strfmonieee128; + __strfmon_lieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c new file mode 100644 index 0000000000..743f7cdcf6 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon.c @@ -0,0 +1,35 @@ +/* Wrapper for strfmon. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +ssize_t +___ieee128_strfmon (char *s, size_t maxsize, const char *format, ...) +{ + va_list ap; + ssize_t res; + + va_start (ap, format); + res = __vstrfmon_l_internal (s, maxsize, _NL_CURRENT_LOCALE, + format, ap, STRFMON_LDBL_USES_FLOAT128); + va_end (ap); + return res; +} +weak_alias (___ieee128_strfmon, __strfmonieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c new file mode 100644 index 0000000000..2ad970af98 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-strfmon_l.c @@ -0,0 +1,35 @@ +/* Wrapper for strfmon_l. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +ssize_t +___ieee128_strfmon_l (char *s, size_t maxsize, locale_t loc, const char *format, ...) +{ + va_list ap; + ssize_t res; + + va_start (ap, format); + res = __vstrfmon_l_internal (s, maxsize, loc, + format, ap, STRFMON_LDBL_USES_FLOAT128); + va_end (ap); + return res; +} +weak_alias (___ieee128_strfmon_l, __strfmon_lieee128) From patchwork Fri Oct 25 15:33:57 2019 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: 1184254 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106325-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kRdJB80z"; 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 4707Xz73F2z9sPL for ; Sat, 26 Oct 2019 02:37:55 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=sQZYLMNXIhBg54c2ICunpdQkkMUnIOQ5MWz5cXQzZ6o KhoN+pFKaM2Wfurjzc9YDgZ0KVzFlrXqYNW4rtt9LzAuKLxGUblDLO7/OUoetamE Qx89zIVcyAn/xHeka5DjO1iy9zq2BdVytm9cJ19VPmR2Ni7x8np/4V07UnGjYBLc = 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-transfer-encoding:content-type; s=default; bh=8iUDHueBZThHcaJMhwOgRTauIU8=; b=kRdJB80zXn+4xjCBK GF9DWQHhLSaJolrTeLiJOnT17EwPjwKlm49RHXPpKQcOejZSmeIJWDD2wSIGwTbZ O5bvFy31ZOk0PtRkGCGRMv9mWXOdSuK4RofSCvF5AuLhVqZp7FDcDZdOZAGexZBU S0cj4urrEjLTlsO7mnoDcnKrIc= Received: (qmail 112350 invoked by alias); 25 Oct 2019 15:36:10 -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 112280 invoked by uid 89); 25 Oct 2019 15:36:09 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, UNSUBSCRIBE_BODY autolearn=ham version=3.3.1 spammy=currency, 2816, setlocale X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 17/30] ldbl-128ibm-compat: Add tests for strfmon and strfmon_l Date: Fri, 25 Oct 2019 12:33:57 -0300 Message-ID: <20191025153410.15405-18-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1613133091911618243 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- This patch adds elementary tests to check that strfmon and strfmon_l correctly evaluate long double values with IBM Extended Precision and IEEE binary128 format. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 6 ++ .../ldbl-128ibm-compat/test-strfmon-ibm128.c | 1 + .../ldbl-128ibm-compat/test-strfmon-ieee128.c | 1 + .../test-strfmon-ldbl-compat.c | 59 +++++++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index bea3823d1c..83c2c43ea4 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -281,6 +281,12 @@ ldbl-extra-routines += strfmon strfmon_l # Also, guarantee that they are compiled in IBM long double mode. CFLAGS-strfmon.c += -mfloat128 -mabi=ibmlongdouble CFLAGS-strfmon_l.c += -mfloat128 -mabi=ibmlongdouble + +tests-internal += test-strfmon-ibm128 test-strfmon-ieee128 +CFLAGS-test-strfmon-ibm128.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-test-strfmon-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +$(objpfx)tst-strfmon-ibm128.out: $(gen-locales) +$(objpfx)tst-strfmon-ieee128.out: $(gen-locales) endif # Add IEEE binary128 files as make targets. diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c new file mode 100644 index 0000000000..5d1def86af --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c new file mode 100644 index 0000000000..5d1def86af --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c new file mode 100644 index 0000000000..1338bd8493 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfmon-ldbl-compat.c @@ -0,0 +1,59 @@ +/* Test for the long double variants of strfmon* functions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include + +#include + +static int +do_test (void) +{ + size_t written; + char buffer[64]; + char *bufptr = buffer; + locale_t loc; + + /* Using the C locale is enough for the purpose of this test case, + i.e.: to test that strfmon correctly reads long double values with + binary128 format. Grouping and currency are irrelevant, here. */ + setlocale (LC_MONETARY, "C"); + loc = newlocale (LC_MONETARY_MASK, "C", (locale_t) 0); + + /* Write to the buffer. */ + written = strfmon (bufptr, 32, "%.10i, %.10Li\n", + (double) -2, (long double) -1); + if (written < 0) + support_record_failure (); + else + bufptr += written; + written = strfmon_l (bufptr, 32, loc, "%.10i, %.10Li\n", + (double) -2, (long double) -1); + if (written < 0) + support_record_failure (); + + /* Compare against the expected output. */ + const char *expected = + "-2.0000000000, -1.0000000000\n" + "-2.0000000000, -1.0000000000\n"; + TEST_COMPARE_STRING (expected, buffer); + + return 0; +} + +#include From patchwork Fri Oct 25 15:33:58 2019 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: 1184255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106326-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="sHNTogKk"; 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 4707Y83c02z9sPL for ; Sat, 26 Oct 2019 02:38:04 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=DzsQCaH1fK90IygnmY1lhYk3sIptZ6B5zzD5Lacau3e apxfv4ltn7MFkY/CE/QbcjMOmbThRx3o5SOjvHMStlIH0K+Bk/iyl1wnso7VjVza utPnf/rvdckjuviecG+APnx3r1f6pkT+cRXjnbawwsPzvECeIaNzuKfWTq9Y49Io = 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-transfer-encoding:content-type; s=default; bh=qUkHavSGumRbJr3i6JGSrLDzXAM=; b=sHNTogKklR2s6DAbt AFK8a9sUuAQUs8bf/OYICyI4DUhA43WVKgAegXv1d5LcbwafORDrEUrlFx6egNwm 0FIFyt7RrS8KcKsvcvzNGMNFrgCIrsCJI0S2DUJPeDTbSd7/Fsj/zR8Q/dCaCuUl B6wItEJVsLB9Y9MY4MOxlersUg= Received: (qmail 112773 invoked by alias); 25 Oct 2019 15:36:13 -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 112729 invoked by uid 89); 25 Oct 2019 15:36:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, UNSUBSCRIBE_BODY autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 18/30] ldbl-128ibm-compat: Add tests for strfroml, strtold, and wcstold Date: Fri, 25 Oct 2019 12:33:58 -0300 Message-ID: <20191025153410.15405-19-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1614540467356487363 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- Since the commit commit 86a0f56158bd9cbaf2d640e2e6c66539f4cbbcc1 Author: Rajalakshmi Srinivasaraghavan Date: Thu Jun 28 13:57:50 2018 +0530 ldbl-128ibm-compat: Introduce ieee128 symbols IEEE long double versions of strfroml, strtold, and wcstold have been prepared, but not exposed (which will only happen when the full support for IEEE long double is complete). This patch adds tests for these functions in both IBM and IEEE long double mode. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 12 +++++ .../ldbl-128ibm-compat/test-strfrom-ibm128.c | 1 + .../ldbl-128ibm-compat/test-strfrom-ieee128.c | 1 + .../test-strfrom-ldbl-compat.c | 49 +++++++++++++++++++ .../ldbl-128ibm-compat/test-wcstold-ibm128.c | 1 + .../ldbl-128ibm-compat/test-wcstold-ieee128.c | 1 + .../test-wcstold-ldbl-compat.c | 36 ++++++++++++++ 7 files changed, 101 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 83c2c43ea4..6f1794fac8 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -13,6 +13,12 @@ ldbl-extra-routines += isoc99_fwscanf \ isoc99_vfwscanf \ isoc99_vswscanf \ isoc99_vwscanf + +tests-internal += test-wcstold-ibm128 test-wcstold-ieee128 +CFLAGS-test-wcstold-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-wcstold-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +$(objpfx)test-wcstold-ieee128: gnulib-tests += $(f128-loader-link) endif ifeq ($(subdir),stdio-common) @@ -287,6 +293,12 @@ CFLAGS-test-strfmon-ibm128.c += -mabi=ibmlongdouble -Wno-psabi CFLAGS-test-strfmon-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi $(objpfx)tst-strfmon-ibm128.out: $(gen-locales) $(objpfx)tst-strfmon-ieee128.out: $(gen-locales) + +tests-internal += test-strfrom-ibm128 test-strfrom-ieee128 +CFLAGS-test-strfrom-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-strfrom-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +$(objpfx)test-strfrom-ieee128: gnulib-tests += $(f128-loader-link) endif # Add IEEE binary128 files as make targets. diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c new file mode 100644 index 0000000000..93887706b9 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c new file mode 100644 index 0000000000..93887706b9 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c new file mode 100644 index 0000000000..f32548fe90 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-strfrom-ldbl-compat.c @@ -0,0 +1,49 @@ +/* Test for the long double variants of strfroml and strtold. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#include + +static int +do_test (void) +{ + int written; + char buffer[64]; + char *bufptr = buffer; + const char *expected = "-1.0000000000"; + long double read; + + /* Write to the buffer. */ + written = strfroml (bufptr, 64, "%.10f", (long double) -1); + if (written < 0) + support_record_failure (); + + /* Compare against the expected output. */ + TEST_COMPARE_STRING (expected, buffer); + + /* Read from the buffer. */ + read = strtold (expected, NULL); + + if (read != (long double) -1) + support_record_failure (); + + return 0; +} + +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c new file mode 100644 index 0000000000..4d60692eeb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ibm128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c new file mode 100644 index 0000000000..4d60692eeb --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ieee128.c @@ -0,0 +1 @@ +#include diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c new file mode 100644 index 0000000000..8b9e300147 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-wcstold-ldbl-compat.c @@ -0,0 +1,36 @@ +/* Test for the long double variant of wcstold. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#include + +static int +do_test (void) +{ + const wchar_t *input = L"-1.0000000000"; + long double read; + + read = wcstold (input, NULL); + if (read != (long double) -1) + support_record_failure (); + + return 0; +} + +#include From patchwork Fri Oct 25 15:33:59 2019 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: 1184256 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106327-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="khk8eOGn"; 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 4707Yl4bh7z9sPZ for ; Sat, 26 Oct 2019 02:38:35 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=fthbqTpC5hG0m2wa1bfd+CvE+EPf+hEv4LO/CaQf86k vQqjuDQX2MOtB8qDXiYJty0DtLAe2F7Ay9gnUMUEWJCmxyJw13+BnxeVJevb1x7V nNxfZgfiNlGNyOzGC4DktOj9dZI2KJ5Yq8FztJArhDEskd1+VvbdNN7F7V4qB7Ps = 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-transfer-encoding:content-type; s=default; bh=XHRAMiA6zxQtTcfZN5h/e+wjefQ=; b=khk8eOGn/jRMs7N/g aS5BSIvaS5wVv7NoH4ueaKsHNV+8HT5GNv50Bc4lXkZWhwb6rYLpKgZjqEvhbB/W +s8AxzvC4H9r/yjfOid8PZYRZV1sJn8lyczxAJKNB/qVjAWRImvUR9ms3LK5rt73 qYF3sn8g4RS9zT8t75u8YH3Te0= Received: (qmail 113225 invoked by alias); 25 Oct 2019 15:36:16 -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 113165 invoked by uid 89); 25 Oct 2019 15:36:16 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*F:D*br, HContent-Transfer-Encoding:8bit X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 19/30] Refactor *cvt functions implementation (1/5) Date: Fri, 25 Oct 2019 12:33:59 -0300 Message-ID: <20191025153410.15405-20-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1615947843105640131 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- This patch is to be squashed with the other n/5 refactoring patches. I split it into these 5 patches, because even using -M and -C, the patches looks as if a lot has changed, when it's basically just moving code around. The final commit will be the squashing of patches 1 to 5, with the following commit message: -- 8< -- This patch refactors the *cvt functions implementation in a way that makes it easier to re-use them for implementing the IEEE long double on powerpc64le. By splitting the implementation per se in one file (efgcvt-template.c) and the alias definitions in others (e.g. efgcvt.c), the new code makes it easier to define new function names, such as __qecvtieee128. --- misc/{efgcvt.c => efgcvt-template.c} | 0 misc/{efgcvt_r.c => efgcvt_r-template.c} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename misc/{efgcvt.c => efgcvt-template.c} (100%) rename misc/{efgcvt_r.c => efgcvt_r-template.c} (100%) diff --git a/misc/efgcvt.c b/misc/efgcvt-template.c similarity index 100% rename from misc/efgcvt.c rename to misc/efgcvt-template.c diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r-template.c similarity index 100% rename from misc/efgcvt_r.c rename to misc/efgcvt_r-template.c From patchwork Fri Oct 25 15:34:00 2019 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: 1184257 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106328-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="nU/xlw3I"; 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 4707Yw5LzDz9sPf for ; Sat, 26 Oct 2019 02:38:44 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=Gb+puKrGcBBepw4gmJPP7uT98n91fiiW8Jtip0M6OvG uVIFwH9xdnTK9rahlfEej3PiRZDrw84rwm6Ug9oQGKS592v9JcSMMJso+S+HYqex F/H+PeGX2JqhrWYYl4q+Lf6Am5EE5o8nIFmbmrgKbPP68q4zvKbn/4kydz4FtwW4 = 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-transfer-encoding:content-type; s=default; bh=v7LmdsiS2mGLbg8eaQg41uSST0c=; b=nU/xlw3Id/T3HFkvn BAdQgXgFU0mFMIzQ8GTjVmjGADsYFexgWxDXaH53CAErOGbnEGCIDZB3r2g3ZAuo v0TX3SHGTI0S/lb1GkZtzsuPjBcJ/vuAE2X4tqvRCFj/YwrYhUQgHavxGdBBLkf7 QuxSt1iWGg4zZtIKrsjsYBLDcc= Received: (qmail 113887 invoked by alias); 25 Oct 2019 15:36:22 -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 113825 invoked by uid 89); 25 Oct 2019 15:36:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 20/30] Refactor *cvt functions implementation (2/5) Date: Fri, 25 Oct 2019 12:34:00 -0300 Message-ID: <20191025153410.15405-21-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1617073745272622787 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- This patch is to be squashed with the other n/5 refactoring patches. This patch only moves and merges the contents of misc/efgcvt-template.c and misc/efgcvt_r-template.c into misc/efgcvt-dbl-macros.h. --- misc/efgcvt-dbl-macros.h | 52 ++++++++++++++++++++++++++++++++++++++++ misc/efgcvt-template.c | 25 ------------------- misc/efgcvt_r-template.c | 33 ------------------------- 3 files changed, 52 insertions(+), 58 deletions(-) create mode 100644 misc/efgcvt-dbl-macros.h diff --git a/misc/efgcvt-dbl-macros.h b/misc/efgcvt-dbl-macros.h new file mode 100644 index 0000000000..08640e9639 --- /dev/null +++ b/misc/efgcvt-dbl-macros.h @@ -0,0 +1,52 @@ +/* Macros for the implementation of *cvt functions, double version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#define FLOAT_TYPE double +#define FUNC_PREFIX +#define FLOAT_FMT_FLAG +#define FLOAT_NAME_EXT +#define FLOAT_MIN_10_EXP DBL_MIN_10_EXP +/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we + don't have log10 available in the preprocessor. */ +#define MAXDIG (NDIGIT_MAX + 3) +#define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG) +#if DBL_MANT_DIG == 53 +# define NDIGIT_MAX 17 +#elif DBL_MANT_DIG == 24 +# define NDIGIT_MAX 9 +#elif DBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 +#else +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" +# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) +#endif +#if DBL_MIN_10_EXP == -37 +# define FLOAT_MIN_10_NORM 1.0e-37 +#elif DBL_MIN_10_EXP == -307 +# define FLOAT_MIN_10_NORM 1.0e-307 +#elif DBL_MIN_10_EXP == -4931 +# define FLOAT_MIN_10_NORM 1.0e-4931 +#else +/* libc can't depend on libm. */ +# error "FLOAT_MIN_10_NORM must be precomputed" +# define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP) +#endif diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c index 492e4e8086..f8650a934f 100644 --- a/misc/efgcvt-template.c +++ b/misc/efgcvt-template.c @@ -20,34 +20,9 @@ #include #include #include -#include #include #include -#ifndef FLOAT_TYPE -# define FLOAT_TYPE double -# define FUNC_PREFIX -# define FLOAT_FMT_FLAG -/* Actually we have to write (DBL_DIG + log10 (DBL_MAX_10_EXP)) but we - don't have log10 available in the preprocessor. */ -# define MAXDIG (NDIGIT_MAX + 3) -# define FCVT_MAXDIG (DBL_MAX_10_EXP + MAXDIG) -# if DBL_MANT_DIG == 53 -# define NDIGIT_MAX 17 -# elif DBL_MANT_DIG == 24 -# define NDIGIT_MAX 9 -# elif DBL_MANT_DIG == 56 -# define NDIGIT_MAX 18 -# else -/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a - compile time constant here, so we cannot use it. */ -# error "NDIGIT_MAX must be precomputed" -# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) -# endif -#else -# define LONG_DOUBLE_CVT -#endif - #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b #define __APPEND(a, b) __APPEND2 (a, b) diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c index 981249850c..74baad78a0 100644 --- a/misc/efgcvt_r-template.c +++ b/misc/efgcvt_r-template.c @@ -17,7 +17,6 @@ . */ #include -#include #include #include #include @@ -26,38 +25,6 @@ #include #include -#ifndef FLOAT_TYPE -# define FLOAT_TYPE double -# define FUNC_PREFIX -# define FLOAT_FMT_FLAG -# define FLOAT_NAME_EXT -# define FLOAT_MIN_10_EXP DBL_MIN_10_EXP -# if DBL_MANT_DIG == 53 -# define NDIGIT_MAX 17 -# elif DBL_MANT_DIG == 24 -# define NDIGIT_MAX 9 -# elif DBL_MANT_DIG == 56 -# define NDIGIT_MAX 18 -# else -/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a - compile time constant here, so we cannot use it. */ -# error "NDIGIT_MAX must be precomputed" -# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * DBL_MANT_DIG + 1.0))) -# endif -# if DBL_MIN_10_EXP == -37 -# define FLOAT_MIN_10_NORM 1.0e-37 -# elif DBL_MIN_10_EXP == -307 -# define FLOAT_MIN_10_NORM 1.0e-307 -# elif DBL_MIN_10_EXP == -4931 -# define FLOAT_MIN_10_NORM 1.0e-4931 -# else -/* libc can't depend on libm. */ -# error "FLOAT_MIN_10_NORM must be precomputed" -# define FLOAT_MIN_10_NORM exp10 (DBL_MIN_10_EXP) -# endif -#else -# define LONG_DOUBLE_CVT -#endif #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b From patchwork Fri Oct 25 15:34:01 2019 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: 1184259 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106329-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="iPN7wkbc"; 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 4707Z55y39z9sPL for ; Sat, 26 Oct 2019 02:38:53 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=kASsFdiYcOHMGoWeid6Vi7jn390s9747sj1GlYzhTB3 MSWTJue2XxmbA6tlG3YLpJj+PXnSgfP08xLmK7XHfhcHw3SA1kXgBWcyCLEVCyJS vYROXGmiMt+WG0ABKOJQx5sCnjKoOL3dd6FQiDIceqFEYNrt6jURMYNDhqjsFpIs = 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-transfer-encoding:content-type; s=default; bh=aqk7dUjYiFuOpRZbTusrbEfT48A=; b=iPN7wkbc0uQs/PG9e B16X0X0z9yU5nIHtfcDKCRiJg0BbGGsMlktQpNIWfxeR2gCZ3i/LuinMQ2nWXyNW j/5K8YrQeHHpYB/iAzL/Mbck6Xx8vL9KjtES9E9nr+KRUaJIW+6qAWyTtBKkul6e F4/HVVazwPL3L6H+0xCdFXTpQM= Received: (qmail 114561 invoked by alias); 25 Oct 2019 15:36:28 -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 114505 invoked by uid 89); 25 Oct 2019 15:36:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=generous X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 21/30] Refactor *cvt functions implementation (3/5) Date: Fri, 25 Oct 2019 12:34:01 -0300 Message-ID: <20191025153410.15405-22-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1618481119590928067 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- This patch is to be squashed with the other n/5 refactoring patches. This patch only moves and merges the contents of misc/qefgcvt.c and misc/qefgcvt_r.c into misc/efgcvt-ldbl-macros.h. --- misc/efgcvt-ldbl-macros.h | 59 +++++++++++++++++++++++++++++++++++++++ misc/qefgcvt.c | 27 ------------------ misc/qefgcvt_r.c | 37 ------------------------ 3 files changed, 59 insertions(+), 64 deletions(-) create mode 100644 misc/efgcvt-ldbl-macros.h diff --git a/misc/efgcvt-ldbl-macros.h b/misc/efgcvt-ldbl-macros.h new file mode 100644 index 0000000000..ff97b13d7f --- /dev/null +++ b/misc/efgcvt-ldbl-macros.h @@ -0,0 +1,59 @@ +/* Macros for the implementation of *cvt functions, long double version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +#define FLOAT_TYPE long double +#define FUNC_PREFIX q +#define FLOAT_FMT_FLAG "L" +#define FLOAT_NAME_EXT l +#define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP +/* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but + we don't have log10 available in the preprocessor. Since we cannot + assume anything on the used `long double' format be generous. */ +#define MAXDIG (NDIGIT_MAX + 12) +#define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG) +#if LDBL_MANT_DIG == 64 +# define NDIGIT_MAX 21 +#elif LDBL_MANT_DIG == 53 +# define NDIGIT_MAX 17 +#elif LDBL_MANT_DIG == 113 +# define NDIGIT_MAX 36 +#elif LDBL_MANT_DIG == 106 +# define NDIGIT_MAX 34 +#elif LDBL_MANT_DIG == 56 +# define NDIGIT_MAX 18 +#else +/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a + compile time constant here, so we cannot use it. */ +# error "NDIGIT_MAX must be precomputed" +# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0))) +#endif +#if LDBL_MIN_10_EXP == -37 +# define FLOAT_MIN_10_NORM 1.0e-37L +#elif LDBL_MIN_10_EXP == -291 +# define FLOAT_MIN_10_NORM 1.0e-291L +#elif LDBL_MIN_10_EXP == -307 +# define FLOAT_MIN_10_NORM 1.0e-307L +#elif LDBL_MIN_10_EXP == -4931 +# define FLOAT_MIN_10_NORM 1.0e-4931L +#else +/* libc can't depend on libm. */ +# error "FLOAT_MIN_10_NORM must be precomputed" +# define FLOAT_MIN_10_NORM exp10l (LDBL_MIN_10_EXP) +#endif diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c index 4fcadfcdc2..6987fb0db1 100644 --- a/misc/qefgcvt.c +++ b/misc/qefgcvt.c @@ -16,31 +16,4 @@ License along with the GNU C Library; if not, see . */ -#include - -#define FLOAT_TYPE long double -#define FUNC_PREFIX q -#define FLOAT_FMT_FLAG "L" -/* Actually we have to write (LDBL_DIG + log10 (LDBL_MAX_10_EXP)) but - we don't have log10 available in the preprocessor. Since we cannot - assume anything on the used `long double' format be generous. */ -#define MAXDIG (NDIGIT_MAX + 12) -#define FCVT_MAXDIG (LDBL_MAX_10_EXP + MAXDIG) -#if LDBL_MANT_DIG == 64 -# define NDIGIT_MAX 21 -#elif LDBL_MANT_DIG == 53 -# define NDIGIT_MAX 17 -#elif LDBL_MANT_DIG == 113 -# define NDIGIT_MAX 36 -#elif LDBL_MANT_DIG == 106 -# define NDIGIT_MAX 34 -#elif LDBL_MANT_DIG == 56 -# define NDIGIT_MAX 18 -#else -/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a - compile time constant here, so we cannot use it. */ -# error "NDIGIT_MAX must be precomputed" -# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0))) -#endif - #include "efgcvt.c" diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index 8f4d8b9f7a..e1f074b49c 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -17,41 +17,4 @@ License along with the GNU C Library; if not, see . */ -#include - -#define FLOAT_TYPE long double -#define FUNC_PREFIX q -#define FLOAT_FMT_FLAG "L" -#define FLOAT_NAME_EXT l -#define FLOAT_MIN_10_EXP LDBL_MIN_10_EXP -#if LDBL_MANT_DIG == 64 -# define NDIGIT_MAX 21 -#elif LDBL_MANT_DIG == 53 -# define NDIGIT_MAX 17 -#elif LDBL_MANT_DIG == 113 -# define NDIGIT_MAX 36 -#elif LDBL_MANT_DIG == 106 -# define NDIGIT_MAX 34 -#elif LDBL_MANT_DIG == 56 -# define NDIGIT_MAX 18 -#else -/* See IEEE 854 5.6, table 2 for this formula. Unfortunately we need a - compile time constant here, so we cannot use it. */ -# error "NDIGIT_MAX must be precomputed" -# define NDIGIT_MAX (lrint (ceil (M_LN2 / M_LN10 * LDBL_MANT_DIG + 1.0))) -#endif -#if LDBL_MIN_10_EXP == -37 -# define FLOAT_MIN_10_NORM 1.0e-37L -#elif LDBL_MIN_10_EXP == -291 -# define FLOAT_MIN_10_NORM 1.0e-291L -#elif LDBL_MIN_10_EXP == -307 -# define FLOAT_MIN_10_NORM 1.0e-307L -#elif LDBL_MIN_10_EXP == -4931 -# define FLOAT_MIN_10_NORM 1.0e-4931L -#else -/* libc can't depend on libm. */ -# error "FLOAT_MIN_10_NORM must be precomputed" -# define FLOAT_MIN_10_NORM exp10l (LDBL_MIN_10_EXP) -#endif - #include "efgcvt_r.c" From patchwork Fri Oct 25 15:34:02 2019 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: 1184260 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106330-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="hCn5jO4g"; 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 4707ZJ3h4cz9sPL for ; Sat, 26 Oct 2019 02:39:04 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=vzx57SAwge/7ratlediNQ3z4MZb7EkXqiIV97m+K/oS UeagfK+0U4X7xlJ7xFraR7PWFDJLp5XuzaaHRB+b4hDrfnOFq837ht8rfb5JHmLX HdMekqzVjyW0inxkk67AJI4vsT5EcLCUtZs0ooSIQy+RfxzneeeyMw57JGA4llTA = 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-transfer-encoding:content-type; s=default; bh=K6RpFfmRoYMA6IXo026WrwLQ6W8=; b=hCn5jO4gXgi1Xz3qq gpukmMPr/dPNWu3LNZVXAFSetMpr8Fldtx3XfZQ5ywaOxVlRl4P4bicc8PYe47hd XHxMKxlBkqnDkPBrLsnl0rCNNJReE6vCwxWKNY43dbskjDw0Fp4jQYdfRaFtl+6l Lm2VchPQcToBll6MSy6au6vopw= Received: (qmail 115144 invoked by alias); 25 Oct 2019 15:36:33 -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 115084 invoked by uid 89); 25 Oct 2019 15:36:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=MIN X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 22/30] Refactor *cvt functions implementation (4/5) Date: Fri, 25 Oct 2019 12:34:02 -0300 Message-ID: <20191025153410.15405-23-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1619888494883688131 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" Changes since v1: - Adapted after patch v1 19/31 (remove hidden_* uses) was dropped. - Fixed unintended removal of cvt* symbols on alpha and s390x (now tested with build-many-glibcs.py). -- 8< -- This patch is to be squashed with the other n/5 refactoring patches. This patch splits the definition of the symbol names into separate files for double and long double, which will make it easier to define new symbol names for IEEE long double functions on powerpc64le. --- misc/efgcvt-template.c | 23 ----------------------- misc/efgcvt.c | 34 ++++++++++++++++++++++++++++++++++ misc/efgcvt_r-template.c | 27 --------------------------- misc/efgcvt_r.c | 37 +++++++++++++++++++++++++++++++++++++ misc/qefgcvt.c | 14 ++++++++++++++ misc/qefgcvt_r.c | 17 +++++++++++++++++ 6 files changed, 102 insertions(+), 50 deletions(-) create mode 100644 misc/efgcvt.c create mode 100644 misc/efgcvt_r.c diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c index f8650a934f..aeb4e1ea01 100644 --- a/misc/efgcvt-template.c +++ b/misc/efgcvt-template.c @@ -76,26 +76,3 @@ __APPEND (FUNC_PREFIX, gcvt) (FLOAT_TYPE value, int ndigit, char *buf) sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value); return buf; } - -#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -# ifdef LONG_DOUBLE_CVT -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) -# define cvt_symbol_1(lib, local, symbol, version) \ - versioned_symbol (lib, local, symbol, version) -# else -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (q, symbol), GLIBC_2_0); \ - strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) -# define cvt_symbol_1(lib, local, symbol, version) \ - compat_symbol (lib, local, symbol, version) -# endif -#else -# define cvt_symbol(symbol) \ - strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) -#endif -cvt_symbol(fcvt); -cvt_symbol(ecvt); -cvt_symbol(gcvt); diff --git a/misc/efgcvt.c b/misc/efgcvt.c new file mode 100644 index 0000000000..81ac60415e --- /dev/null +++ b/misc/efgcvt.c @@ -0,0 +1,34 @@ +/* Double versions of *cvt_r functions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "efgcvt.c" + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (q, symbol), GLIBC_2_0); \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(lib, local, symbol, version) \ + compat_symbol (lib, local, symbol, version) +#else +# define cvt_symbol(symbol) \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +#endif +cvt_symbol (fcvt); +cvt_symbol (ecvt); +cvt_symbol (gcvt); diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c index 74baad78a0..f215dbd345 100644 --- a/misc/efgcvt_r-template.c +++ b/misc/efgcvt_r-template.c @@ -200,30 +200,3 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, *decpt += exponent; return 0; } - -#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -# ifdef LONG_DOUBLE_CVT -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) -# define cvt_symbol_1(lib, local, symbol, version) \ - libc_hidden_def (local) \ - versioned_symbol (lib, local, symbol, version) -# else -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (q, symbol), GLIBC_2_0); \ - weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) -# define cvt_symbol_1(lib, local, symbol, version) \ - libc_hidden_def (local) \ - compat_symbol (lib, local, symbol, version) -# endif -#else -# define cvt_symbol(symbol) \ - cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) -# define cvt_symbol_1(local, symbol) \ - libc_hidden_def (local) \ - weak_alias (local, symbol) -#endif -cvt_symbol(fcvt_r); -cvt_symbol(ecvt_r); diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c new file mode 100644 index 0000000000..aa0eb8ca43 --- /dev/null +++ b/misc/efgcvt_r.c @@ -0,0 +1,37 @@ +/* Double versions of reentrant *cvt_r functions. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include "efgcvt_r.c" + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (q, symbol), GLIBC_2_0); \ + weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(lib, local, symbol, version) \ + libc_hidden_def (local) \ + compat_symbol (lib, local, symbol, version) +#else +# define cvt_symbol(symbol) \ + cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(local, symbol) \ + libc_hidden_def (local) \ + weak_alias (local, symbol) +#endif +cvt_symbol (fcvt_r); +cvt_symbol (ecvt_r); diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c index 6987fb0db1..ea48c6b48a 100644 --- a/misc/qefgcvt.c +++ b/misc/qefgcvt.c @@ -17,3 +17,17 @@ . */ #include "efgcvt.c" + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) +# define cvt_symbol_1(lib, local, symbol, version) \ + versioned_symbol (lib, local, symbol, version) +#else +# define cvt_symbol(symbol) \ + strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +#endif +cvt_symbol(fcvt); +cvt_symbol(ecvt); +cvt_symbol(gcvt); diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index e1f074b49c..d2f36e6d2a 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -18,3 +18,20 @@ . */ #include "efgcvt_r.c" + +#if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) +# define cvt_symbol(symbol) \ + cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ + APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) +# define cvt_symbol_1(lib, local, symbol, version) \ + libc_hidden_def (local) \ + versioned_symbol (lib, local, symbol, version) +#else +# define cvt_symbol(symbol) \ + cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol_1(local, symbol) \ + libc_hidden_def (local) \ + weak_alias (local, symbol) +#endif +cvt_symbol(fcvt_r); +cvt_symbol(ecvt_r); From patchwork Fri Oct 25 15:34:03 2019 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: 1184261 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106331-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="lYutrrF+"; 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 4707ZS5S7vz9sPL for ; Sat, 26 Oct 2019 02:39:12 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=uy2xUJuv8j310cV7AiD/CNSEaapgVQvQn0t3hnaLWjg Fte+T94gkLDDmAybK4PyjZ2dCFQId217BA6XS8FgrUrAsBMtFkCQWjv89jSHXPgk T0d17fwZuQTz2bGA8BuVJIa7WXRfz7EaNM9Jys/bhDs0N+Pyi+Z8Y+l2Py8/0PX4 = 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-transfer-encoding:content-type; s=default; bh=j8xbJDpowRrmEkf/hSfbWWSum8M=; b=lYutrrF+QYIN7ZqOa waETYLoqwLiM1vE4XdARsUlunryADLUIlqqA9RYCa00exfCbWCa/XUdrlePyq0V1 D3loduf+wOzTE1x2NxR/jxanSymt5XASntOtx/L1d4OfqOi5EuKFkAQqOKmr8D/9 LBBXZBQwLRdTrwFBWM/Txi8rUo= Received: (qmail 115771 invoked by alias); 25 Oct 2019 15:36: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 115703 invoked by uid 89); 25 Oct 2019 15:36:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 23/30] Refactor *cvt functions implementation (5/5) Date: Fri, 25 Oct 2019 12:34:03 -0300 Message-ID: <20191025153410.15405-24-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1621577342080110275 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" Changes since v1: - Adapted after patch v1 19/31 (remove hidden_* uses) was dropped. - Fixed unintended removal of cvt* symbols on alpha and s390x (now tested with build-many-glibcs.py). -- 8< -- This patch is to be squashed with the other n/5 refactoring patches. This patch replaces the use of the APPEND macro with one new macro being defined for each of the cvt* functions. This makes it easier to define functions names for IEEE long double on powerpc64le, e.g. __ecvtieee128. --- misc/efgcvt-template.c | 19 ++++++------------- misc/efgcvt.c | 28 ++++++++++++++++++---------- misc/efgcvt_r-template.c | 20 ++++++-------------- misc/efgcvt_r.c | 22 ++++++++++++---------- misc/qefgcvt.c | 28 +++++++++++++++++----------- misc/qefgcvt_r.c | 22 +++++++++++----------- 6 files changed, 70 insertions(+), 69 deletions(-) diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c index aeb4e1ea01..7fabdf264d 100644 --- a/misc/efgcvt-template.c +++ b/misc/efgcvt-template.c @@ -25,8 +25,6 @@ #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b -#define __APPEND(a, b) __APPEND2 (a, b) -#define __APPEND2(a, b) __##a##b #define FCVT_BUFFER APPEND (FUNC_PREFIX, fcvt_buffer) @@ -39,13 +37,11 @@ static char ECVT_BUFFER[MAXDIG]; libc_freeres_ptr (static char *FCVT_BUFPTR); char * -__APPEND (FUNC_PREFIX, fcvt) (FLOAT_TYPE value, int ndigit, int *decpt, - int *sign) +__FCVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign) { if (FCVT_BUFPTR == NULL) { - if (__APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, - FCVT_BUFFER, MAXDIG) != -1) + if (__FCVT_R (value, ndigit, decpt, sign, FCVT_BUFFER, MAXDIG) != -1) return FCVT_BUFFER; FCVT_BUFPTR = (char *) malloc (FCVT_MAXDIG); @@ -53,25 +49,22 @@ __APPEND (FUNC_PREFIX, fcvt) (FLOAT_TYPE value, int ndigit, int *decpt, return FCVT_BUFFER; } - (void) __APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, - FCVT_BUFPTR, FCVT_MAXDIG); + (void) __FCVT_R (value, ndigit, decpt, sign, FCVT_BUFPTR, FCVT_MAXDIG); return FCVT_BUFPTR; } char * -__APPEND (FUNC_PREFIX, ecvt) (FLOAT_TYPE value, int ndigit, int *decpt, - int *sign) +__ECVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign) { - (void) __APPEND (FUNC_PREFIX, ecvt_r) (value, ndigit, decpt, sign, - ECVT_BUFFER, MAXDIG); + (void) __ECVT_R (value, ndigit, decpt, sign, ECVT_BUFFER, MAXDIG); return ECVT_BUFFER; } char * -__APPEND (FUNC_PREFIX, gcvt) (FLOAT_TYPE value, int ndigit, char *buf) +__GCVT (FLOAT_TYPE value, int ndigit, char *buf) { sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value); return buf; diff --git a/misc/efgcvt.c b/misc/efgcvt.c index 81ac60415e..93a0269d5c 100644 --- a/misc/efgcvt.c +++ b/misc/efgcvt.c @@ -16,19 +16,27 @@ License along with the GNU C Library; if not, see . */ -#include "efgcvt.c" +#define ECVT ecvt +#define FCVT fcvt +#define GCVT gcvt +#define __ECVT __ecvt +#define __FCVT __fcvt +#define __GCVT __gcvt +#define __ECVT_R __ecvt_r +#define __FCVT_R __fcvt_r +#include +#include #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (q, symbol), GLIBC_2_0); \ - strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol(local, symbol) \ + cvt_symbol_1 (libc, local, APPEND (q, symbol), GLIBC_2_0); \ + strong_alias (local, symbol) # define cvt_symbol_1(lib, local, symbol, version) \ compat_symbol (lib, local, symbol, version) #else -# define cvt_symbol(symbol) \ - strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol(local, symbol) \ + strong_alias (local, symbol) #endif -cvt_symbol (fcvt); -cvt_symbol (ecvt); -cvt_symbol (gcvt); +cvt_symbol (__fcvt, fcvt); +cvt_symbol (__ecvt, ecvt); +cvt_symbol (__gcvt, gcvt); diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c index f215dbd345..977750118c 100644 --- a/misc/efgcvt_r-template.c +++ b/misc/efgcvt_r-template.c @@ -28,18 +28,10 @@ #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b -#define __APPEND(a, b) __APPEND2 (a, b) -#define __APPEND2(a, b) __##a##b - -#define FLOOR APPEND(floor, FLOAT_NAME_EXT) -#define FABS APPEND(fabs, FLOAT_NAME_EXT) -#define LOG10 APPEND(log10, FLOAT_NAME_EXT) -#define EXP APPEND(exp, FLOAT_NAME_EXT) - int -__APPEND (FUNC_PREFIX, fcvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, - int *sign, char *buf, size_t len) +__FCVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign, + char *buf, size_t len) { ssize_t n; ssize_t i; @@ -133,8 +125,8 @@ __APPEND (FUNC_PREFIX, fcvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, } int -__APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, - int *sign, char *buf, size_t len) +__ECVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign, + char *buf, size_t len) { int exponent = 0; @@ -193,8 +185,8 @@ __APPEND (FUNC_PREFIX, ecvt_r) (FLOAT_TYPE value, int ndigit, int *decpt, *sign = isfinite (value) ? signbit (value) != 0 : 0; } else - if (__APPEND (FUNC_PREFIX, fcvt_r) (value, MIN (ndigit, NDIGIT_MAX) - 1, - decpt, sign, buf, len)) + if (__FCVT_R (value, MIN (ndigit, NDIGIT_MAX) - 1, + decpt, sign, buf, len)) return -1; *decpt += exponent; diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c index aa0eb8ca43..5b48ca5b9b 100644 --- a/misc/efgcvt_r.c +++ b/misc/efgcvt_r.c @@ -16,22 +16,24 @@ License along with the GNU C Library; if not, see . */ -#include "efgcvt_r.c" +#define ECVT_R ecvt_r +#define FCVT_R fcvt_r +#define __ECVT_R __ecvt_r +#define __FCVT_R __fcvt_r +#include +#include #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (q, symbol), GLIBC_2_0); \ - weak_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol(local, symbol) \ + cvt_symbol_1 (libc, local, APPEND (q, symbol), GLIBC_2_0); \ + weak_alias (local, symbol) # define cvt_symbol_1(lib, local, symbol, version) \ libc_hidden_def (local) \ compat_symbol (lib, local, symbol, version) #else -# define cvt_symbol(symbol) \ - cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) -# define cvt_symbol_1(local, symbol) \ +# define cvt_symbol(local, symbol) \ libc_hidden_def (local) \ weak_alias (local, symbol) #endif -cvt_symbol (fcvt_r); -cvt_symbol (ecvt_r); +cvt_symbol (__fcvt_r, fcvt_r); +cvt_symbol (__ecvt_r, ecvt_r); diff --git a/misc/qefgcvt.c b/misc/qefgcvt.c index ea48c6b48a..903bf93aa4 100644 --- a/misc/qefgcvt.c +++ b/misc/qefgcvt.c @@ -16,18 +16,24 @@ License along with the GNU C Library; if not, see . */ -#include "efgcvt.c" +#define ECVT qecvt +#define FCVT qfcvt +#define GCVT qgcvt +#define __ECVT __qecvt +#define __FCVT __qfcvt +#define __GCVT __qgcvt +#define __ECVT_R __qecvt_r +#define __FCVT_R __qfcvt_r +#include +#include #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) -# define cvt_symbol_1(lib, local, symbol, version) \ - versioned_symbol (lib, local, symbol, version) +# define cvt_symbol(local, symbol) \ + versioned_symbol (libc, local, symbol, GLIBC_2_4) #else -# define cvt_symbol(symbol) \ - strong_alias (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) +# define cvt_symbol(local, symbol) \ + strong_alias (local, symbol) #endif -cvt_symbol(fcvt); -cvt_symbol(ecvt); -cvt_symbol(gcvt); +cvt_symbol (__qfcvt, qfcvt); +cvt_symbol (__qecvt, qecvt); +cvt_symbol (__qgcvt, qgcvt); diff --git a/misc/qefgcvt_r.c b/misc/qefgcvt_r.c index d2f36e6d2a..b790bf7837 100644 --- a/misc/qefgcvt_r.c +++ b/misc/qefgcvt_r.c @@ -17,21 +17,21 @@ License along with the GNU C Library; if not, see . */ -#include "efgcvt_r.c" +#define ECVT_R qecvt_r +#define FCVT_R qfcvt_r +#define __ECVT_R __qecvt_r +#define __FCVT_R __qfcvt_r +#include +#include #if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0) -# define cvt_symbol(symbol) \ - cvt_symbol_1 (libc, __APPEND (FUNC_PREFIX, symbol), \ - APPEND (FUNC_PREFIX, symbol), GLIBC_2_4) -# define cvt_symbol_1(lib, local, symbol, version) \ +# define cvt_symbol(local, symbol) \ libc_hidden_def (local) \ - versioned_symbol (lib, local, symbol, version) + versioned_symbol (libc, local, symbol, GLIBC_2_4) #else -# define cvt_symbol(symbol) \ - cvt_symbol_1 (__APPEND (FUNC_PREFIX, symbol), APPEND (FUNC_PREFIX, symbol)) -# define cvt_symbol_1(local, symbol) \ +# define cvt_symbol(local, symbol) \ libc_hidden_def (local) \ weak_alias (local, symbol) #endif -cvt_symbol(fcvt_r); -cvt_symbol(ecvt_r); +cvt_symbol (__qfcvt_r, qfcvt_r); +cvt_symbol (__qecvt_r, qecvt_r); From patchwork Fri Oct 25 15:34:04 2019 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: 1184262 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106332-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="WyeNQ5AK"; 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 4707Zh6GXRz9sPZ for ; Sat, 26 Oct 2019 02:39:24 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=IZVdCia5QZwBb4jcxlIhi4KrZU1u8QTEeYFP28QX+j+ 3gCrww51OE84ydA0m7aiNNQCMDkwMIndcSlE4iJDPJ5JCyTL/Wnel83vlzdcVXW+ bIvu8Cev8FEIWxygtWPUy9WmF4LYp2dJ1cV6XjKhDUla/cVQcyVF6wqqVA12kRHA = 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-transfer-encoding:content-type; s=default; bh=LfZPQmmepPS58UWEorBDdxkahfY=; b=WyeNQ5AK/sC/qB+u9 360ozG4ajlzBgL2cLaAAlAvwSsQMmRQ5xebdme3N4nCLvTddGmUMWHPcqntTTJbh qlfH3IGO8nU74SYZ81EdNOCLtJ1AzZ3dHqrAJbXOwihXTQOBRhjrLelhgu7wIQdD hpWLtD/3fOnrkOWavs/QqSOelI= Received: (qmail 116454 invoked by alias); 25 Oct 2019 15:36:44 -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 116402 invoked by uid 89); 25 Oct 2019 15:36:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy= X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 24/30] ldbl-128ibm-compat: Add *cvt functions Date: Fri, 25 Oct 2019 12:34:04 -0300 Message-ID: <20191025153410.15405-25-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1622703243045555907 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" No changes since v1. -- 8< -- This patch adds IEEE long double versions of q*cvt* functions for powerpc64le. Unlike all other long double to/from string conversion functions, these do not rely on internal functions that can take floating-point numbers with different formats and act on them accordingly, instead, the related files are rebuilt with the -mabi=ieeelongdouble compiler flag set. Having -mabi=ieeelongdouble passed to the compiler causes the object files to be marked with a .gnu_attribute that is incompatible with the .gnu_attribute in files built with -mabi=ibmlongdouble (the default). The difference causes error messages similar to the following: ld: libc_pic.a(s_isinfl.os) uses IBM long double, libc_pic.a(ieee128-qefgcvt_r.os) uses IEEE long double. collect2: error: ld returned 1 exit status make[2]: *** [../Makerules:649: libc_pic.os] Error 1 Although this warning is useful in other situations, the library actually needs to have functions with different long double formats, so .gnu_attribute generation is explicitly disabled for these files with the use of -mno-gnu-attribute. Tested for powerpc64le on the branch that actually enables the sysdeps/ieee754/ldbl-128ibm-compat for powerpc64le. --- misc/efgcvt-template.c | 6 ++- misc/efgcvt_r-template.c | 6 ++- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 12 ++++- sysdeps/ieee754/ldbl-128ibm-compat/Versions | 6 +++ .../ldbl-128ibm-compat/ieee128-qefgcvt.c | 52 +++++++++++++++++++ .../ldbl-128ibm-compat/ieee128-qefgcvt_r.c | 34 ++++++++++++ 6 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c diff --git a/misc/efgcvt-template.c b/misc/efgcvt-template.c index 7fabdf264d..fe4c28bf0f 100644 --- a/misc/efgcvt-template.c +++ b/misc/efgcvt-template.c @@ -23,6 +23,10 @@ #include #include +#ifndef SPRINTF +# define SPRINTF sprintf +#endif + #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b @@ -66,6 +70,6 @@ __ECVT (FLOAT_TYPE value, int ndigit, int *decpt, int *sign) char * __GCVT (FLOAT_TYPE value, int ndigit, char *buf) { - sprintf (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value); + SPRINTF (buf, "%.*" FLOAT_FMT_FLAG "g", MIN (ndigit, NDIGIT_MAX), value); return buf; } diff --git a/misc/efgcvt_r-template.c b/misc/efgcvt_r-template.c index 977750118c..bae2d30a77 100644 --- a/misc/efgcvt_r-template.c +++ b/misc/efgcvt_r-template.c @@ -25,6 +25,10 @@ #include #include +#ifndef SNPRINTF +# define SNPRINTF __snprintf +#endif + #define APPEND(a, b) APPEND2 (a, b) #define APPEND2(a, b) a##b @@ -73,7 +77,7 @@ __FCVT_R (FLOAT_TYPE value, int ndigit, int *decpt, int *sign, /* Value is Inf or NaN. */ *sign = 0; - n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX), + n = SNPRINTF (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX), value); /* Check for a too small buffer. */ if (n >= (ssize_t) len) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 6f1794fac8..759f6e7452 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -251,10 +251,18 @@ endif ifeq ($(subdir),misc) ldbl-extra-routines += err \ error \ - syslog + syslog \ + qefgcvt \ + qefgcvt_r + +CFLAGS-ieee128-qefgcvt.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute +CFLAGS-ieee128-qefgcvt_r.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute tests-internal += tst-ibm128-warn tst-ieee128-warn tests-internal += tst-ibm128-error tst-ieee128-error +tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt + +$(objpfx)tst-ieee128-efgcvt: gnulib-tests += $(f128-loader-link) $(objpfx)tst-ibm128-%.c: tst-ldbl-%.c cp $< $@ @@ -264,9 +272,11 @@ $(objpfx)tst-ieee128-%.c: tst-ldbl-%.c CFLAGS-tst-ibm128-warn.c += -mabi=ibmlongdouble -Wno-psabi CFLAGS-tst-ibm128-error.c += -mabi=ibmlongdouble -Wno-psabi +CFLAGS-tst-ibm128-efgcvt.c += -mabi=ibmlongdouble -Wno-psabi CFLAGS-tst-ieee128-warn.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi CFLAGS-tst-ieee128-error.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-tst-ieee128-efgcvt.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi tests-container += test-syslog-ieee128 test-syslog-ibm128 CFLAGS-test-syslog-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index da8e0ce7ee..b4609c99f7 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -224,5 +224,11 @@ libc { __strfmonieee128; __strfmon_lieee128; + + __qecvtieee128; + __qfcvtieee128; + __qgcvtieee128; + __qecvtieee128_r; + __qfcvtieee128_r; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c new file mode 100644 index 0000000000..8402bd358c --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt.c @@ -0,0 +1,52 @@ +/* IEEE binary128 versions of *cvt functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* When in IEEE long double mode, call ___ieee128_sprintf. */ +#include +typeof (sprintf) ___ieee128_sprintf attribute_hidden; +#define SPRINTF ___ieee128_sprintf + +/* Declare internal functions: ___qecvtieee128_r and ___qfcvtieee128_r, + built from a different compiling unit, and called from here. */ +#include +typeof (qecvt_r) ___qecvtieee128_r; +typeof (qfcvt_r) ___qfcvtieee128_r; + +/* Rename the static buffers and pointer, otherwise the IEEE long double + variants of qecvt and qfcvt would reuse the same buffers and pointer + as their non-IEEE long double counterparts. */ +#define qecvt_buffer qecvtieee128_buffer +#define qfcvt_buffer qfcvtieee128_buffer +#define qfcvt_bufptr qfcvtieee128_bufptr + +#define ECVT __qecvtieee128 +#define FCVT __qfcvtieee128 +#define GCVT __qgcvtieee128 +#define __ECVT ___qecvtieee128 +#define __FCVT ___qfcvtieee128 +#define __GCVT ___qgcvtieee128 +#define __ECVT_R ___qecvtieee128_r +#define __FCVT_R ___qfcvtieee128_r +#include +#include + +#define cvt_symbol(local, symbol) \ + strong_alias (local, symbol) +cvt_symbol (___qfcvtieee128, __qfcvtieee128); +cvt_symbol (___qecvtieee128, __qecvtieee128); +cvt_symbol (___qgcvtieee128, __qgcvtieee128); diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c new file mode 100644 index 0000000000..5eddeff4f5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-qefgcvt_r.c @@ -0,0 +1,34 @@ +/* IEEE binary128 versions of reentrant *cvt_r functions. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* When in IEEE long double mode, call ___ieee128_snprintf. */ +#include +typeof (snprintf) ___ieee128_snprintf attribute_hidden; +#define SNPRINTF ___ieee128_snprintf + +#define ECVT_R __qecvtieee128_r +#define FCVT_R __qfcvtieee128_r +#define __ECVT_R ___qecvtieee128_r +#define __FCVT_R ___qfcvtieee128_r +#include +#include + +#define cvt_symbol(local, symbol) \ + strong_alias (local, symbol) +cvt_symbol (___qfcvtieee128_r, __qfcvtieee128_r); +cvt_symbol (___qecvtieee128_r, __qecvtieee128_r); From patchwork Fri Oct 25 15:34:05 2019 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: 1184263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106333-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="lRRatJSq"; 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 4707Zv1yWrz9sPL for ; Sat, 26 Oct 2019 02:39:35 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=XIqJZoibxSneE1MyjWWOCy4uEVQ9v4GPJ2p4rm3Hbpw SFtFv45TEFZPfs/RAWUkwjDOZQsbp4xObBhSZcjvXas1iuWTx18u+/cPJcyV+fOZ M5WXzUdS304fXruW+fKRZI1HXsh7r7pCspQiiET9dGFGEC5GUe1RfS1zR/XAuHxU = 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-transfer-encoding:content-type; s=default; bh=haA/92/TdO1eG5gHjA1inJLN0zQ=; b=lRRatJSq0WVpOT/sc 1WHtOtiQATj9rMnQc6gAes6lVASG3s5YZ09ss/NKCG0u+rLGqyBOqbzCAwTTkq98 cNHkDQjxC6d/QRjX487vwha4ZxOK2kvd3HZFeBwwuCR0eGwN1F2ojkIrlMq6Dzu3 PZlbB+t+sZxh7GParjxPfQozh8= Received: (qmail 116936 invoked by alias); 25 Oct 2019 15:36:48 -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 116880 invoked by uid 89); 25 Oct 2019 15:36:47 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=transitive, Tulio X-HELO: smtpout1.mo528.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 25/30] Do not redirect calls to __GI_* symbols, when redirecting to *ieee128 Date: Fri, 25 Oct 2019 12:34:05 -0300 Message-ID: <20191025153410.15405-26-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1624110616808050371 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: Tulio Magno Quites Machado Filho Changes since v1: - Reduced the number of changes to the minimum required to build *cvt files in -mabi=ieeelongdouble mode. - Added __LONG_DOUBLE_USES_FLOAT128 to all long-double.h files. -- 8< -- On platforms where long double has IEEE binary128 format as a third option (initially, only powerpc64le), many exported functions are redirected to their __*ieee128 equivalents. This redirection is provided by installed headers such as stdio-ldbl.h, and is supposed to work correctly with user code. However, during the build of glibc, similar redirections are employed, in internal headers, such as include/stdio.h, in order to avoid extra PLT entries. These redirections conflict with the redirections to __*ieee128, and must be avoided during the build. This patch protects the second redirections with a test for __LONG_DOUBLE_USES_FLOAT128, a new macro that is defined to 1 when functions that deal with long double typed values reuses the _Float128 implementation (this is currently only true for powerpc64le). Tested for powerpc64le, x86_64, and with build-many-glibcs.py. Co-authored-by: Gabriel F. T. Gomes --- bits/long-double.h | 1 + include/stdio.h | 11 +++++-- include/stdlib.h | 3 ++ sysdeps/ieee754/ldbl-128/bits/long-double.h | 1 + .../ldbl-128ibm-compat/bits/long-double.h | 29 +++++++++++++++++++ sysdeps/ieee754/ldbl-96/bits/long-double.h | 1 + sysdeps/ieee754/ldbl-opt/bits/long-double.h | 1 + sysdeps/mips/ieee754/bits/long-double.h | 1 + .../linux/sparc/sparc32/bits/long-double.h | 1 + .../linux/sparc/sparc64/bits/long-double.h | 1 + 10 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h diff --git a/bits/long-double.h b/bits/long-double.h index 8bfafe028a..7c2eed521b 100644 --- a/bits/long-double.h +++ b/bits/long-double.h @@ -37,3 +37,4 @@ #ifndef __NO_LONG_DOUBLE_MATH # define __NO_LONG_DOUBLE_MATH 1 #endif +#define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/include/stdio.h b/include/stdio.h index bea2066cd1..dffa7765dd 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -13,7 +13,9 @@ extern int __fcloseall (void) attribute_hidden; extern int __snprintf (char *__restrict __s, size_t __maxlen, const char *__restrict __format, ...) __attribute__ ((__format__ (__printf__, 3, 4))); +# if __LONG_DOUBLE_USES_FLOAT128 == 0 libc_hidden_proto (__snprintf) +# endif extern int __vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) @@ -72,7 +74,8 @@ libc_hidden_proto (__isoc99_vfscanf) Unfortunately, symbol redirection is not transitive, so the __REDIRECT in the public header does not link up with the above libc_hidden_proto. Bridge the gap with a macro. */ -# if !__GLIBC_USE (DEPRECATED_SCANF) +# if !__GLIBC_USE (DEPRECATED_SCANF) \ + && __LONG_DOUBLE_USES_FLOAT128 == 0 # undef sscanf # define sscanf __isoc99_sscanf # endif @@ -150,7 +153,9 @@ libc_hidden_proto (__libc_readline_unlocked); extern const char *const _sys_errlist_internal[] attribute_hidden; extern int _sys_nerr_internal attribute_hidden; +#if __LONG_DOUBLE_USES_FLOAT128 == 0 libc_hidden_proto (__asprintf) +#endif # if IS_IN (libc) extern FILE *_IO_new_fopen (const char*, const char*); # define fopen(fname, mode) _IO_new_fopen (fname, mode) @@ -171,13 +176,15 @@ extern int _IO_new_fgetpos (FILE *, __fpos_t *); # define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp) # endif -libc_hidden_proto (dprintf) extern __typeof (dprintf) __dprintf __attribute__ ((__format__ (__printf__, 2, 3))); libc_hidden_proto (__dprintf) +#if __LONG_DOUBLE_USES_FLOAT128 == 0 +libc_hidden_proto (dprintf) libc_hidden_proto (fprintf) libc_hidden_proto (vfprintf) libc_hidden_proto (sprintf) +#endif libc_hidden_proto (fwrite) libc_hidden_proto (perror) libc_hidden_proto (remove) diff --git a/include/stdlib.h b/include/stdlib.h index 114e12d255..1fab78aa16 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -202,9 +202,12 @@ libc_hidden_proto (____strtoll_l_internal) libc_hidden_proto (____strtoul_l_internal) libc_hidden_proto (____strtoull_l_internal) +#include libc_hidden_proto (strtof) libc_hidden_proto (strtod) +#if __LONG_DOUBLE_USES_FLOAT128 == 0 libc_hidden_proto (strtold) +#endif libc_hidden_proto (strtol) libc_hidden_proto (strtoll) libc_hidden_proto (strtoul) diff --git a/sysdeps/ieee754/ldbl-128/bits/long-double.h b/sysdeps/ieee754/ldbl-128/bits/long-double.h index eac89e233a..17283d3065 100644 --- a/sysdeps/ieee754/ldbl-128/bits/long-double.h +++ b/sysdeps/ieee754/ldbl-128/bits/long-double.h @@ -18,3 +18,4 @@ /* long double is distinct from double, so there is nothing to define here. */ +#define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h new file mode 100644 index 0000000000..02d1b40169 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/bits/long-double.h @@ -0,0 +1,29 @@ +/* Properties of long double type. ldbl-opt version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef __NO_LONG_DOUBLE_MATH +# define __LONG_DOUBLE_MATH_OPTIONAL 1 +# ifndef __LONG_DOUBLE_128__ +# define __NO_LONG_DOUBLE_MATH 1 +# endif +#endif +/* On platforms that reuse the _Float128 implementation for IEEE long + double, access to the correct long double functions is selected based + on the long double mode being used during the compilation. On + powerpc64le, this is true when -mabi=ieeelongdouble is in use. */ +#define __LONG_DOUBLE_USES_FLOAT128 (__LDBL_MANT_DIG__ == 113) diff --git a/sysdeps/ieee754/ldbl-96/bits/long-double.h b/sysdeps/ieee754/ldbl-96/bits/long-double.h index 72d15da6c8..e55227b69a 100644 --- a/sysdeps/ieee754/ldbl-96/bits/long-double.h +++ b/sysdeps/ieee754/ldbl-96/bits/long-double.h @@ -18,3 +18,4 @@ /* long double is distinct from double, so there is nothing to define here. */ +#define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/sysdeps/ieee754/ldbl-opt/bits/long-double.h b/sysdeps/ieee754/ldbl-opt/bits/long-double.h index 1e8fb5886e..8fa37a0e33 100644 --- a/sysdeps/ieee754/ldbl-opt/bits/long-double.h +++ b/sysdeps/ieee754/ldbl-opt/bits/long-double.h @@ -22,3 +22,4 @@ # define __NO_LONG_DOUBLE_MATH 1 # endif #endif +#define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/sysdeps/mips/ieee754/bits/long-double.h b/sysdeps/mips/ieee754/bits/long-double.h index b52f3f860e..808f3e300c 100644 --- a/sysdeps/mips/ieee754/bits/long-double.h +++ b/sysdeps/mips/ieee754/bits/long-double.h @@ -21,3 +21,4 @@ #if !defined __NO_LONG_DOUBLE_MATH && _MIPS_SIM == _ABIO32 # define __NO_LONG_DOUBLE_MATH 1 #endif +#define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h b/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h index aec2a86c96..bd403fba21 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/bits/long-double.h @@ -24,3 +24,4 @@ # define __NO_LONG_DOUBLE_MATH 1 # endif #endif +#define __LONG_DOUBLE_USES_FLOAT128 0 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h index aec2a86c96..bd403fba21 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/bits/long-double.h @@ -24,3 +24,4 @@ # define __NO_LONG_DOUBLE_MATH 1 # endif #endif +#define __LONG_DOUBLE_USES_FLOAT128 0 From patchwork Fri Oct 25 15:34:06 2019 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: 1184264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106334-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="kPcKPCTw"; 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 4707b61sZBz9sPZ for ; Sat, 26 Oct 2019 02:39:46 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=WQ57SsjK3W0BSN7vXxBhPWeSIFJNB3JAGkYaS7akUxX ilSvx0pvVgtuMdyi9bbPCEWLK+naqv8rYVz6Mn5ZogvnJLNxPbzXtQpXHnwg5kls wMv5cKaBS+6ZsDebMW5qW0kGmqRVpUkO0OXJcgSNQLRvXwKDUeSQlkQNSjUv1qP4 = 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-transfer-encoding:content-type; s=default; bh=R/9UCKeGVTII3KvepJphR14fXo4=; b=kPcKPCTwdUdNX+l2w 1DIVqLZbzFsiy6ikWLiDD9cWQRvddQ02+wxxq4ffPy/GBOdIGa0ApltJne4JnHYL myFnkZH0rzrY+xfvk3rMlvwKS4fBjcLQFVtj2AjjDYUzqcZxDlYsfZm15UR7Fxev YTpy4nT4kCcIxKsmc5q02Ei0hE= Received: (qmail 117384 invoked by alias); 25 Oct 2019 15:36:51 -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 117338 invoked by uid 89); 25 Oct 2019 15:36:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*F:D*br, HContent-Transfer-Encoding:8bit X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 26/30] ldbl-128ibm-compat: Compiler flags for stdio functions Date: Fri, 25 Oct 2019 12:34:06 -0300 Message-ID: <20191025153410.15405-27-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1625517993222852291 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: Tulio Magno Quites Machado Filho No changes since v1. -- 8< -- Some of the files that provide stdio.h and wchar.h functions have a filename prefixed with 'io', such as 'iovsprintf.c'. On platforms that imply ldbl-128ibm-compat, these files must be compiled with the flag -mabi=ibmlongdouble. This patch adds this flag to their compilation. Notice that this is not required for the other files that provide similar functions, because filenames that are not prefixed with 'io' have ldbl-128ibm-compat counterparts in the Makefile, which already adds -mabi=ibmlongdouble to them. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 759f6e7452..013f2d7fc5 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -325,6 +325,12 @@ routines += $(foreach r,$(ldbl-extra-routines),ieee128-$(r)) # always be built in IBM long double mode, with additional support for # IEEE binary128, through the use of -mabi=ibmlongdouble and -mfloat128. ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \ + $(objpfx)iovdprintf^ \ + $(objpfx)iovsprintf^ \ + $(objpfx)iovsscanf^ \ + $(objpfx)iovswscanf^ \ + $(objpfx)iovfscanf^ \ + $(objpfx)iovfwscanf^ \ $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \ $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^) obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1))) From patchwork Fri Oct 25 15:34:07 2019 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: 1184265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106335-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="hpgD5kc9"; 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 4707bH40Ldz9sPZ for ; Sat, 26 Oct 2019 02:39:55 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=l30Oh7eiq2mnyTSNM8JmhyZhQ8gs/rXLQeHA5MeH6HV A8vf6QMG9jdgYdjiaHpIqZRtiiLaIJw7n0uDO0/kvqasqkdKm0zahInALANUm31P eMQllLjQzdX7EQqtW7Ib6uCR4w36fI/g56gnQWfz6iZU2hD7RnuYtSpzndFqjfWA = 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-transfer-encoding:content-type; s=default; bh=8GA5r16CnCqUCzudIltQOhuDITs=; b=hpgD5kc9vDvoUuRN4 8IUAW1EpGp6e2a48drLjmasjXpyRUo7y6Lwcx7taoaIMF8Efd4noPB9Ny/qHH2lb vlhBoAVJLP2txoMwZVGdSUtp/65S48J4PAcoA8NCaVHwimt4v4WS73Yls36xKBIQ Gl6LYBJ2/brNJ+r31UvcRaJ+Z8= Received: (qmail 118012 invoked by alias); 25 Oct 2019 15:36:56 -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 117959 invoked by uid 89); 25 Oct 2019 15:36:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=H*F:D*br, HContent-Transfer-Encoding:8bit X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 27/30] Avoid compat symbols for totalorder in powerpc64le IEEE long double Date: Fri, 25 Oct 2019 12:34:07 -0300 Message-ID: <20191025153410.15405-28-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1626925369556651715 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" Changes since v1: - Added comment on the redefinition of libm_alias_float128_other_r_ldbl. -- 8< -- On powerpc64le, the libm_alias_float128_other_r_ldbl macro is used to create an alias between totalorderf128 and __totalorderlieee128, as well as between the totalordermagf128 and __totalordermaglieee128. However, the totalorder* and totalordermag* functions changed their parameter type since commit ID 42760d764649 and got compat symbols for their old versions. With this change, the aforementioned macro would create two conflicting aliases for __totalorderlieee128 and __totalordermaglieee128. This patch avoids the creation of the alias between the IEEE long double symbols (__totalorderl*ieee128) and the compat symbols, because the IEEE long double functions have never been exported thus don't need such compat symbol. --- sysdeps/ieee754/ldbl-128/s_totalorderl.c | 9 +++++++++ sysdeps/ieee754/ldbl-128/s_totalordermagl.c | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/sysdeps/ieee754/ldbl-128/s_totalorderl.c b/sysdeps/ieee754/ldbl-128/s_totalorderl.c index 098bd2bcab..f9db06c025 100644 --- a/sysdeps/ieee754/ldbl-128/s_totalorderl.c +++ b/sysdeps/ieee754/ldbl-128/s_totalorderl.c @@ -74,6 +74,15 @@ __totalorder_compatl (_Float128 x, _Float128 y) { return __totalorderl (&x, &y); } +/* On platforms that reuse the _Float128 implementation for IEEE long + double (powerpc64le), the libm_alias_float128_other_r_ldbl macro + (which is called by the libm_alias_ldouble macro) is used to create + aliases between *f128 (_Float128 API) and __*ieee128 functions. + However, this compat version of totalorderl is older than the + availability of __ieee*128 symbols, thus, the compat alias is not + required, nor desired. */ +#undef libm_alias_float128_other_r_ldbl +#define libm_alias_float128_other_r_ldbl(from, to, r) #undef do_symbol #define do_symbol(orig_name, name, aliasname) \ strong_alias (orig_name, name) \ diff --git a/sysdeps/ieee754/ldbl-128/s_totalordermagl.c b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c index b31788c77c..45b17ed4dd 100644 --- a/sysdeps/ieee754/ldbl-128/s_totalordermagl.c +++ b/sysdeps/ieee754/ldbl-128/s_totalordermagl.c @@ -68,6 +68,15 @@ __totalordermag_compatl (_Float128 x, _Float128 y) { return __totalordermagl (&x, &y); } +/* On platforms that reuse the _Float128 implementation for IEEE long + double (powerpc64le), the libm_alias_float128_other_r_ldbl macro + (which is called by the libm_alias_ldouble macro) is used to create + aliases between *f128 (_Float128 API) and __*ieee128 functions. + However, this compat version of totalordermagl is older than the + availability of __ieee*128 symbols, thus, the compat alias is not + required, nor desired. */ +#undef libm_alias_float128_other_r_ldbl +#define libm_alias_float128_other_r_ldbl(from, to, r) #undef do_symbol #define do_symbol(orig_name, name, aliasname) \ strong_alias (orig_name, name) \ From patchwork Fri Oct 25 15:34:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 1184266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106336-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="KZu2D+pL"; 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 4707bS0Mfzz9sPZ for ; Sat, 26 Oct 2019 02:40:03 +1100 (AEDT) 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:content-transfer-encoding; q=dns; s=default; b=XmZer5UzgpSrPY4JSEL6pzywooMnv8D95dWYXDtHMWn PZmG+0Qz0dqO69EIxr/ymDjvy5cvqRaHJsO/Cmm1z2LA9slZhl7XcjCcja0Uf9bB W6l7M1GgPx39bpxHnhc0DZGaa5B3UK7tInJ1zCufkhtDPAIVHCNuaAXQBXMgKKH8 = 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:content-transfer-encoding; s=default; bh=YbnZvPKofzDVk9pVGutkuiwm0ow=; b=KZu2D+pL7s6sC3L2W ONJBey17SJimnNWkYDW2rJhhrKDvwaSqIx/vdULVcNAqXibWC1x84jtInlctntbh xWQbc4/gUKmRUDISDtl7zsH/deS+qiVDnzc1gOI2QhXpHGjr6NP6Okt/rQpgOFkU EjykTu9tSKJoUEIuewWBLw0GPo= Received: (qmail 118676 invoked by alias); 25 Oct 2019 15:37:01 -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 118611 invoked by uid 89); 25 Oct 2019 15:37:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=complain, H*F:D*br X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 28/30] ldbl-128ibm-compat: Do not mix -mabi=*longdouble and -mlong-double-128 Date: Fri, 25 Oct 2019 12:34:08 -0300 Message-ID: <20191025153410.15405-29-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1628332740653272771 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" Changes since v1: - Do not try to remove -mabi=ieeelongdouble, since it hasn't been added. The removal is a residue from our initial development. -- 8< -- Some compiler versions, e.g. GCC 7, complain when -mlong-double-128 is used together with -mabi=ibmlongdouble or -mabi=ieeelongdouble, producing the following error message: cc1: error: ‘-mabi=ibmlongdouble’ requires ‘-mlong-double-128’ This patch removes -mlong-double-128 from the compilation lines that explicitly request -mabi=*longdouble. Tested for powerpc64le. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 013f2d7fc5..a7c25add7e 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -258,6 +258,13 @@ ldbl-extra-routines += err \ CFLAGS-ieee128-qefgcvt.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute CFLAGS-ieee128-qefgcvt_r.c += -mabi=ieeelongdouble -Wno-psabi -mno-gnu-attribute +# Remove -mlong-double-128 because it does not work correctly with +# -mabi=ibmlongdoule in some GCC versions, e.g. GCC 7. +$(foreach o,$(all-object-suffixes),$(objpfx)ieee128-qefgcvt$(o)): \ + sysdep-CFLAGS := $(filter-out -mlong-double-128, $(sysdep-CFLAGS)) +$(foreach o,$(all-object-suffixes),$(objpfx)ieee128-qefgcvt_r$(o)): \ + sysdep-CFLAGS := $(filter-out -mlong-double-128, $(sysdep-CFLAGS)) + tests-internal += tst-ibm128-warn tst-ieee128-warn tests-internal += tst-ibm128-error tst-ieee128-error tests-internal += tst-ibm128-efgcvt tst-ieee128-efgcvt @@ -334,5 +341,12 @@ ldbl-ibm128-files := $(objpfx)test-%-ibm128^ \ $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)^) \ $(foreach r,$(ldbl-extra-routines),$(objpfx)$(r)-internal^) obj-suf-foreach = $(foreach suf,$(all-object-suffixes),$(subst ^,$(suf),$(1))) + +# Remove -mlong-double-128 because it does not work correctly with +# -mabi=ibmlongdoule in some GCC versions, e.g. GCC 7. +$(call obj-suf-foreach,$(ldbl-ibm128-files)): \ + sysdep-CFLAGS := $(filter-out -mlong-double-128, $(sysdep-CFLAGS)) + +# Explicitly add -mabi=ibm-long-double to required files. $(call obj-suf-foreach,$(ldbl-ibm128-files)): \ sysdep-CFLAGS += -mabi=ibmlongdouble From patchwork Fri Oct 25 15:34:09 2019 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: 1184267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106337-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="h53oPg8H"; 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 4707bf2SJbz9sPZ for ; Sat, 26 Oct 2019 02:40:14 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=p6N3obPowgCcCPR0j2MlDTopVQ44fpsvYYDqz6ZocDb hQAq1qolOAOPzyoIWbkwrWKcnAFJgbaSbTo/e7ukQkJfpv4U3a4fr0NwRjOKV5p9 SJO+f6BojftJFShMExyuYKqJaybdIZYc/aU+R+K66JsALxmU88BGpTBGXOxUUYyk = 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-transfer-encoding:content-type; s=default; bh=74pcaIYiBvbDdnJKv7JtC5RWWxQ=; b=h53oPg8HXmaxmIaiG qJeh6Yx8wAcDqV5olEW0vgHfgTkwR4ZQWcpZ444AzHSUVTZK0ZSHrl9iq7tPxkwh HdmLSJMc0GOcaFPR4JMkQNGIOsBoSlff8ZK+THolNu+mZ51yvEdav5GirMPWOB/C YxLMyc9as/CVMj1YaDIfVaWksc= Received: (qmail 119526 invoked by alias); 25 Oct 2019 15:37:09 -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 119464 invoked by uid 89); 25 Oct 2019 15:37:08 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=POWER8, newest, sk:ac_comp, ac_cache_check X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 29/30] powerpc64le: Require a compiler with -mno-gnu-attribute Date: Fri, 25 Oct 2019 12:34:09 -0300 Message-ID: <20191025153410.15405-30-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1630303066656919235 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" Changes since v1: - Added mentions to the build requirement in manual/install.texi, INSTALL (regenerated) and NEWS. -- 8< -- On powerpc64le, a few files are built on IEEE long double mode (-mabi=ieeelongdouble), whereas most are built on IBM long double mode (-mabi=ibmlongdouble, the default for -mlong-double-128). Since binutils 2.31, linking object files with different long double modes causes errors similar to: ld: libc_pic.a(s_isinfl.os) uses IBM long double, libc_pic.a(ieee128-qefgcvt.os) uses IEEE long double. collect2: error: ld returned 1 exit status make[2]: *** [../Makerules:649: libc_pic.os] Error 1 The warnings are fair and correct, but in order for glibc to have support for both long double modes on powerpc64le, they have to be ignored. This can be accomplished with the use of -mno-gnu-attribute option when building the few files that require IEEE long double mode. However, -mno-gnu-attribute is not available in GCC 6, the minimum version required to build glibc, so this patch adds a test for this feature in powerpc64le builds, and fails early if it's not available. Tested, on powerpc64le, that the build fails early with GCC 6 and that it succeeds with GCC 7 or greater. --- INSTALL | 5 ++++ NEWS | 2 +- manual/install.texi | 5 ++++ sysdeps/powerpc/powerpc64/le/configure | 29 +++++++++++++++++++++++ sysdeps/powerpc/powerpc64/le/configure.ac | 15 ++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/INSTALL b/INSTALL index 392537cc5c..1baa99f304 100644 --- a/INSTALL +++ b/INSTALL @@ -467,6 +467,11 @@ build the GNU C Library: better code. As of release time, GCC 9.1.1 is the newest compiler verified to work to build the GNU C Library. + For PowerPC 64-bits little-endian (powerpc64le), a GCC version with + support for -mno-gnu-attribute is required. As of release time, + this means GCC 7 or higher. The compiler option is required for + building the GNU C Library with support for IEEE long double. + For multi-arch support it is recommended to use a GCC which has been built with support for GNU indirect functions. This ensures that correct debugging information is generated for functions diff --git a/NEWS b/NEWS index d7286841c9..7fb3727ab0 100644 --- a/NEWS +++ b/NEWS @@ -32,7 +32,7 @@ Deprecated and removed features, and other changes affecting compatibility: Changes to build and runtime requirements: - [Add changes to build and runtime requirements here] +* On powerpc64le, GCC 7 or later is required to build the GNU C Library. Security related changes: diff --git a/manual/install.texi b/manual/install.texi index b2d569ac5a..85767ebde3 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -507,6 +507,11 @@ the newest version of the compiler that is known to work for building release time, GCC 9.1.1 is the newest compiler verified to work to build @theglibc{}. +For PowerPC 64-bits little-endian (powerpc64le), a GCC version with +support for -mno-gnu-attribute is required. As of release time, this +means GCC 7 or higher. The compiler option is required for building the +GNU C Library with support for IEEE long double. + For multi-arch support it is recommended to use a GCC which has been built with support for GNU indirect functions. This ensures that correct debugging information is generated for functions selected by IFUNC resolvers. This diff --git a/sysdeps/powerpc/powerpc64/le/configure b/sysdeps/powerpc/powerpc64/le/configure index bca80cec76..c8e01af4f2 100644 --- a/sysdeps/powerpc/powerpc64/le/configure +++ b/sysdeps/powerpc/powerpc64/le/configure @@ -32,4 +32,33 @@ if test "$libc_cv_target_power8_ok" != "yes"; then : fi CFLAGS="$OLD_CFLAGS" +# Local configure fragment for sysdeps/powerpc/powerpc64le. + +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -mno-gnu-attribute" +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler supports -mno-gnu-attribute" >&5 +$as_echo_n "checking if the compiler supports -mno-gnu-attribute... " >&6; } +if ${libc_cv_no_gnu_attr_ok+:} false; then : + $as_echo_n "(cached) " >&6 +else + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + libc_cv_no_gnu_attr_ok=yes +else + libc_cv_no_gnu_attr_ok=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_no_gnu_attr_ok" >&5 +$as_echo "$libc_cv_no_gnu_attr_ok" >&6; } +if test "$libc_cv_no_gnu_attr_ok" != "yes"; then : + critic_missing="$critic_missing A compiler with -mno-gnu-attribute is required on powerpc64le." +fi +CFLAGS="$OLD_CFLAGS" + test -n "$critic_missing" && as_fn_error $? "*** $critic_missing" "$LINENO" 5 diff --git a/sysdeps/powerpc/powerpc64/le/configure.ac b/sysdeps/powerpc/powerpc64/le/configure.ac index 7f2c9fbf1f..fdec69603b 100644 --- a/sysdeps/powerpc/powerpc64/le/configure.ac +++ b/sysdeps/powerpc/powerpc64/le/configure.ac @@ -17,4 +17,19 @@ AS_IF([test "$libc_cv_target_power8_ok" != "yes"], [critic_missing="$critic_missing POWER8 or newer is required on powerpc64le."]) CFLAGS="$OLD_CFLAGS" +# Local configure fragment for sysdeps/powerpc/powerpc64le. + +dnl Require support for -mno-gnu-attribute +OLD_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS -mno-gnu-attribute" +AC_CACHE_CHECK([if the compiler supports -mno-gnu-attribute], + libc_cv_no_gnu_attr_ok, [ +AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ +]])], + [libc_cv_no_gnu_attr_ok=yes], + [libc_cv_no_gnu_attr_ok=no])]) +AS_IF([test "$libc_cv_no_gnu_attr_ok" != "yes"], + [critic_missing="$critic_missing A compiler with -mno-gnu-attribute is required on powerpc64le."]) +CFLAGS="$OLD_CFLAGS" + test -n "$critic_missing" && AC_MSG_ERROR([*** $critic_missing]) From patchwork Fri Oct 25 15:34:10 2019 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: 1184268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-106338-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.net.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="TCoygYrH"; 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 4707br0mG2z9sPL for ; Sat, 26 Oct 2019 02:40:23 +1100 (AEDT) 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-transfer-encoding:content-type; q=dns; s=default; b=U8Vwd55pVIbGJSfARwQEzCToIIRhH9ZLsxQI6b315FM BdoulLikU5hP7096v4SXJhA5FP0QQ7XveGaXviarLQX1DTRdusDfy9FxcWMDduO2 kn8Bsclq+fV6R1uK2oO44Ch4mQGE7mK0tGsdH2cE5KG8Sp6an4eahu3lLpBCgUks = 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-transfer-encoding:content-type; s=default; bh=shH8GMJK4iYv/tpWzZ3kS9xcla4=; b=TCoygYrHl/NwGNUKP OYZ6i8dIl6KeV2lvJZyB3/3R5xAmrbZIGvUGio2HH0u4LHN1wLt1kha/C0ip70r/ sJm+2VsnKAkw+Zp3tVHLWgGUbQ5T7wSJuTU30ZJoznFu1Z5xfURHrJsOaP8hiLSd RMANuhrDH+gGJfB/cnOL9eO02o= Received: (qmail 120181 invoked by alias); 25 Oct 2019 15:37:15 -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 120126 invoked by uid 89); 25 Oct 2019 15:37:15 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=4723 X-HELO: smtpout1.mo803.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v2 30/30] RFC: powerpc64le: Enable support for IEEE long double Date: Fri, 25 Oct 2019 12:34:10 -0300 Message-ID: <20191025153410.15405-31-gabriel@inconstante.net.br> In-Reply-To: <20191025153410.15405-1-gabriel@inconstante.net.br> References: <20191025153410.15405-1-gabriel@inconstante.net.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 1631147490496532163 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedufedrleefgdelvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecu From: "Gabriel F. T. Gomes" DO NOT COMMIT! Changes since v1: - Use __LONG_DOUBLE_USES_FLOAT128 directly. -- 8< -- On platforms where long double may have two different formats, i.e.: the same format as double (64-bits) or something else (128-bits), building with -mlong-double-128 is the default and function calls in the user program match the name of the function in Glibc. When building with -mlong-double-64, Glibc installed headers redirect such calls to the appropriate function. This patch adds similar redirections to be used by user code builds in IEEE long double mode (-mabi=ieeelongdouble). It also skips some uses of libc_hidden_proto in internal headers, because they also produce redirections, causing a redirection conflict. PS: Missing NEWS entry. --- argp/argp.h | 3 +- libio/bits/stdio-ldbl.h | 46 +++++--- libio/stdio.h | 16 ++- misc/bits/syslog-ldbl.h | 4 +- misc/err.h | 3 +- misc/error.h | 6 +- misc/sys/cdefs.h | 38 ++++++- misc/sys/syslog.h | 4 +- stdio-common/printf.h | 3 +- stdlib/bits/stdlib-ldbl.h | 22 ++++ stdlib/monetary.h | 3 +- stdlib/stdlib.h | 4 +- sysdeps/powerpc/powerpc64/le/Implies-before | 1 + .../linux/powerpc/powerpc64/le/libc.abilist | 93 ++++++++++++++++ .../linux/powerpc/powerpc64/le/libm.abilist | 104 ++++++++++++++++++ wcsmbs/bits/wchar-ldbl.h | 36 +++++- wcsmbs/wchar.h | 14 ++- 17 files changed, 357 insertions(+), 43 deletions(-) diff --git a/argp/argp.h b/argp/argp.h index 07adec1895..9d4d26370b 100644 --- a/argp/argp.h +++ b/argp/argp.h @@ -554,7 +554,8 @@ __NTH (__option_is_end (const struct argp_option *__opt)) # endif #endif /* Use extern inlines. */ -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/libio/bits/stdio-ldbl.h b/libio/bits/stdio-ldbl.h index 2f01a98384..6b90433616 100644 --- a/libio/bits/stdio-ldbl.h +++ b/libio/bits/stdio-ldbl.h @@ -27,9 +27,17 @@ __LDBL_REDIR_DECL (vfprintf) __LDBL_REDIR_DECL (vprintf) __LDBL_REDIR_DECL (vsprintf) #if !__GLIBC_USE (DEPRECATED_SCANF) +# if defined __LDBL_COMPAT __LDBL_REDIR1_DECL (fscanf, __nldbl___isoc99_fscanf) __LDBL_REDIR1_DECL (scanf, __nldbl___isoc99_scanf) __LDBL_REDIR1_DECL (sscanf, __nldbl___isoc99_sscanf) +# elif __LONG_DOUBLE_USES_FLOAT128 == 1 +__LDBL_REDIR1_DECL (fscanf, __isoc99_fscanfieee128) +__LDBL_REDIR1_DECL (scanf, __isoc99_scanfieee128) +__LDBL_REDIR1_DECL (sscanf, __isoc99_sscanfieee128) +# else +# error bits/stdlib-ldbl.h included when no ldbl redirections are required. +# endif #else __LDBL_REDIR_DECL (fscanf) __LDBL_REDIR_DECL (scanf) @@ -43,9 +51,17 @@ __LDBL_REDIR_DECL (vsnprintf) #ifdef __USE_ISOC99 # if !__GLIBC_USE (DEPRECATED_SCANF) +# if defined __LDBL_COMPAT __LDBL_REDIR1_DECL (vfscanf, __nldbl___isoc99_vfscanf) __LDBL_REDIR1_DECL (vscanf, __nldbl___isoc99_vscanf) __LDBL_REDIR1_DECL (vsscanf, __nldbl___isoc99_vsscanf) +# elif __LONG_DOUBLE_USES_FLOAT128 == 1 +__LDBL_REDIR1_DECL (vfscanf, __isoc99_vfscanfieee128) +__LDBL_REDIR1_DECL (vscanf, __isoc99_vscanfieee128) +__LDBL_REDIR1_DECL (vsscanf, __isoc99_vsscanfieee128) +# else +# error bits/stdlib-ldbl.h included when no ldbl redirections are required. +# endif # else __LDBL_REDIR_DECL (vfscanf) __LDBL_REDIR_DECL (vsscanf) @@ -60,33 +76,33 @@ __LDBL_REDIR_DECL (dprintf) #ifdef __USE_GNU __LDBL_REDIR_DECL (vasprintf) -__LDBL_REDIR_DECL (__asprintf) +__LDBL_REDIR2_DECL (asprintf) __LDBL_REDIR_DECL (asprintf) __LDBL_REDIR_DECL (obstack_printf) __LDBL_REDIR_DECL (obstack_vprintf) #endif #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function -__LDBL_REDIR_DECL (__sprintf_chk) -__LDBL_REDIR_DECL (__vsprintf_chk) +__LDBL_REDIR2_DECL (sprintf_chk) +__LDBL_REDIR2_DECL (vsprintf_chk) # if defined __USE_ISOC99 || defined __USE_UNIX98 -__LDBL_REDIR_DECL (__snprintf_chk) -__LDBL_REDIR_DECL (__vsnprintf_chk) +__LDBL_REDIR2_DECL (snprintf_chk) +__LDBL_REDIR2_DECL (vsnprintf_chk) # endif # if __USE_FORTIFY_LEVEL > 1 -__LDBL_REDIR_DECL (__fprintf_chk) -__LDBL_REDIR_DECL (__printf_chk) -__LDBL_REDIR_DECL (__vfprintf_chk) -__LDBL_REDIR_DECL (__vprintf_chk) +__LDBL_REDIR2_DECL (fprintf_chk) +__LDBL_REDIR2_DECL (printf_chk) +__LDBL_REDIR2_DECL (vfprintf_chk) +__LDBL_REDIR2_DECL (vprintf_chk) # ifdef __USE_XOPEN2K8 -__LDBL_REDIR_DECL (__dprintf_chk) -__LDBL_REDIR_DECL (__vdprintf_chk) +__LDBL_REDIR2_DECL (dprintf_chk) +__LDBL_REDIR2_DECL (vdprintf_chk) # endif # ifdef __USE_GNU -__LDBL_REDIR_DECL (__asprintf_chk) -__LDBL_REDIR_DECL (__vasprintf_chk) -__LDBL_REDIR_DECL (__obstack_printf_chk) -__LDBL_REDIR_DECL (__obstack_vprintf_chk) +__LDBL_REDIR2_DECL (asprintf_chk) +__LDBL_REDIR2_DECL (vasprintf_chk) +__LDBL_REDIR2_DECL (obstack_printf_chk) +__LDBL_REDIR2_DECL (obstack_vprintf_chk) # endif # endif #endif diff --git a/libio/stdio.h b/libio/stdio.h index 1abce9b3f1..819d0a6402 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -400,9 +400,12 @@ extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __THROW; /* For historical reasons, the C99-compliant versions of the scanf - functions are at alternative names. When __LDBL_COMPAT is in - effect, this is handled in bits/stdio-ldbl.h. */ -#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT + functions are at alternative names. When __LDBL_COMPAT or + __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in + bits/stdio-ldbl.h. */ +#include +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \ + && __LONG_DOUBLE_USES_FLOAT128 == 0 # ifdef __REDIRECT extern int __REDIRECT (fscanf, (FILE *__restrict __stream, const char *__restrict __format, ...), @@ -447,7 +450,8 @@ extern int vsscanf (const char *__restrict __s, /* Same redirection as above for the v*scanf family. */ # if !__GLIBC_USE (DEPRECATED_SCANF) -# if defined __REDIRECT && !defined __LDBL_COMPAT +# if defined __REDIRECT && !defined __LDBL_COMPAT \ + && __LONG_DOUBLE_USES_FLOAT128 == 0 extern int __REDIRECT (vfscanf, (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg), @@ -866,7 +870,9 @@ extern int __overflow (FILE *, int); #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include #endif -#ifdef __LDBL_COMPAT + +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/misc/bits/syslog-ldbl.h b/misc/bits/syslog-ldbl.h index 8d60fb8e44..5075e50379 100644 --- a/misc/bits/syslog-ldbl.h +++ b/misc/bits/syslog-ldbl.h @@ -27,9 +27,9 @@ __LDBL_REDIR_DECL (vsyslog) #endif #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function -__LDBL_REDIR_DECL (__syslog_chk) +__LDBL_REDIR2_DECL (syslog_chk) # ifdef __USE_MISC -__LDBL_REDIR_DECL (__vsyslog_chk) +__LDBL_REDIR2_DECL (vsyslog_chk) # endif #endif diff --git a/misc/err.h b/misc/err.h index a71b3fafe0..f3b39edfe8 100644 --- a/misc/err.h +++ b/misc/err.h @@ -52,7 +52,8 @@ extern void errx (int __status, const char *__format, ...) extern void verrx (int __status, const char *, __gnuc_va_list) __attribute__ ((__noreturn__, __format__ (__printf__, 2, 0))); -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/misc/error.h b/misc/error.h index 79840bf0f7..0170d89b52 100644 --- a/misc/error.h +++ b/misc/error.h @@ -47,11 +47,13 @@ extern unsigned int error_message_count; variable controls whether this mode is selected or not. */ extern int error_one_per_line; -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #else /* Do not inline error and error_at_line when long double has the same - size of double, because that would invalidate the redirections to the + size of double, nor when long double reuses the float128 + implementation, because that would invalidate the redirections to the compatibility functions. */ # if defined __extern_always_inline && defined __va_arg_pack # include diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h index abcb0d5e3c..4f1d66e425 100644 --- a/misc/sys/cdefs.h +++ b/misc/sys/cdefs.h @@ -460,7 +460,37 @@ #include #include -#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH +#if __LONG_DOUBLE_USES_FLOAT128 == 1 +# ifdef __REDIRECT + +/* Alias name defined automatically. */ +# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir +# define __LDBL_REDIR_DECL(name) \ + extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128")); + +/* Alias name defined automatically, with leading underscores. */ +# define __LDBL_REDIR2_DECL(name) \ + extern __typeof (__##name) __##name \ + __asm (__ASMNAME ("__" #name "ieee128")); + +/* Alias name defined manually. */ +# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1 +# define __LDBL_REDIR1_DECL(name, alias) \ + extern __typeof (name) name __asm (__ASMNAME (#alias)); + +# define __LDBL_REDIR1_NTH(name, proto, alias) \ + __REDIRECT_NTH (name, proto, alias) +# define __REDIRECT_NTH_LDBL(name, proto, alias) \ + __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128) + +/* Unused. */ +# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl +# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth + +# else +_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform"); +# endif +#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH # define __LDBL_COMPAT 1 # ifdef __REDIRECT # define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias) @@ -469,6 +499,8 @@ # define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias) # define __LDBL_REDIR_NTH(name, proto) \ __LDBL_REDIR1_NTH (name, proto, __nldbl_##name) +# define __LDBL_REDIR2_DECL(name) \ + extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name)); # define __LDBL_REDIR1_DECL(name, alias) \ extern __typeof (name) name __asm (__ASMNAME (#alias)); # define __LDBL_REDIR_DECL(name) \ @@ -479,11 +511,13 @@ __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias) # endif #endif -#if !defined __LDBL_COMPAT || !defined __REDIRECT +#if (!defined __LDBL_COMPAT && __LONG_DOUBLE_USES_FLOAT128 == 0) \ + || !defined __REDIRECT # define __LDBL_REDIR1(name, proto, alias) name proto # define __LDBL_REDIR(name, proto) name proto # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW # define __LDBL_REDIR_NTH(name, proto) name proto __THROW +# define __LDBL_REDIR2_DECL(name) # define __LDBL_REDIR_DECL(name) # ifdef __REDIRECT # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) diff --git a/misc/sys/syslog.h b/misc/sys/syslog.h index ee01478c4b..c000b8e915 100644 --- a/misc/sys/syslog.h +++ b/misc/sys/syslog.h @@ -206,7 +206,9 @@ extern void vsyslog (int __pri, const char *__fmt, __gnuc_va_list __ap) #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include #endif -#ifdef __LDBL_COMPAT + +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/stdio-common/printf.h b/stdio-common/printf.h index 2eb0b51382..e93a2bdebd 100644 --- a/stdio-common/printf.h +++ b/stdio-common/printf.h @@ -182,7 +182,8 @@ extern int printf_size_info (const struct printf_info *__restrict __info, size_t __n, int *__restrict __argtypes) __THROW; -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/stdlib/bits/stdlib-ldbl.h b/stdlib/bits/stdlib-ldbl.h index dcbf74a6dd..615ee3131a 100644 --- a/stdlib/bits/stdlib-ldbl.h +++ b/stdlib/bits/stdlib-ldbl.h @@ -21,21 +21,43 @@ #endif #ifdef __USE_ISOC99 +# ifdef __LDBL_COMPAT __LDBL_REDIR1_DECL (strtold, strtod) +# else +__LDBL_REDIR1_DECL (strtold, __strtoieee128) +# endif #endif #ifdef __USE_GNU +# ifdef __LDBL_COMPAT __LDBL_REDIR1_DECL (strtold_l, strtod_l) +# else +__LDBL_REDIR1_DECL (strtold_l, __strtoieee128_l) +# endif #endif #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X) +# ifdef __LDBL_COMPAT __LDBL_REDIR1_DECL (strfroml, strfromd) +# else +__LDBL_REDIR1_DECL (strfroml, __strfromieee128) +# endif #endif #ifdef __USE_MISC +# if defined __LDBL_COMPAT __LDBL_REDIR1_DECL (qecvt, ecvt) __LDBL_REDIR1_DECL (qfcvt, fcvt) __LDBL_REDIR1_DECL (qgcvt, gcvt) __LDBL_REDIR1_DECL (qecvt_r, ecvt_r) __LDBL_REDIR1_DECL (qfcvt_r, fcvt_r) +# elif __LONG_DOUBLE_USES_FLOAT128 == 1 +__LDBL_REDIR1_DECL (qecvt, __qecvtieee128) +__LDBL_REDIR1_DECL (qfcvt, __qfcvtieee128) +__LDBL_REDIR1_DECL (qgcvt, __qgcvtieee128) +__LDBL_REDIR1_DECL (qecvt_r, __qecvtieee128_r) +__LDBL_REDIR1_DECL (qfcvt_r, __qfcvtieee128_r) +# else +# error bits/stdlib-ldbl.h included when no ldbl redirections are required. +# endif #endif diff --git a/stdlib/monetary.h b/stdlib/monetary.h index 40d3128b90..6a680cc832 100644 --- a/stdlib/monetary.h +++ b/stdlib/monetary.h @@ -50,7 +50,8 @@ extern ssize_t strfmon_l (char *__restrict __s, size_t __maxsize, __THROW __attribute_format_strfmon__ (4, 5); #endif -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index 4bd86ec84d..e527864cb7 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -1016,7 +1016,9 @@ extern int ttyslot (void) __THROW; #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function # include #endif -#ifdef __LDBL_COMPAT + +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif diff --git a/sysdeps/powerpc/powerpc64/le/Implies-before b/sysdeps/powerpc/powerpc64/le/Implies-before index 7c20db4e97..2139f4dae8 100644 --- a/sysdeps/powerpc/powerpc64/le/Implies-before +++ b/sysdeps/powerpc/powerpc64/le/Implies-before @@ -1,4 +1,5 @@ # On PowerPC we use the IBM extended long double format. +ieee754/ldbl-128ibm-compat ieee754/ldbl-128ibm ieee754/ldbl-opt ieee754/dbl-64 diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index 2229a1dcc0..737c7c33e4 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2247,3 +2247,96 @@ GLIBC_2.30 getdents64 F GLIBC_2.30 gettid F GLIBC_2.30 tgkill F GLIBC_2.30 twalk_r F +GLIBC_2.31 __argp_errorieee128 F +GLIBC_2.31 __argp_failureieee128 F +GLIBC_2.31 __asprintf_chkieee128 F +GLIBC_2.31 __asprintfieee128 F +GLIBC_2.31 __dprintf_chkieee128 F +GLIBC_2.31 __dprintfieee128 F +GLIBC_2.31 __errieee128 F +GLIBC_2.31 __error_at_lineieee128 F +GLIBC_2.31 __errorieee128 F +GLIBC_2.31 __errxieee128 F +GLIBC_2.31 __fprintf_chkieee128 F +GLIBC_2.31 __fprintfieee128 F +GLIBC_2.31 __fscanfieee128 F +GLIBC_2.31 __fwprintf_chkieee128 F +GLIBC_2.31 __fwprintfieee128 F +GLIBC_2.31 __fwscanfieee128 F +GLIBC_2.31 __isoc99_fscanfieee128 F +GLIBC_2.31 __isoc99_fwscanfieee128 F +GLIBC_2.31 __isoc99_scanfieee128 F +GLIBC_2.31 __isoc99_sscanfieee128 F +GLIBC_2.31 __isoc99_swscanfieee128 F +GLIBC_2.31 __isoc99_vfscanfieee128 F +GLIBC_2.31 __isoc99_vfwscanfieee128 F +GLIBC_2.31 __isoc99_vscanfieee128 F +GLIBC_2.31 __isoc99_vsscanfieee128 F +GLIBC_2.31 __isoc99_vswscanfieee128 F +GLIBC_2.31 __isoc99_vwscanfieee128 F +GLIBC_2.31 __isoc99_wscanfieee128 F +GLIBC_2.31 __obstack_printf_chkieee128 F +GLIBC_2.31 __obstack_printfieee128 F +GLIBC_2.31 __obstack_vprintf_chkieee128 F +GLIBC_2.31 __obstack_vprintfieee128 F +GLIBC_2.31 __printf_chkieee128 F +GLIBC_2.31 __printf_sizeieee128 F +GLIBC_2.31 __printfieee128 F +GLIBC_2.31 __qecvtieee128 F +GLIBC_2.31 __qecvtieee128_r F +GLIBC_2.31 __qfcvtieee128 F +GLIBC_2.31 __qfcvtieee128_r F +GLIBC_2.31 __qgcvtieee128 F +GLIBC_2.31 __scanfieee128 F +GLIBC_2.31 __snprintf_chkieee128 F +GLIBC_2.31 __snprintfieee128 F +GLIBC_2.31 __sprintf_chkieee128 F +GLIBC_2.31 __sprintfieee128 F +GLIBC_2.31 __sscanfieee128 F +GLIBC_2.31 __strfmon_lieee128 F +GLIBC_2.31 __strfmonieee128 F +GLIBC_2.31 __strfromieee128 F +GLIBC_2.31 __strtoieee128 F +GLIBC_2.31 __strtoieee128_l F +GLIBC_2.31 __swprintf_chkieee128 F +GLIBC_2.31 __swprintfieee128 F +GLIBC_2.31 __swscanfieee128 F +GLIBC_2.31 __syslog_chkieee128 F +GLIBC_2.31 __syslogieee128 F +GLIBC_2.31 __vasprintf_chkieee128 F +GLIBC_2.31 __vasprintfieee128 F +GLIBC_2.31 __vdprintf_chkieee128 F +GLIBC_2.31 __vdprintfieee128 F +GLIBC_2.31 __verrieee128 F +GLIBC_2.31 __verrxieee128 F +GLIBC_2.31 __vfprintf_chkieee128 F +GLIBC_2.31 __vfprintfieee128 F +GLIBC_2.31 __vfscanfieee128 F +GLIBC_2.31 __vfwprintf_chkieee128 F +GLIBC_2.31 __vfwprintfieee128 F +GLIBC_2.31 __vfwscanfieee128 F +GLIBC_2.31 __vprintf_chkieee128 F +GLIBC_2.31 __vprintfieee128 F +GLIBC_2.31 __vscanfieee128 F +GLIBC_2.31 __vsnprintf_chkieee128 F +GLIBC_2.31 __vsnprintfieee128 F +GLIBC_2.31 __vsprintf_chkieee128 F +GLIBC_2.31 __vsprintfieee128 F +GLIBC_2.31 __vsscanfieee128 F +GLIBC_2.31 __vswprintf_chkieee128 F +GLIBC_2.31 __vswprintfieee128 F +GLIBC_2.31 __vswscanfieee128 F +GLIBC_2.31 __vsyslog_chkieee128 F +GLIBC_2.31 __vsyslogieee128 F +GLIBC_2.31 __vwarnieee128 F +GLIBC_2.31 __vwarnxieee128 F +GLIBC_2.31 __vwprintf_chkieee128 F +GLIBC_2.31 __vwprintfieee128 F +GLIBC_2.31 __vwscanfieee128 F +GLIBC_2.31 __warnieee128 F +GLIBC_2.31 __warnxieee128 F +GLIBC_2.31 __wcstoieee128 F +GLIBC_2.31 __wcstoieee128_l F +GLIBC_2.31 __wprintf_chkieee128 F +GLIBC_2.31 __wprintfieee128 F +GLIBC_2.31 __wscanfieee128 F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist index d479a64fca..60658729d0 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist @@ -1081,6 +1081,110 @@ GLIBC_2.29 exp2 F GLIBC_2.29 log F GLIBC_2.29 log2 F GLIBC_2.29 pow F +GLIBC_2.31 __acoshieee128 F +GLIBC_2.31 __acosieee128 F +GLIBC_2.31 __asinhieee128 F +GLIBC_2.31 __asinieee128 F +GLIBC_2.31 __atan2ieee128 F +GLIBC_2.31 __atanhieee128 F +GLIBC_2.31 __atanieee128 F +GLIBC_2.31 __cabsieee128 F +GLIBC_2.31 __cacoshieee128 F +GLIBC_2.31 __cacosieee128 F +GLIBC_2.31 __canonicalizeieee128 F +GLIBC_2.31 __cargieee128 F +GLIBC_2.31 __casinhieee128 F +GLIBC_2.31 __casinieee128 F +GLIBC_2.31 __catanhieee128 F +GLIBC_2.31 __catanieee128 F +GLIBC_2.31 __cbrtieee128 F +GLIBC_2.31 __ccoshieee128 F +GLIBC_2.31 __ccosieee128 F +GLIBC_2.31 __ceilieee128 F +GLIBC_2.31 __cexpieee128 F +GLIBC_2.31 __cimagieee128 F +GLIBC_2.31 __clog10ieee128 F +GLIBC_2.31 __clogieee128 F +GLIBC_2.31 __conjieee128 F +GLIBC_2.31 __copysignieee128 F +GLIBC_2.31 __coshieee128 F +GLIBC_2.31 __cosieee128 F +GLIBC_2.31 __cpowieee128 F +GLIBC_2.31 __cprojieee128 F +GLIBC_2.31 __crealieee128 F +GLIBC_2.31 __csinhieee128 F +GLIBC_2.31 __csinieee128 F +GLIBC_2.31 __csqrtieee128 F +GLIBC_2.31 __ctanhieee128 F +GLIBC_2.31 __ctanieee128 F +GLIBC_2.31 __erfcieee128 F +GLIBC_2.31 __erfieee128 F +GLIBC_2.31 __exp10ieee128 F +GLIBC_2.31 __exp2ieee128 F +GLIBC_2.31 __expieee128 F +GLIBC_2.31 __expm1ieee128 F +GLIBC_2.31 __fabsieee128 F +GLIBC_2.31 __fdimieee128 F +GLIBC_2.31 __floorieee128 F +GLIBC_2.31 __fmaieee128 F +GLIBC_2.31 __fmaxieee128 F +GLIBC_2.31 __fmaxmagieee128 F +GLIBC_2.31 __fminieee128 F +GLIBC_2.31 __fminmagieee128 F +GLIBC_2.31 __fmodieee128 F +GLIBC_2.31 __frexpieee128 F +GLIBC_2.31 __fromfpieee128 F +GLIBC_2.31 __fromfpxieee128 F +GLIBC_2.31 __getpayloadieee128 F +GLIBC_2.31 __hypotieee128 F +GLIBC_2.31 __ilogbieee128 F +GLIBC_2.31 __j0ieee128 F +GLIBC_2.31 __j1ieee128 F +GLIBC_2.31 __jnieee128 F +GLIBC_2.31 __ldexpieee128 F +GLIBC_2.31 __lgammaieee128 F +GLIBC_2.31 __lgammaieee128_r F +GLIBC_2.31 __llogbieee128 F +GLIBC_2.31 __llrintieee128 F +GLIBC_2.31 __llroundieee128 F +GLIBC_2.31 __log10ieee128 F +GLIBC_2.31 __log1pieee128 F +GLIBC_2.31 __log2ieee128 F +GLIBC_2.31 __logbieee128 F +GLIBC_2.31 __logieee128 F +GLIBC_2.31 __lrintieee128 F +GLIBC_2.31 __lroundieee128 F +GLIBC_2.31 __modfieee128 F +GLIBC_2.31 __nanieee128 F +GLIBC_2.31 __nearbyintieee128 F +GLIBC_2.31 __nextafterieee128 F +GLIBC_2.31 __nextdownieee128 F +GLIBC_2.31 __nextupieee128 F +GLIBC_2.31 __powieee128 F +GLIBC_2.31 __remainderieee128 F +GLIBC_2.31 __remquoieee128 F +GLIBC_2.31 __rintieee128 F +GLIBC_2.31 __roundevenieee128 F +GLIBC_2.31 __roundieee128 F +GLIBC_2.31 __scalblnieee128 F +GLIBC_2.31 __scalbnieee128 F +GLIBC_2.31 __setpayloadieee128 F +GLIBC_2.31 __setpayloadsigieee128 F +GLIBC_2.31 __sincosieee128 F +GLIBC_2.31 __sinhieee128 F +GLIBC_2.31 __sinieee128 F +GLIBC_2.31 __sqrtieee128 F +GLIBC_2.31 __tanhieee128 F +GLIBC_2.31 __tanieee128 F +GLIBC_2.31 __tgammaieee128 F +GLIBC_2.31 __totalorderieee128 F +GLIBC_2.31 __totalordermagieee128 F +GLIBC_2.31 __truncieee128 F +GLIBC_2.31 __ufromfpieee128 F +GLIBC_2.31 __ufromfpxieee128 F +GLIBC_2.31 __y0ieee128 F +GLIBC_2.31 __y1ieee128 F +GLIBC_2.31 __ynieee128 F GLIBC_2.31 totalorder F GLIBC_2.31 totalorderf F GLIBC_2.31 totalorderf128 F diff --git a/wcsmbs/bits/wchar-ldbl.h b/wcsmbs/bits/wchar-ldbl.h index ae8f09800f..ed8b746cb7 100644 --- a/wcsmbs/bits/wchar-ldbl.h +++ b/wcsmbs/bits/wchar-ldbl.h @@ -28,9 +28,17 @@ __LDBL_REDIR_DECL (vfwprintf); __LDBL_REDIR_DECL (vwprintf); __LDBL_REDIR_DECL (vswprintf); # if !__GLIBC_USE (DEPRECATED_SCANF) +# if defined __LDBL_COMPAT __LDBL_REDIR1_DECL (fwscanf, __nldbl___isoc99_fwscanf) __LDBL_REDIR1_DECL (wscanf, __nldbl___isoc99_wscanf) __LDBL_REDIR1_DECL (swscanf, __nldbl___isoc99_swscanf) +# elif __LONG_DOUBLE_USES_FLOAT128 == 1 +__LDBL_REDIR1_DECL (fwscanf, __isoc99_fwscanfieee128) +__LDBL_REDIR1_DECL (wscanf, __isoc99_wscanfieee128) +__LDBL_REDIR1_DECL (swscanf, __isoc99_swscanfieee128) +# else +# error bits/stdlib-ldbl.h included when no ldbl redirections are required. +# endif # else __LDBL_REDIR_DECL (fwscanf); __LDBL_REDIR_DECL (wscanf); @@ -39,11 +47,23 @@ __LDBL_REDIR_DECL (swscanf); #endif #ifdef __USE_ISOC99 +# ifdef __LDBL_COMPAT __LDBL_REDIR1_DECL (wcstold, wcstod); +# else +__LDBL_REDIR1_DECL (wcstold, __wcstoieee128) +# endif # if !__GLIBC_USE (DEPRECATED_SCANF) +# if defined __LDBL_COMPAT __LDBL_REDIR1_DECL (vfwscanf, __nldbl___isoc99_vfwscanf) __LDBL_REDIR1_DECL (vwscanf, __nldbl___isoc99_vwscanf) __LDBL_REDIR1_DECL (vswscanf, __nldbl___isoc99_vswscanf) +# elif __LONG_DOUBLE_USES_FLOAT128 == 1 +__LDBL_REDIR1_DECL (vfwscanf, __isoc99_vfwscanfieee128) +__LDBL_REDIR1_DECL (vwscanf, __isoc99_vwscanfieee128) +__LDBL_REDIR1_DECL (vswscanf, __isoc99_vswscanfieee128) +# else +# error bits/stdlib-ldbl.h included when no ldbl redirections are required. +# endif # else __LDBL_REDIR_DECL (vfwscanf); __LDBL_REDIR_DECL (vwscanf); @@ -52,16 +72,20 @@ __LDBL_REDIR_DECL (vswscanf); #endif #ifdef __USE_GNU +# ifdef __LDBL_COMPAT __LDBL_REDIR1_DECL (wcstold_l, wcstod_l); +# else +__LDBL_REDIR1_DECL (wcstold_l, __wcstoieee128_l) +# endif #endif #if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function -__LDBL_REDIR_DECL (__swprintf_chk) -__LDBL_REDIR_DECL (__vswprintf_chk) +__LDBL_REDIR2_DECL (swprintf_chk) +__LDBL_REDIR2_DECL (vswprintf_chk) # if __USE_FORTIFY_LEVEL > 1 -__LDBL_REDIR_DECL (__fwprintf_chk) -__LDBL_REDIR_DECL (__wprintf_chk) -__LDBL_REDIR_DECL (__vfwprintf_chk) -__LDBL_REDIR_DECL (__vwprintf_chk) +__LDBL_REDIR2_DECL (fwprintf_chk) +__LDBL_REDIR2_DECL (wprintf_chk) +__LDBL_REDIR2_DECL (vfwprintf_chk) +__LDBL_REDIR2_DECL (vwprintf_chk) # endif #endif diff --git a/wcsmbs/wchar.h b/wcsmbs/wchar.h index 4b731ebb51..815bb812a3 100644 --- a/wcsmbs/wchar.h +++ b/wcsmbs/wchar.h @@ -633,9 +633,11 @@ extern int swscanf (const wchar_t *__restrict __s, __THROW /* __attribute__ ((__format__ (__wscanf__, 2, 3))) */; /* For historical reasons, the C99-compliant versions of the scanf - functions are at alternative names. When __LDBL_COMPAT is in - effect, this is handled in bits/wchar-ldbl.h. */ -#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT + functions are at alternative names. When __LDBL_COMPAT or + __LONG_DOUBLE_USES_FLOAT128 are in effect, this is handled in + bits/wchar-ldbl.h. */ +#if !__GLIBC_USE (DEPRECATED_SCANF) && !defined __LDBL_COMPAT \ + && __LONG_DOUBLE_USES_FLOAT128 == 0 # ifdef __REDIRECT extern int __REDIRECT (fwscanf, (__FILE *__restrict __stream, const wchar_t *__restrict __format, ...), @@ -687,7 +689,8 @@ extern int vswscanf (const wchar_t *__restrict __s, # if !defined __USE_GNU \ && (!defined __LDBL_COMPAT || !defined __REDIRECT) \ - && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) + && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K) \ + && __LONG_DOUBLE_USES_FLOAT128 == 0 # ifdef __REDIRECT extern int __REDIRECT (vfwscanf, (__FILE *__restrict __s, const wchar_t *__restrict __format, @@ -848,7 +851,8 @@ extern size_t wcsftime_l (wchar_t *__restrict __s, size_t __maxsize, # include #endif -#ifdef __LDBL_COMPAT +#include +#if defined __LDBL_COMPAT || __LONG_DOUBLE_USES_FLOAT128 == 1 # include #endif