aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/ieee754/ldbl-opt
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2018-03-07 14:31:58 -0500
committerGabriel F. T. Gomes <gabriel@inconstante.eti.br>2018-12-05 18:15:42 -0200
commit349718d4d7841df46bcc36df9bc2baef4c40d6f5 (patch)
tree1c6ae071a4a6d063e551ae6577b04d952262daea /sysdeps/ieee754/ldbl-opt
parent72b8692d7e640eb85ea0fb7de6d5e797512691c1 (diff)
downloadglibc-349718d4d7841df46bcc36df9bc2baef4c40d6f5.tar
glibc-349718d4d7841df46bcc36df9bc2baef4c40d6f5.tar.gz
glibc-349718d4d7841df46bcc36df9bc2baef4c40d6f5.tar.bz2
glibc-349718d4d7841df46bcc36df9bc2baef4c40d6f5.zip
Add __vfscanf_internal and __vfwscanf_internal with flags arguments.
There are two flags currently defined: SCANF_LDBL_IS_DBL is the mode used by __nldbl_ scanf variants, and SCANF_ISOC99_A is the mode used by __isoc99_ scanf variants. In this patch, the new functions honor these flag bits if they're set, but they still also look at the corresponding bits of environmental state, and callers all pass zero. The new functions do *not* have the "errp" argument possessed by _IO_vfscanf and _IO_vfwscanf. All internal callers passed NULL for that argument. External callers could theoretically exist, so I preserved wrappers, but they are flagged as compat symbols and they don't preserve the three-way distinction among types of errors that was formerly exposed. These functions probably should have been in the list of deprecated _IO_ symbols in 2.27 NEWS -- they're not just aliases for vfscanf and vfwscanf. (It was necessary to introduce ldbl_compat_symbol for _IO_vfscanf. Please check that part of the patch very carefully, I am still not confident I understand all of the details of ldbl-opt.) This patch also introduces helper inlines in libio/strfile.h that encapsulate the process of initializing an _IO_strfile object for reading. This allows us to call __vfscanf_internal directly from sscanf, and __vfwscanf_internal directly from swscanf, without duplicating the initialization code. (Previously, they called their v-counterparts, but that won't work if we want to control *both* C99 mode and ldbl-is-dbl mode using the flags argument to__vfscanf_internal.) It's still a little awkward, especially for wide strfiles, but it's much better than what we had. Tested for powerpc and powerpc64le.
Diffstat (limited to 'sysdeps/ieee754/ldbl-opt')
-rw-r--r--sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h6
-rw-r--r--sysdeps/ieee754/ldbl-opt/nldbl-compat.c17
2 files changed, 19 insertions, 4 deletions
diff --git a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
index 61ba784f86..1c49036f7b 100644
--- a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
+++ b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
@@ -20,10 +20,16 @@
long_double_symbol (libc, __GL_##name##_##aliasname, aliasname);
# define long_double_symbol_1(lib, local, symbol, version) \
versioned_symbol (lib, local, symbol, version)
+# define ldbl_compat_symbol(lib, local, symbol, version) \
+ compat_symbol (lib, local, symbol, LONG_DOUBLE_COMPAT_VERSION)
#else
# define ldbl_hidden_def(local, name) libc_hidden_def (name)
# define ldbl_strong_alias(name, aliasname) strong_alias (name, aliasname)
# define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname)
+/* Same as compat_symbol, ldbl_compat_symbol is not to be used outside
+ '#if SHLIB_COMPAT' statement and should fail if it is. */
+# define ldbl_compat_symbol(lib, local, symbol, version) \
+ _Static_assert (0, "ldbl_compat_symbol should be used inside SHLIB_COMPAT");
# ifndef __ASSEMBLER__
/* Note that weak_alias cannot be used - it is defined to nothing
in most of the C files. */
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
index 7a1e89c1a3..91ea27a423 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -330,16 +330,20 @@ __nldbl_wprintf (const wchar_t *fmt, ...)
return done;
}
+#if 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)
{
int res;
set_no_long_double ();
- res = _IO_vfscanf (s, fmt, ap, errp);
+ res = __vfscanf_internal (s, fmt, ap, 0);
clear_no_long_double ();
+ if (__glibc_unlikely (errp != 0))
+ *errp = (res == -1);
return res;
}
+#endif
int
attribute_compat_text_section
@@ -347,7 +351,7 @@ __nldbl___vfscanf (FILE *s, const char *fmt, va_list ap)
{
int res;
set_no_long_double ();
- res = _IO_vfscanf (s, fmt, ap, NULL);
+ res = __vfscanf_internal (s, fmt, ap, 0);
clear_no_long_double ();
return res;
}
@@ -423,7 +427,7 @@ __nldbl_vfwscanf (FILE *s, const wchar_t *fmt, va_list ap)
{
int res;
set_no_long_double ();
- res = _IO_vfwscanf (s, fmt, ap, NULL);
+ res = __vfwscanf_internal (s, fmt, ap, 0);
clear_no_long_double ();
return res;
}
@@ -1027,7 +1031,6 @@ compat_symbol (libc, __nldbl_vdprintf, vdprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsnprintf, vsnprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsprintf, vsprintf, GLIBC_2_0);
compat_symbol (libc, __nldbl__IO_sscanf, _IO_sscanf, GLIBC_2_0);
-compat_symbol (libc, __nldbl__IO_vfscanf, _IO_vfscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl___vfscanf, __vfscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl___vsscanf, __vsscanf, GLIBC_2_0);
compat_symbol (libc, __nldbl_fscanf, fscanf, GLIBC_2_0);
@@ -1040,6 +1043,12 @@ compat_symbol (libc, __nldbl___printf_fp, __printf_fp, GLIBC_2_0);
compat_symbol (libc, __nldbl_strfmon, strfmon, GLIBC_2_0);
compat_symbol (libc, __nldbl_syslog, syslog, GLIBC_2_0);
compat_symbol (libc, __nldbl_vsyslog, vsyslog, GLIBC_2_0);
+/* This function is not in public headers, but was exported until
+ version 2.29. For platforms that are newer than that, there's no
+ need to expose the symbol. */
+# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
+compat_symbol (libc, __nldbl__IO_vfscanf, _IO_vfscanf, GLIBC_2_0);
+# endif
#endif
#if LONG_DOUBLE_COMPAT(libc, GLIBC_2_1)
compat_symbol (libc, __nldbl___asprintf, __asprintf, GLIBC_2_1);