From patchwork Fri May 24 23:39:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 1939189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=CAKbmJS5; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VmM3T1R68z20QM for ; Sat, 25 May 2024 09:40:21 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5BC78385E45D for ; Fri, 24 May 2024 23:40:19 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by sourceware.org (Postfix) with ESMTPS id 2926B385840B for ; Fri, 24 May 2024 23:39:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2926B385840B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2926B385840B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::431 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716593997; cv=none; b=Jyto2QlL3PiGPf7PrUBFkDmpuvanLwUAoXuLJZOl9iSLkvw9oHPkfbp7a/y3QxqnEKtWkiDqluSBF3Cl+2w1VsWoXzXpEpauwqbUBIKsM/Fxc1ozq4EHVBvEsGS71h7RX8q32ess6gAu7xc+RfDrZQC2D5uWMoo3wwQdQKUBhfs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716593997; c=relaxed/simple; bh=gczASzNsIiWQT8xHtt5qvwim7Ocb4aDzQDea2ZwNvFE=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=sERW3rIlaHL0wXD1sQ37DuM1FQ/7KttbXvZhyZZMNBWjwjziDB9eWuYWA4iaVX+vX/Wss86fJb0mepMjcvkSlqSlKTCpxLOq/VH+BJ716I1fTqdC8UaFXRlTw56z561k4AG1vQBTD/E89vgaeM3WUA9fpsdoVtOCoswoh0I6wgY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6fcbd812b33so249676b3a.3 for ; Fri, 24 May 2024 16:39:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716593993; x=1717198793; darn=sourceware.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WZxgCYdrsu8Y8NMqF6d/4o9m8UFKmoZELqTpClSKESc=; b=CAKbmJS59SuM4E6E/sRB6szIRNUlvZwUBTy1hNIyURPxLPdv3DmPckEtYl8yjUz7dy RQV0xFNdHYA3bSm6F2NFtAD/WW2FIHcWMr8MIqcE6g4HfX7Pqd4gfOYZWvavfgn789se ndYYFdnVgExebTsYJI39CwPM6Y2r6Apl3+gJxCUdYmbo2Hhm4u7jZErDNaij30mjFsRH ePwBaU7nCeb0l/pgbo3/iv6IKtKD6mJqL/eEzTXWRELbs30m9SSPzFAtqRNmFb1iS+5h HAY/iSY2yDOkaIh3RoEHH4H1H8oDaE1ZZ8Ww2T//cgf93Eys4VOPDXGWt7yL30Yr8Q9B EeWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716593993; x=1717198793; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=WZxgCYdrsu8Y8NMqF6d/4o9m8UFKmoZELqTpClSKESc=; b=WqPBGoNLp/2eFepH2fwJZamaivIL8RgLKejmiNryu7SnXj3b3bxOZ8P7bz3UTmrHKi JPgANdnYiBClopiRsTumpHx8Ry/7rMN0Eg334nYLxruLf1rJrb+g/1/8/5R6+xotedKv CP3mH4s8ZsvP9f9isTCOTOyPZJ9lZ8am4vSQ7psLIEfqTpZBSSNaY7m91YgUdBsW9VGj RxyczWOw/K/i48OBGPNpNviOCTkD+yfxP4xrlwQ2BrdPO1fTi/a8DsU46kyqvpnKBiy2 nGLotu11OwoUaajcRoenWFaRCmxdQPaTav9QHNCSOXcmjg9Zm3C7tfjLP72Cgv+QvfHr hd+Q== X-Gm-Message-State: AOJu0YzhmkJbeCgXua2+A0Mz+3VtEvV4XDTb7obvdPHN5FkKMFRe30Hy DdCxTdQaNf18JXFNIS3mcFbdOWUICas39VLj1Wl/BX+dCoZsiI6W6HWkpw== X-Google-Smtp-Source: AGHT+IFOe17QbayTcsL/hPTdun3OIc7V5WGjN5COTuineesi90lC41xhPI6iv5WPcvRVhmrPvbjcYA== X-Received: by 2002:a05:6a20:5506:b0:1ad:999b:de47 with SMTP id adf61e73a8af0-1b212e5b906mr3303315637.51.1716593992977; Fri, 24 May 2024 16:39:52 -0700 (PDT) Received: from gnu-cfl-3.localdomain ([172.59.129.178]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f44c99428fsm19155455ad.206.2024.05.24.16.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 May 2024 16:39:52 -0700 (PDT) Received: from gnu-cfl-3.. (localhost [IPv6:::1]) by gnu-cfl-3.localdomain (Postfix) with ESMTP id 0AAC47407BD; Fri, 24 May 2024 16:39:51 -0700 (PDT) From: "H.J. Lu" To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH v3] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] Date: Fri, 24 May 2024 16:39:49 -0700 Message-ID: <20240524233950.1400154-1-hjl.tools@gmail.com> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 X-Spam-Status: No, score=-3021.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Changes in v3: 1. Don't change stdio-common/test-fscanf.c. 2. Don't include stdio-common/test-fscanf.c. 3. Move test input files to stdio-common. Changes in v2: 1. No need to include in nldbl-compat.c. 2. Don't protect the __nldbl__IO_vfscanf compat symbol with #if LONG_DOUBLE_COMPAT(libc, GLIBC_2_0) --- Fix BZ #31776 by 1. Making __nldbl__IO_vfscanf a compat symbol. 2. Remove _IO_vfscanf from libnldbl_nonshared.a. Since _IO_vfscanf is a compat symbol, there is no point to provide it in libnldbl_nonshared.a. 3. Change libnldbl_nonshared.a to call __nldbl_vfscanf, instead of __nldbl__IO_vfscanf. Add fscanf/scanf/vfscanf/vscanf tests of long double as double without including . NB: Input files for fscanf tests must be under stdio-common. Otherwise, Rules won't pick them up. Signed-off-by: H.J. Lu --- .../test-nldbl-fscanf-redirect-static.input | 4 + stdio-common/test-nldbl-fscanf-redirect.input | 4 + sysdeps/ieee754/ldbl-opt/Makefile | 12 ++- sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 4 + sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c | 2 +- sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c | 13 --- sysdeps/ieee754/ldbl-opt/nldbl-scanf.c | 2 +- sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c | 2 +- sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c | 2 +- .../test-nldbl-fscanf-redirect-static.c | 1 + .../ldbl-opt/test-nldbl-fscanf-redirect.c | 98 +++++++++++++++++++ 11 files changed, 126 insertions(+), 18 deletions(-) create mode 100644 stdio-common/test-nldbl-fscanf-redirect-static.input create mode 100644 stdio-common/test-nldbl-fscanf-redirect.input delete mode 100644 sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.c create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c diff --git a/stdio-common/test-nldbl-fscanf-redirect-static.input b/stdio-common/test-nldbl-fscanf-redirect-static.input new file mode 100644 index 0000000000..20859d314a --- /dev/null +++ b/stdio-common/test-nldbl-fscanf-redirect-static.input @@ -0,0 +1,4 @@ +25 24.5 thompson +25 24.5 thompson +25 24.5 thompson +25 24.5 thompson diff --git a/stdio-common/test-nldbl-fscanf-redirect.input b/stdio-common/test-nldbl-fscanf-redirect.input new file mode 100644 index 0000000000..20859d314a --- /dev/null +++ b/stdio-common/test-nldbl-fscanf-redirect.input @@ -0,0 +1,4 @@ +25 24.5 thompson +25 24.5 thompson +25 24.5 thompson +25 24.5 thompson diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile index d1eda5d022..81cb5b3a53 100644 --- a/sysdeps/ieee754/ldbl-opt/Makefile +++ b/sysdeps/ieee754/ldbl-opt/Makefile @@ -101,7 +101,6 @@ libnldbl-calls = \ getpayload \ hypot \ ilogb \ - iovfscanf \ isinf \ isnan \ isoc23_fscanf \ @@ -428,11 +427,16 @@ endif ifeq ($(subdir), stdio-common) tests += \ + test-nldbl-fscanf-redirect \ + test-nldbl-fscanf-redirect-static \ tst-nldbl-scanf-binary-c11 \ tst-nldbl-scanf-binary-c23 \ tst-nldbl-scanf-binary-gnu11 \ tst-nldbl-scanf-binary-gnu89 \ # tests +tests-static += \ + test-nldbl-fscanf-redirect-static \ +# tests-static # Some versions of GCC supported for building glibc do not support -std=c23 # (added in GCC 14), or the older name -std=c2x (added in GCC 9), so @@ -446,6 +450,12 @@ CFLAGS-tst-nldbl-scanf-binary-gnu11.c += -mlong-double-64 -std=gnu11 \ -DOBJPFX=\"$(objpfx)\" CFLAGS-tst-nldbl-scanf-binary-gnu89.c += -mlong-double-64 -std=gnu89 \ -DOBJPFX=\"$(objpfx)\" +CFLAGS-test-nldbl-fscanf-redirect.c += -mlong-double-64 +CFLAGS-test-nldbl-fscanf-redirect-static.c += -mlong-double-64 +$(objpfx)test-nldbl-fscanf-redirect: \ + $(common-objpfx)math/libnldbl_nonshared.a +$(objpfx)test-nldbl-fscanf-redirect-static: \ + $(common-objpfx)math/libnldbl_nonshared.a endif diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index f0bfb1e8a1..b05e47f185 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -1336,3 +1336,7 @@ compat_symbol (libc, __nldbl___fprintf_chk, __fprintf_chk, GLIBC_2_3_4); compat_symbol (libc, __nldbl___vprintf_chk, __vprintf_chk, GLIBC_2_3_4); compat_symbol (libc, __nldbl___vfprintf_chk, __vfprintf_chk, GLIBC_2_3_4); #endif +#if SHLIB_COMPAT (libc, LONG_DOUBLE_COMPAT_VERSION, GLIBC_2_29) +compat_symbol (libc, __nldbl__IO_vfscanf, __nldbl__IO_vfscanf, + LONG_DOUBLE_COMPAT_VERSION); +#endif diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c b/sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c index 00507187f3..8f762944b9 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c @@ -13,7 +13,7 @@ fscanf (FILE *stream, const char *fmt, ...) int done; va_start (arg, fmt); - done = __nldbl__IO_vfscanf (stream, fmt, arg, NULL); + done = __nldbl_vfscanf (stream, fmt, arg); va_end (arg); return done; diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c b/sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c deleted file mode 100644 index 6ed9b48624..0000000000 --- a/sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c +++ /dev/null @@ -1,13 +0,0 @@ -/* This file defines one of the deprecated scanf variants. */ -#include -#undef __GLIBC_USE_DEPRECATED_SCANF -#define __GLIBC_USE_DEPRECATED_SCANF 1 - -#include "nldbl-compat.h" - -int -attribute_hidden -_IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp) -{ - return __nldbl__IO_vfscanf (s, fmt, ap, errp); -} diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-scanf.c b/sysdeps/ieee754/ldbl-opt/nldbl-scanf.c index c10da284f2..c7dd1b7bd0 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-scanf.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-scanf.c @@ -13,7 +13,7 @@ scanf (const char *fmt, ...) int done; va_start (arg, fmt); - done = __nldbl__IO_vfscanf (stdin, fmt, arg, NULL); + done = __nldbl_vfscanf (stdin, fmt, arg); va_end (arg); return done; diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c b/sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c index 6f5ebc3045..076a06fe4f 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c @@ -9,7 +9,7 @@ int attribute_hidden __vfscanf (FILE *s, const char *fmt, va_list ap) { - return __nldbl__IO_vfscanf (s, fmt, ap, NULL); + return __nldbl_vfscanf (s, fmt, ap); } extern __typeof (__vfscanf) vfscanf attribute_hidden; weak_alias (__vfscanf, vfscanf) diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c b/sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c index 38f654aa73..7560ec5bac 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c @@ -10,5 +10,5 @@ attribute_hidden weak_function vscanf (const char *fmt, va_list ap) { - return __nldbl__IO_vfscanf (stdin, fmt, ap, NULL); + return __nldbl_vfscanf (stdin, fmt, ap); } diff --git a/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.c b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.c new file mode 100644 index 0000000000..0e38f24b5a --- /dev/null +++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.c @@ -0,0 +1 @@ +#include "test-nldbl-fscanf-redirect.c" diff --git a/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c new file mode 100644 index 0000000000..507a3f4a7c --- /dev/null +++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c @@ -0,0 +1,98 @@ +/* Test fscanf/scanf/vfscanf/vscanf of long double as double without + . + Copyright (C) 2024 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 + +#ifndef EXPECTED_LONG_DOUBLE_VALUE +# define EXPECTED_LONG_DOUBLE_VALUE 24.5 +#endif + +struct FILE; +extern struct FILE *stdin; +extern int fscanf (struct FILE *, const char *, ...); +extern int scanf (const char *, ...); +extern int vfscanf (struct FILE *, const char *, va_list); +extern int vscanf (const char *, va_list); +extern int printf (const char *format, ...); + +static int +wrap_vfscanf (struct FILE *fp, const char *format, ...) +{ + va_list ap; + va_start (ap, format); + int ret = vfscanf (fp, format, ap); + va_end (ap); + return ret; +} + +static int +wrap_vscanf (const char *format, ...) +{ + va_list ap; + va_start (ap, format); + int ret = vscanf (format, ap); + va_end (ap); + return ret; +} + +int +main (void) +{ + int n, i; + long double x; + char name[50]; + n = fscanf (stdin, "%d%Lf%s", &i, &x, name); + printf ("fscanf : n = %d, i = %d, x = %Lf, name = \"%.50s\"\n", + n, i, x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; + + n = scanf ("%d%Lf%s", &i, &x, name); + printf ("scanf : n = %d, i = %d, x = %Lf, name = \"%.50s\"\n", + n, i, x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; + + n = wrap_vfscanf (stdin, "%d%Lf%s", &i, &x, name); + printf ("vfscanf: n = %d, i = %d, x = %Lf, name = \"%.50s\"\n", + n, i, x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; + + n = wrap_vscanf ("%d%Lf%s", &i, &x, name); + printf ("vscanf : n = %d, i = %d, x = %Lf, name = \"%.50s\"\n", + n, i, x, name); + if (n != 3 + || i != 25 + || x != EXPECTED_LONG_DOUBLE_VALUE + || strcmp (name, "thompson")) + return 1; + + return 0; +}