* [PATCH] Always define __nldbl__IO_vfscanf in libc.a [BZ #31776]
@ 2024-05-24 15:00 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 2024-05-24 15:00 UTC (permalink / raw)
To: libc-alpha
Fix BZ #31776 by always defining __nldbl__IO_vfscanf in libc.a since it
is used in libnldbl_nonshared.a.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
sysdeps/ieee754/ldbl-opt/Makefile | 11 ++++++
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 4 +-
.../test-nldbl-fscanf-redirect-static.c | 1 +
.../test-nldbl-fscanf-redirect-static.input | 1 +
.../ldbl-opt/test-nldbl-fscanf-redirect.c | 37 +++++++++++++++++++
.../ldbl-opt/test-nldbl-fscanf-redirect.input | 1 +
6 files changed, 54 insertions(+), 1 deletion(-)
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 839a22689c..78fe053180 100644
--- a/sysdeps/ieee754/ldbl-opt/Makefile
+++ b/sysdeps/ieee754/ldbl-opt/Makefile
@@ -241,7 +241,12 @@ tests += \
tst-nldbl-scanf-binary-c23 \
tst-nldbl-scanf-binary-gnu11 \
tst-nldbl-scanf-binary-gnu89 \
+ test-nldbl-fscanf-redirect \
+ test-nldbl-fscanf-redirect-static \
# 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
@@ -255,6 +260,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..31aba4038c 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -274,7 +274,9 @@ __nldbl_wprintf (const wchar_t *fmt, ...)
return ret;
}
-#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
+/* Always define __nldbl__IO_vfscanf in libc.a since it is used in
+ libnldbl_nonshared.a. */
+#if !defined SHARED || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
int
attribute_compat_text_section
__nldbl__IO_vfscanf (FILE *s, const char *fmt, va_list ap, int *errp)
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..8438aabe42
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect-static.input
@@ -0,0 +1 @@
+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..566d908d9e
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.c
@@ -0,0 +1,37 @@
+/* Test fscanf 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/>. */
+
+#include <string.h>
+
+struct FILE;
+extern struct FILE *stdin;
+extern int fscanf (struct FILE *, const char *, ...);
+
+int
+main (void)
+{
+ int n, i;
+ long double x;
+ char name[50];
+ n = fscanf (stdin, "%d%Lf%s", &i, &x, name);
+
+ if (n != 3 || i != 25 || x != 5.432 || strcmp (name, "thompson"))
+ return 1;
+
+ return 0;
+}
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..8438aabe42
--- /dev/null
+++ b/sysdeps/ieee754/ldbl-opt/test-nldbl-fscanf-redirect.input
@@ -0,0 +1 @@
+25 54.32E-1 thompson
--
2.45.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-24 15:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24 15:00 [PATCH] Always define __nldbl__IO_vfscanf in libc.a [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).