* [PATCH 0/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776]
@ 2024-05-24 18:30 H.J. Lu
2024-05-24 18:30 ` [PATCH 1/2] Add scanf/vfscanf/vscanf tests of long double without <stdio.h> H.J. Lu
2024-05-24 18:30 ` [PATCH 2/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] H.J. Lu
0 siblings, 2 replies; 3+ messages in thread
From: H.J. Lu @ 2024-05-24 18:30 UTC (permalink / raw)
To: libc-alpha; +Cc: fweimer
__nldbl__IO_vfscanf is only needed in libnldbl_nonshared.a to define
_IO_vfscanf. But _IO_vfscanfis a compat symbol and shouldn't be in
libnldbl_nonshared.a. We can make __nldbl__IO_vfscanf a compat symbol
by
1. Remove _IO_vfscanf from libnldbl_nonshared.a.
2. Change libnldbl_nonshared.a to call __nldbl_vfscanf, instead of
__nldbl__IO_vfscanf.
H.J. Lu (2):
Add scanf/vfscanf/vscanf tests of long double without <stdio.h>
Make __nldbl__IO_vfscanf a compat symbol [BZ #31776]
stdio-common/test-fscanf.c | 55 ++++++++++++++++++-
stdio-common/test-fscanf.input | 3 +
sysdeps/ieee754/ldbl-opt/Makefile | 12 +++-
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 5 ++
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 +
.../test-nldbl-fscanf-redirect-static.input | 4 ++
.../ldbl-opt/test-nldbl-fscanf-redirect.c | 21 +++++++
.../ldbl-opt/test-nldbl-fscanf-redirect.input | 4 ++
13 files changed, 106 insertions(+), 20 deletions(-)
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-static.input
create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c
create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input
--
2.45.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] Add scanf/vfscanf/vscanf tests of long double without <stdio.h>
2024-05-24 18:30 [PATCH 0/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] H.J. Lu
@ 2024-05-24 18:30 ` H.J. Lu
2024-05-24 18:30 ` [PATCH 2/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] H.J. Lu
1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2024-05-24 18:30 UTC (permalink / raw)
To: libc-alpha; +Cc: fweimer
Update test-fscanf.c to add scanf/vfscanf/vscanf tests of long double
without including <stdio.h>.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
stdio-common/test-fscanf.c | 55 ++++++++++++++++++++++++++++++++--
stdio-common/test-fscanf.input | 3 ++
2 files changed, 56 insertions(+), 2 deletions(-)
diff --git a/stdio-common/test-fscanf.c b/stdio-common/test-fscanf.c
index f2c4250b51..26477300a5 100644
--- a/stdio-common/test-fscanf.c
+++ b/stdio-common/test-fscanf.c
@@ -1,4 +1,4 @@
-/* Test fscanf of long double without <stdio.h>.
+/* Test fscanf/scanf/vfscanf/vscanf of long double without <stdio.h>.
Copyright (C) 2024 Free Software Foundation, Inc.
This file is part of the GNU C Library.
@@ -16,11 +16,39 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <stdarg.h>
#include <string.h>
+#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);
+
+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)
@@ -29,8 +57,31 @@ main (void)
long double x;
char name[50];
n = fscanf (stdin, "%d%Lf%s", &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);
+ 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);
+ if (n != 3
+ || i != 25
+ || x != EXPECTED_LONG_DOUBLE_VALUE
+ || strcmp (name, "thompson"))
+ return 1;
- if (n != 3 || i != 25 || x != 24.5 || strcmp (name, "thompson"))
+ n = wrap_vscanf ("%d%Lf%s", &i, &x, name);
+ if (n != 3
+ || i != 25
+ || x != EXPECTED_LONG_DOUBLE_VALUE
+ || strcmp (name, "thompson"))
return 1;
return 0;
diff --git a/stdio-common/test-fscanf.input b/stdio-common/test-fscanf.input
index 69322cc51a..20859d314a 100644
--- a/stdio-common/test-fscanf.input
+++ b/stdio-common/test-fscanf.input
@@ -1 +1,4 @@
25 24.5 thompson
+25 24.5 thompson
+25 24.5 thompson
+25 24.5 thompson
--
2.45.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776]
2024-05-24 18:30 [PATCH 0/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] H.J. Lu
2024-05-24 18:30 ` [PATCH 1/2] Add scanf/vfscanf/vscanf tests of long double without <stdio.h> H.J. Lu
@ 2024-05-24 18:30 ` H.J. Lu
1 sibling, 0 replies; 3+ messages in thread
From: H.J. Lu @ 2024-05-24 18:30 UTC (permalink / raw)
To: libc-alpha; +Cc: fweimer
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
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 <stdio.h>.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
sysdeps/ieee754/ldbl-opt/Makefile | 12 ++++++++++-
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 5 +++++
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 +
.../test-nldbl-fscanf-redirect-static.input | 4 ++++
.../ldbl-opt/test-nldbl-fscanf-redirect.c | 21 +++++++++++++++++++
.../ldbl-opt/test-nldbl-fscanf-redirect.input | 4 ++++
11 files changed, 50 insertions(+), 18 deletions(-)
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-static.input
create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c
create mode 100644 sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input
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..b2a46b1fef 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -35,6 +35,7 @@
#include <sys/syslog.h>
#include <libc-lock.h>
+#include <nldbl-abi.h>
#include "nldbl-compat.h"
libc_hidden_proto (__nldbl_vsscanf)
@@ -1303,6 +1304,10 @@ compat_symbol (libc, __nldbl_vsyslog, vsyslog, GLIBC_2_0);
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
compat_symbol (libc, __nldbl__IO_vfscanf, _IO_vfscanf, GLIBC_2_0);
# 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
#endif
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_1)
compat_symbol (libc, __nldbl___asprintf, __asprintf, GLIBC_2_1);
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 <features.h>
-#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-static.input b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.input
new file mode 100644
index 0000000000..5551d71dab
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.input
@@ -0,0 +1,4 @@
+25 54.32E-1 thompson
+25 54.32E-1 thompson
+25 54.32E-1 thompson
+25 54.32E-1 thompson
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..ae1f0c1a4b
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c
@@ -0,0 +1,21 @@
+/* Test fscanf/scanf/vfscanf/vscanf of long double as double without
+ <stdio.h>.
+ 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
+ <https://www.gnu.org/licenses/>. */
+
+#define EXPECTED_LONG_DOUBLE_VALUE 5.432
+#include <test-fscanf.c>
diff --git a/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input
new file mode 100644
index 0000000000..5551d71dab
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input
@@ -0,0 +1,4 @@
+25 54.32E-1 thompson
+25 54.32E-1 thompson
+25 54.32E-1 thompson
+25 54.32E-1 thompson
--
2.45.1
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-24 18:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24 18:30 [PATCH 0/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] H.J. Lu
2024-05-24 18:30 ` [PATCH 1/2] Add scanf/vfscanf/vscanf tests of long double without <stdio.h> H.J. Lu
2024-05-24 18:30 ` [PATCH 2/2] Make __nldbl__IO_vfscanf a compat symbol [BZ #31776] H.J. Lu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).