From patchwork Thu Nov 15 21:44:45 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: 998548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-97286-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=inconstante.eti.br Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ewXBAo9e"; 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 42ww1p6cP3z9s7T for ; Fri, 16 Nov 2018 08:47:10 +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; q=dns; s=default; b=lJWGX 7yhewl9sDH+gDE0Wo0PqiWHh8TM0zO9lpjFzt1NyrhOHZl05f8EJ0DuPEpNeLJNQ WD4AYO43zXlHGeB0r8q4OQTDFgLZWYCiD2AFOiHAB0pkenEr19GpNKEajArMppGz OHzciyZkFMdbViC3irgvhq3ikze4DRF/eOmZDA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=nJo2Ld6tQXW QsePsBvt+n+asGCc=; b=ewXBAo9ebPYifYKkHrmNBTWJG8YAWGCM2RmueLoriW+ 0foQg6+0AYZp/Jxhum1DBweFHcifRCSrNIkA58njzNPia2dNhI5MhxEg16YYmwKr JKIaZ/bOnTj07M3L/6X5W4YaWB43Ijogi2+aRURznMevgH8VDQsIOWtMvQwaPk3s = Received: (qmail 122698 invoked by alias); 15 Nov 2018 21:46:20 -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 122249 invoked by uid 89); 15 Nov 2018 21:45:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.2 spammy=Temporarily, environmental X-HELO: mo20.mail-out.ovh.net From: "Gabriel F. T. Gomes" To: Subject: [PATCH v3 3/7] Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl. Date: Thu, 15 Nov 2018 19:44:45 -0200 Message-ID: <20181115214449.19262-4-gabriel@inconstante.eti.br> In-Reply-To: <20181115214449.19262-1-gabriel@inconstante.eti.br> References: <20181115214449.19262-1-gabriel@inconstante.eti.br> MIME-Version: 1.0 X-Ovh-Tracer-Id: 16783226964859670211 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtkedrleehgddugeejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenuc From: Zack Weinberg Changes since v2 - None, but dependent on previous patch in the set, thus resending. Changed since v1: - In __nldbl___isoc99_vwscanf, called __vfwscanf_internal directly (missing (accidentally?) from the previous version). - Broke long lines. - Changed name of variable (from rv to ret), since the rationale for making these changes to variables names is consistency. - Added signed-off-by statements. -- 8< -- Change the callers of __vfscanf_internal and __vfwscanf_internal that want to treat 'long double' as another name for 'double' (all of which happen to be in sysdeps/ieee754/ldbl-opt/nldbl-compat.c) to communicate this via the new flags argument, instead of the per-thread variable __no_long_double and its __ldbl_is_dbl wrapper macro. Tested for powerpc and powerpc64le. 2018-10-16 Zack Weinberg Gabriel F. T. Gomes * stdio-common/vfscanf-internal.c: Don't look at __ldbl_is_dbl. * sysdeps/ieee754/ldbl-opt/ndlbl-compat.c: Include libio/strfile.h instead of libioP.h. (__nldbl_IO_vfscanf, __ndlbl___vfscanf, __nldbl_sscanf) (__nldbl___vsscanf, __nldbl_vscanf, __nldbl_fscanf) (__nldbl_scanf, __nldbl_vfwscanf, __nldbl_swscanf) (__nldbl_vswscanf, __nldbl_vwscanf, __nldbl_fwscanf) (__nldbl_wscanf): Call __vfscanf_internal / __vfwscanf_internal directly, passing SCANF_LDBL_IS_DBL. Set up a strfile if necessary. Do not set __no_long_double. Normalize variable names. (__nldbl___isoc99_vfscanf, __nldbl___isoc99_sscanf) (__nldbl___isoc99_vsscanf, __nldbl___isoc99_vscanf) (__nldbl___isoc99_fscanf, __nldbl___isoc99_scanf) (__nldbl___isoc99_vfwscanf, __nldbl___isoc99_swscanf) (__nldbl___isoc99_vswscanf, __nldbl___isoc99_vwscanf) (__nldbl___isoc99_fwscanf, __nldbl___isoc99_wscanf): Call __vfscanf_internal / __vfwscanf_internal directly, passing SCANF_LDBL_IS_DBL | SCANF_ISOC99_A. Set up a strfile if necessary. Do not set __no_long_double. Normalize variable names. --- stdio-common/vfscanf-internal.c | 4 - sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 251 +++++++++++++++----------------- 2 files changed, 121 insertions(+), 134 deletions(-) diff --git a/stdio-common/vfscanf-internal.c b/stdio-common/vfscanf-internal.c index f0072d8682..818b558140 100644 --- a/stdio-common/vfscanf-internal.c +++ b/stdio-common/vfscanf-internal.c @@ -332,10 +332,6 @@ __vfscanf_internal (FILE *s, const char *format, va_list argptr, struct char_buffer charbuf; scratch_buffer_init (&charbuf.scratch); - /* Temporarily honor the environmental mode bits. */ - if (__ldbl_is_dbl) - mode_flags |= SCANF_LDBL_IS_DBL; - #ifdef __va_copy __va_copy (arg, argptr); #else diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index 91ea27a423..468e23dec4 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -335,13 +335,10 @@ int attribute_compat_text_section __nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp) { - int res; - set_no_long_double (); - res = __vfscanf_internal (s, fmt, ap, 0); - clear_no_long_double (); + int ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL); if (__glibc_unlikely (errp != 0)) - *errp = (res == -1); - return res; + *errp = (ret == -1); + return ret; } #endif @@ -349,11 +346,7 @@ int attribute_compat_text_section __nldbl___vfscanf (FILE *s, const char *fmt, va_list ap) { - int res; - set_no_long_double (); - res = __vfscanf_internal (s, fmt, ap, 0); - clear_no_long_double (); - return res; + return __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL); } weak_alias (__nldbl___vfscanf, __nldbl_vfscanf) libc_hidden_def (__nldbl_vfscanf) @@ -362,26 +355,26 @@ int attribute_compat_text_section __nldbl_sscanf (const char *s, const char *fmt, ...) { - va_list arg; - int done; + _IO_strfile sf; + FILE *f = _IO_strfile_read (&sf, s); + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl_vsscanf (s, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL); + va_end (ap); - return done; + return ret; } strong_alias (__nldbl_sscanf, __nldbl__IO_sscanf) int attribute_compat_text_section -__nldbl___vsscanf (const char *string, const char *fmt, va_list ap) +__nldbl___vsscanf (const char *s, const char *fmt, va_list ap) { - int res; - __no_long_double = 1; - res = _IO_vsscanf (string, fmt, ap); - __no_long_double = 0; - return res; + _IO_strfile sf; + FILE *f = _IO_strfile_read (&sf, s); + return __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL); } weak_alias (__nldbl___vsscanf, __nldbl_vsscanf) libc_hidden_def (__nldbl_vsscanf) @@ -390,46 +383,42 @@ int attribute_compat_text_section weak_function __nldbl_vscanf (const char *fmt, va_list ap) { - return __nldbl_vfscanf (stdin, fmt, ap); + return __vfscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL); } int attribute_compat_text_section __nldbl_fscanf (FILE *stream, const char *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl_vfscanf (stream, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfscanf_internal (stream, fmt, ap, SCANF_LDBL_IS_DBL); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section __nldbl_scanf (const char *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl_vfscanf (stdin, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section __nldbl_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap) { - int res; - set_no_long_double (); - res = __vfwscanf_internal (s, fmt, ap, 0); - clear_no_long_double (); - return res; + return __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL); } libc_hidden_def (__nldbl_vfwscanf) @@ -437,25 +426,28 @@ int attribute_compat_text_section __nldbl_swscanf (const wchar_t *s, const wchar_t *fmt, ...) { - va_list arg; - int done; + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *f = _IO_strfile_readw (&sf, &wd, s); + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl_vswscanf (s, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section -__nldbl_vswscanf (const wchar_t *string, const wchar_t *fmt, va_list ap) +__nldbl_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap) { - int res; - __no_long_double = 1; - res = vswscanf (string, fmt, ap); - __no_long_double = 0; - return res; + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *f = _IO_strfile_readw (&sf, &wd, s); + + return __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL); } libc_hidden_def (__nldbl_vswscanf) @@ -463,35 +455,35 @@ int attribute_compat_text_section weak_function __nldbl_vwscanf (const wchar_t *fmt, va_list ap) { - return __nldbl_vfwscanf (stdin, fmt, ap); + return __vfwscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL); } int attribute_compat_text_section __nldbl_fwscanf (FILE *stream, const wchar_t *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl_vfwscanf (stream, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfwscanf_internal (stream, fmt, ap, SCANF_LDBL_IS_DBL); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section __nldbl_wscanf (const wchar_t *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl_vfwscanf (stdin, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfwscanf_internal (stdin, fmt, ap, SCANF_LDBL_IS_DBL); + va_end (ap); - return done; + return ret; } int @@ -866,11 +858,7 @@ int attribute_compat_text_section __nldbl___isoc99_vfscanf (FILE *s, const char *fmt, va_list ap) { - int res; - set_no_long_double (); - res = __isoc99_vfscanf (s, fmt, ap); - clear_no_long_double (); - return res; + return __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); } libc_hidden_def (__nldbl___isoc99_vfscanf) @@ -878,25 +866,26 @@ int attribute_compat_text_section __nldbl___isoc99_sscanf (const char *s, const char *fmt, ...) { - va_list arg; - int done; + _IO_strfile sf; + FILE *f = _IO_strfile_read (&sf, s); + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl___isoc99_vsscanf (s, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section -__nldbl___isoc99_vsscanf (const char *string, const char *fmt, va_list ap) +__nldbl___isoc99_vsscanf (const char *s, const char *fmt, va_list ap) { - int res; - __no_long_double = 1; - res = __isoc99_vsscanf (string, fmt, ap); - __no_long_double = 0; - return res; + _IO_strfile sf; + FILE *f = _IO_strfile_read (&sf, s); + + return __vfscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); } libc_hidden_def (__nldbl___isoc99_vsscanf) @@ -904,46 +893,44 @@ int attribute_compat_text_section __nldbl___isoc99_vscanf (const char *fmt, va_list ap) { - return __nldbl___isoc99_vfscanf (stdin, fmt, ap); + return __vfscanf_internal (stdin, fmt, ap, + SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); } int attribute_compat_text_section -__nldbl___isoc99_fscanf (FILE *stream, const char *fmt, ...) +__nldbl___isoc99_fscanf (FILE *s, const char *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl___isoc99_vfscanf (stream, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section __nldbl___isoc99_scanf (const char *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl___isoc99_vfscanf (stdin, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfscanf_internal (stdin, fmt, ap, + SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section __nldbl___isoc99_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap) { - int res; - set_no_long_double (); - res = __isoc99_vfwscanf (s, fmt, ap); - clear_no_long_double (); - return res; + return __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); } libc_hidden_def (__nldbl___isoc99_vfwscanf) @@ -951,26 +938,28 @@ int attribute_compat_text_section __nldbl___isoc99_swscanf (const wchar_t *s, const wchar_t *fmt, ...) { - va_list arg; - int done; + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *f = _IO_strfile_readw (&sf, &wd, s); + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl___isoc99_vswscanf (s, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section -__nldbl___isoc99_vswscanf (const wchar_t *string, const wchar_t *fmt, - va_list ap) +__nldbl___isoc99_vswscanf (const wchar_t *s, const wchar_t *fmt, va_list ap) { - int res; - __no_long_double = 1; - res = __isoc99_vswscanf (string, fmt, ap); - __no_long_double = 0; - return res; + _IO_strfile sf; + struct _IO_wide_data wd; + FILE *f = _IO_strfile_readw (&sf, &wd, s); + + return __vfwscanf_internal (f, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); } libc_hidden_def (__nldbl___isoc99_vswscanf) @@ -978,35 +967,37 @@ int attribute_compat_text_section __nldbl___isoc99_vwscanf (const wchar_t *fmt, va_list ap) { - return __nldbl___isoc99_vfwscanf (stdin, fmt, ap); + return __vfwscanf_internal (stdin, fmt, ap, + SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); } int attribute_compat_text_section -__nldbl___isoc99_fwscanf (FILE *stream, const wchar_t *fmt, ...) +__nldbl___isoc99_fwscanf (FILE *s, const wchar_t *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl___isoc99_vfwscanf (stream, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfwscanf_internal (s, fmt, ap, SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); + va_end (ap); - return done; + return ret; } int attribute_compat_text_section __nldbl___isoc99_wscanf (const wchar_t *fmt, ...) { - va_list arg; - int done; + va_list ap; + int ret; - va_start (arg, fmt); - done = __nldbl___isoc99_vfwscanf (stdin, fmt, arg); - va_end (arg); + va_start (ap, fmt); + ret = __vfwscanf_internal (stdin, fmt, ap, + SCANF_LDBL_IS_DBL | SCANF_ISOC99_A); + va_end (ap); - return done; + return ret; } #if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)