From 698fb75b9ff5ae454a1344b5f9fafa0ca367c555 Mon Sep 17 00:00:00 2001 From: Zack Weinberg Date: Wed, 7 Mar 2018 14:32:01 -0500 Subject: Add __v*printf_internal with flags arguments There are a lot more printf variants than there are scanf variants, and the code for setting up and tearing down their custom FILE variants around the call to __vf(w)printf is more complicated and variable. Therefore, I have added _internal versions of all the v*printf variants, rather than introducing helper routines so that they can all directly call __vf(w)printf_internal, as was done with scanf. As with the scanf changes, in this patch the _internal functions still look at the environmental mode bits and all callers pass 0 for the flags parameter. Several of the affected public functions had _IO_ name aliases that were not exported (but, in one case, appeared in libio.h anyway); I was originally planning to leave them as aliases to avoid having to touch internal callers, but it turns out ldbl_*_alias only work for exported symbols, so they've all been removed instead. It also turns out there were hardly any internal callers. _IO_vsprintf and _IO_vfprintf *are* exported, so those two stick around. Summary for the changes to each of the affected symbols: _IO_vfprintf, _IO_vsprintf: All internal calls removed, thus the internal declarations, as well as uses of libc_hidden_proto and libc_hidden_def, were also removed. The external symbol is now exposed via uses of ldbl_strong_alias to __vfprintf_internal and __vsprintf_internal, respectively. _IO_vasprintf, _IO_vdprintf, _IO_vsnprintf, _IO_vfwprintf, _IO_vswprintf, _IO_obstack_vprintf, _IO_obstack_printf: All internal calls removed, thus declaration in internal headers were also removed. They were never exported, so there are no aliases tying them to the internal functions. I.e.: entirely gone. __vsnprintf: Internal calls were always preceded by macros such as #define __vsnprintf _IO_vsnprintf, and #define __vsnprintf vsnprintf The macros were removed and their uses replaced with calls to the new internal function __vsnprintf_internal. Since there were no internal calls, the internal declaration was also removed. The external symbol is preserved with ldbl_weak_alias to ___vsnprintf. __vfwprintf: All internal calls converted into calls to __vfwprintf_internal, thus the internal declaration was removed. The function is now a wrapper that calls __vfwprintf_internal. The external symbol is preserved. __vswprintf: Similarly, but no external symbol. __vasprintf, __vdprintf, __vfprintf, __vsprintf: New internal wrappers. Not exported. vasprintf, vdprintf, vfprintf, vsprintf, vsnprintf, vfwprintf, vswprintf, obstack_vprintf, obstack_printf: These functions used to be aliases to the respective _IO_* function, they are now aliases to their respective __* functions. Tested for powerpc and powerpc64le. --- sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c index 468e23dec4..bda84af0bb 100644 --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c @@ -166,7 +166,7 @@ __nldbl_vfprintf (FILE *s, const char *fmt, va_list ap) { int done; set_no_long_double (); - done = _IO_vfprintf (s, fmt, ap); + done = __vfprintf_internal (s, fmt, ap, 0); clear_no_long_double (); return done; } @@ -175,15 +175,16 @@ strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf) int attribute_compat_text_section -__nldbl__IO_vsprintf (char *string, const char *fmt, va_list ap) +__nldbl___vsprintf (char *string, const char *fmt, va_list ap) { int done; __no_long_double = 1; - done = _IO_vsprintf (string, fmt, ap); + done = __vsprintf_internal (string, fmt, ap, 0); __no_long_double = 0; return done; } -weak_alias (__nldbl__IO_vsprintf, __nldbl_vsprintf) +strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf) +weak_alias (__nldbl___vsprintf, __nldbl_vsprintf) libc_hidden_def (__nldbl_vsprintf) int @@ -193,7 +194,7 @@ __nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt, { int done; __no_long_double = 1; - done = _IO_obstack_vprintf (obstack, fmt, ap); + done = __obstack_vprintf_internal (obstack, fmt, ap, 0); __no_long_double = 0; return done; } @@ -245,7 +246,7 @@ __nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap) { int res; __no_long_double = 1; - res = _IO_vasprintf (result_ptr, fmt, ap); + res = __vasprintf_internal (result_ptr, fmt, ap, 0); __no_long_double = 0; return res; } @@ -257,7 +258,7 @@ __nldbl_vdprintf (int d, const char *fmt, va_list arg) { int res; set_no_long_double (); - res = _IO_vdprintf (d, fmt, arg); + res = __vdprintf_internal (d, fmt, arg, 0); clear_no_long_double (); return res; } @@ -269,7 +270,7 @@ __nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap) { int res; set_no_long_double (); - res = _IO_vfwprintf (s, fmt, ap); + res = __vfwprintf_internal (s, fmt, ap, 0); clear_no_long_double (); return res; } @@ -289,7 +290,7 @@ __nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt, { int res; __no_long_double = 1; - res = _IO_vsnprintf (string, maxlen, fmt, ap); + res = __vsnprintf_internal (string, maxlen, fmt, ap, 0); __no_long_double = 0; return res; } @@ -303,7 +304,7 @@ __nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt, { int res; __no_long_double = 1; - res = _IO_vswprintf (string, maxlen, fmt, ap); + res = __vswprintf_internal (string, maxlen, fmt, ap, 0); __no_long_double = 0; return res; } -- cgit 1.4.1