From patchwork Thu Jun 21 02:10:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel F. T. Gomes" X-Patchwork-Id: 27968 Received: (qmail 130621 invoked by alias); 21 Jun 2018 02:11:26 -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 130445 invoked by uid 89); 21 Jun 2018 02:11:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_SHORT, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy= X-HELO: mo19.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH 10/14] ldbl-128ibm-compat: Add wide character scanning functions Date: Wed, 20 Jun 2018 23:10:19 -0300 Message-ID: <20180621021023.17036-11-gabriel@inconstante.eti.br> In-Reply-To: <20180621021023.17036-1-gabriel@inconstante.eti.br> References: <20180621021023.17036-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 X-ClientProxiedBy: EX3.emp.local (172.16.2.3) To EX4.emp.local (172.16.2.4) X-Ovh-Tracer-Id: 668503071037247171 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtiedrtdefgdehjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecu Similarly to what was done for regular character scanning functions, this patch uses the new mode mask, SCANF_LDBL_USES_FLOAT128, in the 'mode' argument of the wide characters scanning function, __vfwscanf_internal (which is also extended to support scanning floating-point values with IEEE binary128, by redirecting calls to __wcstold_internal to __wcstof128_internal). Tested for powerpc64le. * sysdeps/ieee754/ldbl-128ibm-compat/Makefile (routines): Add ieee128-fwscanf, ieee128-swscanf, ieee128-wscanf, ieee128-vfwscanf, ieee128-vswscanf, and ieee128-vwscanf (CFLAGS-vfwscanf-internal.c): Add -mfloat128 to the compiler command used to build vfwscanf-internal.c. This is needed to extend __vfwscanf_internal with the support to redirect the call to __wcstold_internal to __wcstof128_internal. (tests-internal): Add test-wscanf-ieee128 and test-wscanf-ibm128. (CFLAGS-test-wscanf-ieee128.c): New variable. (CFLAGS-test-wscanf-ibm128.c): Likewise. ($(objpfx)test-wscanf-ieee128): Link the loader after libgcc. [run-built-tests] (tests-special): Add $(objpfx)test-wscanf-ieee128.out and $(objpfx)test-wscanf-ibm128.out. ($(objpfx)test-wscanf-ieee128.out): New build and run rules. ($(objpfx)test-wscanf-ibm128.out): Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/Versions: Add __fwscanfieee128, __swscanfieee128, __wscanfieee128, __vfwscanfieee128, __vswscanfieee128, and __vwscanfieee128. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c: New file. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c: Likewise. * sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c: Likewise. --- sysdeps/ieee754/ldbl-128ibm-compat/Makefile | 30 ++++++++++++++++ sysdeps/ieee754/ldbl-128ibm-compat/Versions | 8 +++++ .../ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c | 35 +++++++++++++++++++ .../ieee754/ldbl-128ibm-compat/ieee128-swscanf.c | 40 ++++++++++++++++++++++ .../ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c | 27 +++++++++++++++ .../ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c | 31 +++++++++++++++++ .../ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c | 27 +++++++++++++++ .../ieee754/ldbl-128ibm-compat/ieee128-wscanf.c | 35 +++++++++++++++++++ .../ldbl-128ibm-compat/test-wscanf-ibm128.c | 1 + .../ldbl-128ibm-compat/test-wscanf-ieee128.c | 1 + .../ldbl-128ibm-compat/test-wscanf-ldbl-compat.c | 10 ++++++ 11 files changed, 245 insertions(+) create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-swscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vfwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/ieee128-wscanf.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ibm128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ieee128.c create mode 100644 sysdeps/ieee754/ldbl-128ibm-compat/test-wscanf-ldbl-compat.c diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile index 10fd6bbffc..5cb6fd4f73 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Makefile +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Makefile @@ -53,6 +53,14 @@ routines += ieee128-vfscanf routines += ieee128-vscanf routines += ieee128-vsscanf +routines += ieee128-fwscanf +routines += ieee128-swscanf +routines += ieee128-wscanf + +routines += ieee128-vfwscanf +routines += ieee128-vswscanf +routines += ieee128-vwscanf + # Printing long double values with IEEE binary128 format reuses part # of the internal float128 implementation (__printf_fp, __printf_fphex, # and __float128 variables and union members). Likewise, reading these @@ -61,6 +69,7 @@ routines += ieee128-vsscanf CFLAGS-vfprintf-internal.c += -mfloat128 CFLAGS-vfwprintf-internal.c += -mfloat128 CFLAGS-vfscanf-internal.c += -mfloat128 +CFLAGS-vfwscanf-internal.c += -mfloat128 # Basic tests for the implementation of long double with IEEE binary128 # format and for the related redirections in installed headers. @@ -86,6 +95,12 @@ CFLAGS-test-scanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi $(objpfx)test-scanf-ieee128: gnulib-tests += $(f128-loader-link) +tests-internal += test-wscanf-ieee128 test-wscanf-ibm128 +CFLAGS-test-wscanf-ieee128.c += -mfloat128 -mabi=ieeelongdouble -Wno-psabi +CFLAGS-test-wscanf-ibm128.c += -mabi=ibmlongdouble -Wno-psabi + +$(objpfx)test-wscanf-ieee128: gnulib-tests += $(f128-loader-link) + ifeq ($(run-built-tests),yes) tests-special += $(objpfx)test-printf-ieee128.out tests-special += $(objpfx)test-printf-ibm128.out @@ -101,6 +116,9 @@ tests-special += $(objpfx)test-wprintf-chk-ibm128.out tests-special += $(objpfx)test-scanf-ieee128.out tests-special += $(objpfx)test-scanf-ibm128.out + +tests-special += $(objpfx)test-wscanf-ieee128.out +tests-special += $(objpfx)test-wscanf-ibm128.out endif $(objpfx)test-printf-ieee128.out: \ @@ -162,4 +180,16 @@ $(objpfx)test-scanf-ibm128.out: \ $(objpfx)test-scanf-ibm128 $(SHELL) $^ '$(test-program-prefix)' $@; \ $(evaluate-test) + +$(objpfx)test-wscanf-ieee128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \ + $(objpfx)test-wscanf-ieee128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) + +$(objpfx)test-wscanf-ibm128.out: \ + ../sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat.sh \ + $(objpfx)test-wscanf-ibm128 + $(SHELL) $^ '$(test-program-prefix)' $@; \ + $(evaluate-test) endif diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/Versions b/sysdeps/ieee754/ldbl-128ibm-compat/Versions index 26cb9aa692..e0e7e74160 100644 --- a/sysdeps/ieee754/ldbl-128ibm-compat/Versions +++ b/sysdeps/ieee754/ldbl-128ibm-compat/Versions @@ -164,5 +164,13 @@ libc { __vfscanfieee128; __vscanfieee128; __vsscanfieee128; + + __fwscanfieee128; + __swscanfieee128; + __wscanfieee128; + + __vfwscanfieee128; + __vswscanfieee128; + __vwscanfieee128; } } diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c new file mode 100644 index 0000000000..b4b10cf9f8 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-fwscanf.c @@ -0,0 +1,35 @@ +/* Wrapper for fwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#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..a70e94ba98 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vswscanf.c @@ -0,0 +1,31 @@ +/* Wrapper for vswscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +extern int +___ieee128_vswscanf (wchar_t *string, const wchar_t *format, va_list ap) +{ + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *fp = _IO_strfile_readw (&sf, &wd, string); + return __vfwscanf_internal (fp, format, ap, SCANF_LDBL_USES_FLOAT128); +} +strong_alias (___ieee128_vswscanf, __vswscanfieee128) diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c new file mode 100644 index 0000000000..0944794ac5 --- /dev/null +++ b/sysdeps/ieee754/ldbl-128ibm-compat/ieee128-vwscanf.c @@ -0,0 +1,27 @@ +/* Wrapper for vwscanf. IEEE128 version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#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