[v3,7/7] Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl.
Commit Message
From: Zack Weinberg <zackw@panix.com>
Changed since v2:
- Removed #ifdef ASSEMBLER since no longer used.
Changed since v1:
- Removed libc_hidden_def and libc_hidden_proto from all of the
__nldbl_*printf* function, since they are no longer called from
within glibc, only from nldbl-*printf*.c files (libnldbl_nonshared.a)
-- 8< --
After all that prep work, nldbl-compat.c can now use PRINTF_LDBL_IS_DBL
instead of __no_long_double to control the behavior of printf-like
functions; this is the last thing we needed __no_long_double for, so it
can go away entirely.
Tested for powerpc and powerpc64le.
2018-10-25 Zack Weinberg <zackw@panix.com>
Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
* stdio-common/vfprintf-internal.c
(__vfprintf_internal, __vfwprintf_internal): Don't use __ldbl_is_dbl.
* sysdeps/generic/math_ldbl_opt.h: Remove __ldbl_is_dbl.
* sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h: Remove __ldbl_is_dbl
and __no_long_double.
* sysdeps/ieee754/ldbl-opt/math_ldbl_opt.c: Remove file.
* sysdeps/ieee754/ldbl-opt/Makefile (routines): Remove math_ldbl_opt.
* sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Remove
libc_hidden_proto and libc_hidden_def from all __nldbl_*printf*
and __nldbl_*syslog* functions.
(__nldbl_cleanup, set_no_long_double, clear_no_long_double): Remove.
(__nldbl___asprintf, __nldbl_dprintf, __nldbl_fprintf)
(__nldbl_fwprintf, __nldbl_printf, __nldbl_sprintf)
(__nldbl_vfprintf, __nldbl___vsprintf, __nldbl_obstack_vprintf)
(__ndlbl_obstack_printf, __nldbl_snprintf, __nldbl_swprintf)
(__nldbl_vasprintf, __nldbl_vdprintf, __nldbl_vfwprintf)
(__nldbl_vprintf, __nldbl_vsnprintf, __ndlbl_vswprintf)
(__nldbl_vwprintf, __nldbl_wprintf):
Directly call the appropriate __v*printf_internal routine, passing
PRINTF_LDBL_IS_DBL. Do not mess with __no_long_double. Normalize
variable names.
(__nldbl___fprintf_chk, __nldbl___fwprintf_chk)
(__nldbl___printf_chk, __nldbl___snprintf_chk)
(__nldbl___sprintf_chk, __nldbl___swprintf_chk)
(__nldbl___vfprintf_chk, __nldbl___vfwprintf_chk)
(__nldbl___vprintf_chk, __nldbl___vsnprintf_chk)
(__nldbl___vsprintf_chk, __nldbl___vswprintf_chk)
(__nldbl___vwprintf_chk, __nldbl___wprintf_chk)
(__nldbl___vasprintf_chk, __nldbl___asprintf_chk)
(__nldbl___vdprintf_chk, __nldbl___dprintf_chk)
(__nldbl___obstack_vprintf_chk, __nldbl___obstack_printf_chk):
Likewise, and also pass PRINTF_FORTIFY when appropriate.
(__nldbl_syslog, __nldbl_vsyslog):
Directly call __vsyslog_internal, passing PRINTF_LDBL_IS_DBL.
(__nldbl_syslog_chk): Likewise, and also pass PRINTF_FORTIFY when
appropriate.
(__nldbl_vsyslog_chk): Likewise, and also pass PRINTF_FORTIFY when
appropriate.
---
stdio-common/vfprintf-internal.c | 4 -
sysdeps/generic/math_ldbl_opt.h | 1 -
sysdeps/ieee754/ldbl-opt/Makefile | 2 +-
sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h | 7 -
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 504 +++++++++++++++----------------
5 files changed, 238 insertions(+), 280 deletions(-)
Comments
On 15/11/2018 19:44, Gabriel F. T. Gomes wrote:
> From: Zack Weinberg <zackw@panix.com>
>
> Changed since v2:
>
> - Removed #ifdef ASSEMBLER since no longer used.
LGTM, thanks.
>
> Changed since v1:
>
> - Removed libc_hidden_def and libc_hidden_proto from all of the
> __nldbl_*printf* function, since they are no longer called from
> within glibc, only from nldbl-*printf*.c files (libnldbl_nonshared.a)
>
> -- 8< --
> After all that prep work, nldbl-compat.c can now use PRINTF_LDBL_IS_DBL
> instead of __no_long_double to control the behavior of printf-like
> functions; this is the last thing we needed __no_long_double for, so it
> can go away entirely.
>
> Tested for powerpc and powerpc64le.
>
> 2018-10-25 Zack Weinberg <zackw@panix.com>
> Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
>
> * stdio-common/vfprintf-internal.c
> (__vfprintf_internal, __vfwprintf_internal): Don't use __ldbl_is_dbl.
> * sysdeps/generic/math_ldbl_opt.h: Remove __ldbl_is_dbl.
> * sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h: Remove __ldbl_is_dbl
> and __no_long_double.
> * sysdeps/ieee754/ldbl-opt/math_ldbl_opt.c: Remove file.
> * sysdeps/ieee754/ldbl-opt/Makefile (routines): Remove math_ldbl_opt.
> * sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Remove
> libc_hidden_proto and libc_hidden_def from all __nldbl_*printf*
> and __nldbl_*syslog* functions.
> (__nldbl_cleanup, set_no_long_double, clear_no_long_double): Remove.
> (__nldbl___asprintf, __nldbl_dprintf, __nldbl_fprintf)
> (__nldbl_fwprintf, __nldbl_printf, __nldbl_sprintf)
> (__nldbl_vfprintf, __nldbl___vsprintf, __nldbl_obstack_vprintf)
> (__ndlbl_obstack_printf, __nldbl_snprintf, __nldbl_swprintf)
> (__nldbl_vasprintf, __nldbl_vdprintf, __nldbl_vfwprintf)
> (__nldbl_vprintf, __nldbl_vsnprintf, __ndlbl_vswprintf)
> (__nldbl_vwprintf, __nldbl_wprintf):
> Directly call the appropriate __v*printf_internal routine, passing
> PRINTF_LDBL_IS_DBL. Do not mess with __no_long_double. Normalize
> variable names.
> (__nldbl___fprintf_chk, __nldbl___fwprintf_chk)
> (__nldbl___printf_chk, __nldbl___snprintf_chk)
> (__nldbl___sprintf_chk, __nldbl___swprintf_chk)
> (__nldbl___vfprintf_chk, __nldbl___vfwprintf_chk)
> (__nldbl___vprintf_chk, __nldbl___vsnprintf_chk)
> (__nldbl___vsprintf_chk, __nldbl___vswprintf_chk)
> (__nldbl___vwprintf_chk, __nldbl___wprintf_chk)
> (__nldbl___vasprintf_chk, __nldbl___asprintf_chk)
> (__nldbl___vdprintf_chk, __nldbl___dprintf_chk)
> (__nldbl___obstack_vprintf_chk, __nldbl___obstack_printf_chk):
> Likewise, and also pass PRINTF_FORTIFY when appropriate.
> (__nldbl_syslog, __nldbl_vsyslog):
> Directly call __vsyslog_internal, passing PRINTF_LDBL_IS_DBL.
> (__nldbl_syslog_chk): Likewise, and also pass PRINTF_FORTIFY when
> appropriate.
> (__nldbl_vsyslog_chk): Likewise, and also pass PRINTF_FORTIFY when
> appropriate.
> ---
> stdio-common/vfprintf-internal.c | 4 -
> sysdeps/generic/math_ldbl_opt.h | 1 -
> sysdeps/ieee754/ldbl-opt/Makefile | 2 +-
> sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h | 7 -
> sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 504 +++++++++++++++----------------
> 5 files changed, 238 insertions(+), 280 deletions(-)
>
> diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
> index 4cc4261ead..61769e0ce1 100644
> --- a/stdio-common/vfprintf-internal.c
> +++ b/stdio-common/vfprintf-internal.c
> @@ -1280,10 +1280,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags)
> 0 if unknown. */
> int readonly_format = 0;
>
> - /* Temporarily honor environmental settings. */
> - if (__ldbl_is_dbl)
> - mode_flags |= PRINTF_LDBL_IS_DBL;
> -
> /* Orient the stream. */
> #ifdef ORIENT
> ORIENT;
Ok.
> diff --git a/sysdeps/generic/math_ldbl_opt.h b/sysdeps/generic/math_ldbl_opt.h
> index 92f670dff7..fbd2c82e2f 100644
> --- a/sysdeps/generic/math_ldbl_opt.h
> +++ b/sysdeps/generic/math_ldbl_opt.h
> @@ -15,4 +15,3 @@
> #define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname)
> #define ldbl_compat_symbol(lib, local, symbol, version) \
> compat_symbol (lib, local, symbol, version)
> -#define __ldbl_is_dbl 0
Ok.
> diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
> index 6854413fa3..64fdb8cb9e 100644
> --- a/sysdeps/ieee754/ldbl-opt/Makefile
> +++ b/sysdeps/ieee754/ldbl-opt/Makefile
> @@ -8,7 +8,7 @@ endif
>
> ifeq ($(subdir),math)
> libm-routines += s_nexttowardfd
> -routines += math_ldbl_opt nldbl-compat
> +routines += nldbl-compat
>
> extra-libs += libnldbl
> libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \
Ok.
> diff --git a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
> index 1c49036f7b..cbe8156e39 100644
> --- a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
> +++ b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
> @@ -40,10 +40,3 @@
> weak_alias (local, symbol)
> # endif
> #endif
> -
> -#ifndef __ASSEMBLER__
> -/* Set temporarily to non-zero if long double should be considered
> - the same as double. */
> -extern __thread int __no_long_double attribute_tls_model_ie attribute_hidden;
> -# define __ldbl_is_dbl __builtin_expect (__no_long_double, 0)
> -#endif
Ok.
> diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
> index 59b2c9fcdd..f6dd81759d 100644
> --- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
> +++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
> @@ -30,43 +30,15 @@
>
> #include "nldbl-compat.h"
>
> -libc_hidden_proto (__nldbl_vfprintf)
> libc_hidden_proto (__nldbl_vsscanf)
> -libc_hidden_proto (__nldbl_vsprintf)
> libc_hidden_proto (__nldbl_vfscanf)
> libc_hidden_proto (__nldbl_vfwscanf)
> -libc_hidden_proto (__nldbl_vdprintf)
> libc_hidden_proto (__nldbl_vswscanf)
> -libc_hidden_proto (__nldbl_vfwprintf)
> -libc_hidden_proto (__nldbl_vswprintf)
> -libc_hidden_proto (__nldbl_vsnprintf)
> -libc_hidden_proto (__nldbl_vasprintf)
> -libc_hidden_proto (__nldbl_obstack_vprintf)
> -libc_hidden_proto (__nldbl___vfwprintf_chk)
> -libc_hidden_proto (__nldbl___vsnprintf_chk)
> -libc_hidden_proto (__nldbl___vfprintf_chk)
> -libc_hidden_proto (__nldbl___vsyslog_chk)
> -libc_hidden_proto (__nldbl___vsprintf_chk)
> -libc_hidden_proto (__nldbl___vswprintf_chk)
> -libc_hidden_proto (__nldbl___vasprintf_chk)
> -libc_hidden_proto (__nldbl___vdprintf_chk)
> -libc_hidden_proto (__nldbl___obstack_vprintf_chk)
> libc_hidden_proto (__nldbl___isoc99_vsscanf)
> libc_hidden_proto (__nldbl___isoc99_vfscanf)
> libc_hidden_proto (__nldbl___isoc99_vswscanf)
> libc_hidden_proto (__nldbl___isoc99_vfwscanf)
>
> -static void
> -__nldbl_cleanup (void *arg)
> -{
> - __no_long_double = 0;
> -}
> -
> -#define set_no_long_double() \
> - __libc_cleanup_push (__nldbl_cleanup, NULL); __no_long_double = 1
> -#define clear_no_long_double() \
> - __no_long_double = 0; __libc_cleanup_pop (0)
> -
> /* Compatibility with IEEE double as long double.
> IEEE quad long double is used by default for most programs, so
> we don't need to split this into one file per function for the
> @@ -76,14 +48,14 @@ int
> attribute_compat_text_section
> __nldbl___asprintf (char **string_ptr, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vasprintf (string_ptr, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vasprintf_internal (string_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
> weak_alias (__nldbl___asprintf, __nldbl_asprintf)
>
> @@ -91,28 +63,28 @@ int
> attribute_compat_text_section
> __nldbl_dprintf (int d, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vdprintf (d, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl_fprintf (FILE *stream, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vfprintf (stream, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
> weak_alias (__nldbl_fprintf, __nldbl__IO_fprintf)
>
> @@ -120,28 +92,28 @@ int
> attribute_compat_text_section weak_function
> __nldbl_fwprintf (FILE *stream, const wchar_t *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vfwprintf (stream, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfwprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl_printf (const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vfprintf (stdout, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
> strong_alias (__nldbl_printf, __nldbl__IO_printf)
>
> @@ -149,14 +121,14 @@ int
> attribute_compat_text_section
> __nldbl_sprintf (char *s, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vsprintf (s, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vsprintf_internal (s, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
> strong_alias (__nldbl_sprintf, __nldbl__IO_sprintf)
>
> @@ -164,123 +136,93 @@ int
> attribute_compat_text_section
> __nldbl_vfprintf (FILE *s, const char *fmt, va_list ap)
> {
> - int done;
> - set_no_long_double ();
> - done = __vfprintf_internal (s, fmt, ap, 0);
> - clear_no_long_double ();
> - return done;
> + return __vfprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_vfprintf)
> strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf)
>
> int
> attribute_compat_text_section
> __nldbl___vsprintf (char *string, const char *fmt, va_list ap)
> {
> - int done;
> - __no_long_double = 1;
> - done = __vsprintf_internal (string, -1, fmt, ap, 0);
> - __no_long_double = 0;
> - return done;
> + return __vsprintf_internal (string, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf)
> weak_alias (__nldbl___vsprintf, __nldbl_vsprintf)
> -libc_hidden_def (__nldbl_vsprintf)
>
> int
> attribute_compat_text_section
> __nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt,
> va_list ap)
> {
> - int done;
> - __no_long_double = 1;
> - done = __obstack_vprintf_internal (obstack, fmt, ap, 0);
> - __no_long_double = 0;
> - return done;
> + return __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_obstack_vprintf)
>
> int
> attribute_compat_text_section
> __nldbl_obstack_printf (struct obstack *obstack, const char *fmt, ...)
> {
> - int result;
> + int ret;
> va_list ap;
> va_start (ap, fmt);
> - result = __nldbl_obstack_vprintf (obstack, fmt, ap);
> + ret = __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
> va_end (ap);
> - return result;
> + return ret;
> }
>
> int
> attribute_compat_text_section weak_function
> __nldbl_snprintf (char *s, size_t maxlen, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vsnprintf (s, maxlen, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vsnprintf_internal (s, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl_swprintf (wchar_t *s, size_t n, const wchar_t *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vswprintf (s, n, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vswprintf_internal (s, n, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section weak_function
> __nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap)
> {
> - int res;
> - __no_long_double = 1;
> - res = __vasprintf_internal (result_ptr, fmt, ap, 0);
> - __no_long_double = 0;
> - return res;
> + return __vasprintf_internal (result_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_vasprintf)
>
> int
> attribute_compat_text_section
> -__nldbl_vdprintf (int d, const char *fmt, va_list arg)
> +__nldbl_vdprintf (int d, const char *fmt, va_list ap)
> {
> - int res;
> - set_no_long_double ();
> - res = __vdprintf_internal (d, fmt, arg, 0);
> - clear_no_long_double ();
> - return res;
> + return __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_vdprintf)
>
> int
> attribute_compat_text_section weak_function
> __nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap)
> {
> - int res;
> - set_no_long_double ();
> - res = __vfwprintf_internal (s, fmt, ap, 0);
> - clear_no_long_double ();
> - return res;
> + return __vfwprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_vfwprintf)
>
> int
> attribute_compat_text_section
> __nldbl_vprintf (const char *fmt, va_list ap)
> {
> - return __nldbl_vfprintf (stdout, fmt, ap);
> + return __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
>
> int
> @@ -288,13 +230,8 @@ attribute_compat_text_section
> __nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt,
> va_list ap)
> {
> - int res;
> - __no_long_double = 1;
> - res = __vsnprintf_internal (string, maxlen, fmt, ap, 0);
> - __no_long_double = 0;
> - return res;
> + return __vsnprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_vsnprintf)
> weak_alias (__nldbl_vsnprintf, __nldbl___vsnprintf)
>
> int
> @@ -302,33 +239,28 @@ attribute_compat_text_section weak_function
> __nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt,
> va_list ap)
> {
> - int res;
> - __no_long_double = 1;
> - res = __vswprintf_internal (string, maxlen, fmt, ap, 0);
> - __no_long_double = 0;
> - return res;
> + return __vswprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
> -libc_hidden_def (__nldbl_vswprintf)
>
> int
> attribute_compat_text_section
> __nldbl_vwprintf (const wchar_t *fmt, va_list ap)
> {
> - return __nldbl_vfwprintf (stdout, fmt, ap);
> + return __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
> }
>
> int
> attribute_compat_text_section
> __nldbl_wprintf (const wchar_t *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
>
> - va_start (arg, fmt);
> - done = __nldbl_vfwprintf (stdout, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
> @@ -491,42 +423,51 @@ int
> attribute_compat_text_section
> __nldbl___fprintf_chk (FILE *stream, int flag, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vfprintf_chk (stream, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfprintf_internal (stream, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl___fwprintf_chk (FILE *stream, int flag, const wchar_t *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vfwprintf_chk (stream, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfwprintf_internal (stream, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl___printf_chk (int flag, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vfprintf_chk (stdout, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfprintf_internal (stdout, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> @@ -534,74 +475,94 @@ attribute_compat_text_section
> __nldbl___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
> const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + if (__glibc_unlikely (slen < maxlen))
> + __chk_fail ();
>
> - va_start (arg, fmt);
> - done = __nldbl___vsnprintf_chk (s, maxlen, flag, slen, fmt, arg);
> - va_end (arg);
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - return done;
> + va_start (ap, fmt);
> + ret = __vsnprintf_internal (s, maxlen, fmt, ap, mode);
> + va_end (ap);
> +
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl___sprintf_chk (char *s, int flag, size_t slen, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + if (slen == 0)
> + __chk_fail ();
> +
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vsprintf_chk (s, flag, slen, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vsprintf_internal (s, slen, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> -__nldbl___swprintf_chk (wchar_t *s, size_t n, int flag, size_t slen,
> +__nldbl___swprintf_chk (wchar_t *s, size_t maxlen, int flag, size_t slen,
> const wchar_t *fmt, ...)
> {
> - va_list arg;
> - int done;
> + if (__glibc_unlikely (slen < maxlen))
> + __chk_fail ();
> +
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vswprintf_chk (s, n, flag, slen, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vswprintf_internal (s, maxlen, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl___vfprintf_chk (FILE *s, int flag, const char *fmt, va_list ap)
> {
> - int res;
> - set_no_long_double ();
> - res = __vfprintf_internal (s, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
> - clear_no_long_double ();
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vfprintf_internal (s, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vfprintf_chk)
>
> int
> attribute_compat_text_section
> __nldbl___vfwprintf_chk (FILE *s, int flag, const wchar_t *fmt, va_list ap)
> {
> - int res;
> - set_no_long_double ();
> - res = __vfwprintf_internal (s, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
> - clear_no_long_double ();
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vfwprintf_internal (s, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vfwprintf_chk)
>
> int
> attribute_compat_text_section
> __nldbl___vprintf_chk (int flag, const char *fmt, va_list ap)
> {
> - return __nldbl___vfprintf_chk (stdout, flag, fmt, ap);
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vfprintf_internal (stdout, fmt, ap, mode);
> }
>
> int
> @@ -612,14 +573,12 @@ __nldbl___vsnprintf_chk (char *string, size_t maxlen, int flag, size_t slen,
> if (__glibc_unlikely (slen < maxlen))
> __chk_fail ();
>
> - int res;
> - __no_long_double = 1;
> - res = __vsnprintf_internal (string, maxlen, fmt, ap,
> - (flag > 0) ? PRINTF_FORTIFY : 0);
> - __no_long_double = 0;
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vsnprintf_internal (string, maxlen, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vsnprintf_chk)
>
> int
> attribute_compat_text_section
> @@ -629,14 +588,12 @@ __nldbl___vsprintf_chk (char *string, int flag, size_t slen, const char *fmt,
> if (slen == 0)
> __chk_fail ();
>
> - int res;
> - __no_long_double = 1;
> - res = __vsprintf_internal (string, slen, fmt, ap,
> - (flag > 0) ? PRINTF_FORTIFY : 0);
> - __no_long_double = 0;
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vsprintf_internal (string, slen, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vsprintf_chk)
>
> int
> attribute_compat_text_section
> @@ -646,116 +603,125 @@ __nldbl___vswprintf_chk (wchar_t *string, size_t maxlen, int flag, size_t slen,
> if (__glibc_unlikely (slen < maxlen))
> __chk_fail ();
>
> - int res;
> - __no_long_double = 1;
> - res = __vswprintf_internal (string, maxlen, fmt, ap,
> - (flag > 0) ? PRINTF_FORTIFY : 0);
> - __no_long_double = 0;
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vswprintf_internal (string, maxlen, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vswprintf_chk)
>
> int
> attribute_compat_text_section
> __nldbl___vwprintf_chk (int flag, const wchar_t *fmt, va_list ap)
> {
> - return __nldbl___vfwprintf_chk (stdout, flag, fmt, ap);
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vfwprintf_internal (stdout, fmt, ap, mode);
> }
>
> int
> attribute_compat_text_section
> __nldbl___wprintf_chk (int flag, const wchar_t *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vfwprintf_chk (stdout, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vfwprintf_internal (stdout, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> -__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list arg)
> +__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list ap)
> {
> - int res;
> - __no_long_double = 1;
> - res = __vasprintf_internal (ptr, fmt, arg,
> - (flag > 0) ? PRINTF_FORTIFY : 0);
> - __no_long_double = 0;
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vasprintf_internal (ptr, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vasprintf_chk)
>
> int
> attribute_compat_text_section
> __nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vasprintf_chk (ptr, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vasprintf_internal (ptr, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> -__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list arg)
> +__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list ap)
> {
> - int res;
> - set_no_long_double ();
> - res = __vdprintf_internal (d, fmt, arg, (flag > 0) ? PRINTF_FORTIFY : 0);
> - clear_no_long_double ();
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __vdprintf_internal (d, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___vdprintf_chk)
>
> int
> attribute_compat_text_section
> __nldbl___dprintf_chk (int d, int flag, const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___vdprintf_chk (d, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __vdprintf_internal (d, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> int
> attribute_compat_text_section
> __nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag,
> - const char *fmt, va_list arg)
> + const char *fmt, va_list ap)
> {
> - int res;
> - __no_long_double = 1;
> - res = __obstack_vprintf_internal (obstack, fmt, arg,
> - (flag > 0) ? PRINTF_FORTIFY : 0);
> - __no_long_double = 0;
> - return res;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
> +
> + return __obstack_vprintf_internal (obstack, fmt, ap, mode);
> }
> -libc_hidden_def (__nldbl___obstack_vprintf_chk)
>
> int
> attribute_compat_text_section
> __nldbl___obstack_printf_chk (struct obstack *obstack, int flag,
> const char *fmt, ...)
> {
> - va_list arg;
> - int done;
> + va_list ap;
> + int ret;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> - va_start (arg, fmt);
> - done = __nldbl___obstack_vprintf_chk (obstack, flag, fmt, arg);
> - va_end (arg);
> + va_start (ap, fmt);
> + ret = __obstack_vprintf_internal (obstack, fmt, ap, mode);
> + va_end (ap);
>
> - return done;
> + return ret;
> }
>
> extern __typeof (printf_size) __printf_size;
> @@ -837,18 +803,28 @@ __nldbl_syslog (int pri, const char *fmt, ...)
> {
> va_list ap;
> va_start (ap, fmt);
> - __nldbl___vsyslog_chk (pri, -1, fmt, ap);
> + __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
> va_end (ap);
> }
>
> +void
> +attribute_compat_text_section
> +__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
> +{
> + __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
> +}
> +
> void
> attribute_compat_text_section
> __nldbl___syslog_chk (int pri, int flag, const char *fmt, ...)
> {
> va_list ap;
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> va_start (ap, fmt);
> - __nldbl___vsyslog_chk (pri, flag, fmt, ap);
> + __vsyslog_internal (pri, fmt, ap, mode);
> va_end(ap);
> }
>
> @@ -856,17 +832,11 @@ void
> attribute_compat_text_section
> __nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
> {
> - set_no_long_double ();
> - __vsyslog_internal (pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
> - clear_no_long_double ();
> -}
> -libc_hidden_def (__nldbl___vsyslog_chk)
> + unsigned int mode = PRINTF_LDBL_IS_DBL;
> + if (flag > 0)
> + mode |= PRINTF_FORTIFY;
>
> -void
> -attribute_compat_text_section
> -__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
> -{
> - __nldbl___vsyslog_chk (pri, -1, fmt, ap);
> + __vsyslog_internal (pri, fmt, ap, mode);
> }
>
> int
>
Ok.
@@ -1280,10 +1280,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags)
0 if unknown. */
int readonly_format = 0;
- /* Temporarily honor environmental settings. */
- if (__ldbl_is_dbl)
- mode_flags |= PRINTF_LDBL_IS_DBL;
-
/* Orient the stream. */
#ifdef ORIENT
ORIENT;
@@ -15,4 +15,3 @@
#define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname)
#define ldbl_compat_symbol(lib, local, symbol, version) \
compat_symbol (lib, local, symbol, version)
-#define __ldbl_is_dbl 0
@@ -8,7 +8,7 @@ endif
ifeq ($(subdir),math)
libm-routines += s_nexttowardfd
-routines += math_ldbl_opt nldbl-compat
+routines += nldbl-compat
extra-libs += libnldbl
libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \
@@ -40,10 +40,3 @@
weak_alias (local, symbol)
# endif
#endif
-
-#ifndef __ASSEMBLER__
-/* Set temporarily to non-zero if long double should be considered
- the same as double. */
-extern __thread int __no_long_double attribute_tls_model_ie attribute_hidden;
-# define __ldbl_is_dbl __builtin_expect (__no_long_double, 0)
-#endif
@@ -30,43 +30,15 @@
#include "nldbl-compat.h"
-libc_hidden_proto (__nldbl_vfprintf)
libc_hidden_proto (__nldbl_vsscanf)
-libc_hidden_proto (__nldbl_vsprintf)
libc_hidden_proto (__nldbl_vfscanf)
libc_hidden_proto (__nldbl_vfwscanf)
-libc_hidden_proto (__nldbl_vdprintf)
libc_hidden_proto (__nldbl_vswscanf)
-libc_hidden_proto (__nldbl_vfwprintf)
-libc_hidden_proto (__nldbl_vswprintf)
-libc_hidden_proto (__nldbl_vsnprintf)
-libc_hidden_proto (__nldbl_vasprintf)
-libc_hidden_proto (__nldbl_obstack_vprintf)
-libc_hidden_proto (__nldbl___vfwprintf_chk)
-libc_hidden_proto (__nldbl___vsnprintf_chk)
-libc_hidden_proto (__nldbl___vfprintf_chk)
-libc_hidden_proto (__nldbl___vsyslog_chk)
-libc_hidden_proto (__nldbl___vsprintf_chk)
-libc_hidden_proto (__nldbl___vswprintf_chk)
-libc_hidden_proto (__nldbl___vasprintf_chk)
-libc_hidden_proto (__nldbl___vdprintf_chk)
-libc_hidden_proto (__nldbl___obstack_vprintf_chk)
libc_hidden_proto (__nldbl___isoc99_vsscanf)
libc_hidden_proto (__nldbl___isoc99_vfscanf)
libc_hidden_proto (__nldbl___isoc99_vswscanf)
libc_hidden_proto (__nldbl___isoc99_vfwscanf)
-static void
-__nldbl_cleanup (void *arg)
-{
- __no_long_double = 0;
-}
-
-#define set_no_long_double() \
- __libc_cleanup_push (__nldbl_cleanup, NULL); __no_long_double = 1
-#define clear_no_long_double() \
- __no_long_double = 0; __libc_cleanup_pop (0)
-
/* Compatibility with IEEE double as long double.
IEEE quad long double is used by default for most programs, so
we don't need to split this into one file per function for the
@@ -76,14 +48,14 @@ int
attribute_compat_text_section
__nldbl___asprintf (char **string_ptr, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vasprintf (string_ptr, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vasprintf_internal (string_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
weak_alias (__nldbl___asprintf, __nldbl_asprintf)
@@ -91,28 +63,28 @@ int
attribute_compat_text_section
__nldbl_dprintf (int d, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vdprintf (d, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl_fprintf (FILE *stream, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vfprintf (stream, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
weak_alias (__nldbl_fprintf, __nldbl__IO_fprintf)
@@ -120,28 +92,28 @@ int
attribute_compat_text_section weak_function
__nldbl_fwprintf (FILE *stream, const wchar_t *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vfwprintf (stream, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfwprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl_printf (const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vfprintf (stdout, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
strong_alias (__nldbl_printf, __nldbl__IO_printf)
@@ -149,14 +121,14 @@ int
attribute_compat_text_section
__nldbl_sprintf (char *s, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vsprintf (s, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vsprintf_internal (s, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
strong_alias (__nldbl_sprintf, __nldbl__IO_sprintf)
@@ -164,123 +136,93 @@ int
attribute_compat_text_section
__nldbl_vfprintf (FILE *s, const char *fmt, va_list ap)
{
- int done;
- set_no_long_double ();
- done = __vfprintf_internal (s, fmt, ap, 0);
- clear_no_long_double ();
- return done;
+ return __vfprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_vfprintf)
strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf)
int
attribute_compat_text_section
__nldbl___vsprintf (char *string, const char *fmt, va_list ap)
{
- int done;
- __no_long_double = 1;
- done = __vsprintf_internal (string, -1, fmt, ap, 0);
- __no_long_double = 0;
- return done;
+ return __vsprintf_internal (string, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
}
strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf)
weak_alias (__nldbl___vsprintf, __nldbl_vsprintf)
-libc_hidden_def (__nldbl_vsprintf)
int
attribute_compat_text_section
__nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt,
va_list ap)
{
- int done;
- __no_long_double = 1;
- done = __obstack_vprintf_internal (obstack, fmt, ap, 0);
- __no_long_double = 0;
- return done;
+ return __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_obstack_vprintf)
int
attribute_compat_text_section
__nldbl_obstack_printf (struct obstack *obstack, const char *fmt, ...)
{
- int result;
+ int ret;
va_list ap;
va_start (ap, fmt);
- result = __nldbl_obstack_vprintf (obstack, fmt, ap);
+ ret = __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
- return result;
+ return ret;
}
int
attribute_compat_text_section weak_function
__nldbl_snprintf (char *s, size_t maxlen, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vsnprintf (s, maxlen, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vsnprintf_internal (s, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl_swprintf (wchar_t *s, size_t n, const wchar_t *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vswprintf (s, n, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vswprintf_internal (s, n, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section weak_function
__nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap)
{
- int res;
- __no_long_double = 1;
- res = __vasprintf_internal (result_ptr, fmt, ap, 0);
- __no_long_double = 0;
- return res;
+ return __vasprintf_internal (result_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_vasprintf)
int
attribute_compat_text_section
-__nldbl_vdprintf (int d, const char *fmt, va_list arg)
+__nldbl_vdprintf (int d, const char *fmt, va_list ap)
{
- int res;
- set_no_long_double ();
- res = __vdprintf_internal (d, fmt, arg, 0);
- clear_no_long_double ();
- return res;
+ return __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_vdprintf)
int
attribute_compat_text_section weak_function
__nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap)
{
- int res;
- set_no_long_double ();
- res = __vfwprintf_internal (s, fmt, ap, 0);
- clear_no_long_double ();
- return res;
+ return __vfwprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_vfwprintf)
int
attribute_compat_text_section
__nldbl_vprintf (const char *fmt, va_list ap)
{
- return __nldbl_vfprintf (stdout, fmt, ap);
+ return __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
@@ -288,13 +230,8 @@ attribute_compat_text_section
__nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt,
va_list ap)
{
- int res;
- __no_long_double = 1;
- res = __vsnprintf_internal (string, maxlen, fmt, ap, 0);
- __no_long_double = 0;
- return res;
+ return __vsnprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_vsnprintf)
weak_alias (__nldbl_vsnprintf, __nldbl___vsnprintf)
int
@@ -302,33 +239,28 @@ attribute_compat_text_section weak_function
__nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt,
va_list ap)
{
- int res;
- __no_long_double = 1;
- res = __vswprintf_internal (string, maxlen, fmt, ap, 0);
- __no_long_double = 0;
- return res;
+ return __vswprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
}
-libc_hidden_def (__nldbl_vswprintf)
int
attribute_compat_text_section
__nldbl_vwprintf (const wchar_t *fmt, va_list ap)
{
- return __nldbl_vfwprintf (stdout, fmt, ap);
+ return __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
}
int
attribute_compat_text_section
__nldbl_wprintf (const wchar_t *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
- va_start (arg, fmt);
- done = __nldbl_vfwprintf (stdout, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
+ va_end (ap);
- return done;
+ return ret;
}
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
@@ -491,42 +423,51 @@ int
attribute_compat_text_section
__nldbl___fprintf_chk (FILE *stream, int flag, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vfprintf_chk (stream, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfprintf_internal (stream, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl___fwprintf_chk (FILE *stream, int flag, const wchar_t *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vfwprintf_chk (stream, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfwprintf_internal (stream, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl___printf_chk (int flag, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vfprintf_chk (stdout, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfprintf_internal (stdout, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
@@ -534,74 +475,94 @@ attribute_compat_text_section
__nldbl___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
const char *fmt, ...)
{
- va_list arg;
- int done;
+ if (__glibc_unlikely (slen < maxlen))
+ __chk_fail ();
- va_start (arg, fmt);
- done = __nldbl___vsnprintf_chk (s, maxlen, flag, slen, fmt, arg);
- va_end (arg);
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- return done;
+ va_start (ap, fmt);
+ ret = __vsnprintf_internal (s, maxlen, fmt, ap, mode);
+ va_end (ap);
+
+ return ret;
}
int
attribute_compat_text_section
__nldbl___sprintf_chk (char *s, int flag, size_t slen, const char *fmt, ...)
{
- va_list arg;
- int done;
+ if (slen == 0)
+ __chk_fail ();
+
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vsprintf_chk (s, flag, slen, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vsprintf_internal (s, slen, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
-__nldbl___swprintf_chk (wchar_t *s, size_t n, int flag, size_t slen,
+__nldbl___swprintf_chk (wchar_t *s, size_t maxlen, int flag, size_t slen,
const wchar_t *fmt, ...)
{
- va_list arg;
- int done;
+ if (__glibc_unlikely (slen < maxlen))
+ __chk_fail ();
+
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vswprintf_chk (s, n, flag, slen, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vswprintf_internal (s, maxlen, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl___vfprintf_chk (FILE *s, int flag, const char *fmt, va_list ap)
{
- int res;
- set_no_long_double ();
- res = __vfprintf_internal (s, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
- clear_no_long_double ();
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vfprintf_internal (s, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vfprintf_chk)
int
attribute_compat_text_section
__nldbl___vfwprintf_chk (FILE *s, int flag, const wchar_t *fmt, va_list ap)
{
- int res;
- set_no_long_double ();
- res = __vfwprintf_internal (s, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
- clear_no_long_double ();
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vfwprintf_internal (s, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vfwprintf_chk)
int
attribute_compat_text_section
__nldbl___vprintf_chk (int flag, const char *fmt, va_list ap)
{
- return __nldbl___vfprintf_chk (stdout, flag, fmt, ap);
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vfprintf_internal (stdout, fmt, ap, mode);
}
int
@@ -612,14 +573,12 @@ __nldbl___vsnprintf_chk (char *string, size_t maxlen, int flag, size_t slen,
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
- int res;
- __no_long_double = 1;
- res = __vsnprintf_internal (string, maxlen, fmt, ap,
- (flag > 0) ? PRINTF_FORTIFY : 0);
- __no_long_double = 0;
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vsnprintf_internal (string, maxlen, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vsnprintf_chk)
int
attribute_compat_text_section
@@ -629,14 +588,12 @@ __nldbl___vsprintf_chk (char *string, int flag, size_t slen, const char *fmt,
if (slen == 0)
__chk_fail ();
- int res;
- __no_long_double = 1;
- res = __vsprintf_internal (string, slen, fmt, ap,
- (flag > 0) ? PRINTF_FORTIFY : 0);
- __no_long_double = 0;
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vsprintf_internal (string, slen, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vsprintf_chk)
int
attribute_compat_text_section
@@ -646,116 +603,125 @@ __nldbl___vswprintf_chk (wchar_t *string, size_t maxlen, int flag, size_t slen,
if (__glibc_unlikely (slen < maxlen))
__chk_fail ();
- int res;
- __no_long_double = 1;
- res = __vswprintf_internal (string, maxlen, fmt, ap,
- (flag > 0) ? PRINTF_FORTIFY : 0);
- __no_long_double = 0;
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vswprintf_internal (string, maxlen, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vswprintf_chk)
int
attribute_compat_text_section
__nldbl___vwprintf_chk (int flag, const wchar_t *fmt, va_list ap)
{
- return __nldbl___vfwprintf_chk (stdout, flag, fmt, ap);
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vfwprintf_internal (stdout, fmt, ap, mode);
}
int
attribute_compat_text_section
__nldbl___wprintf_chk (int flag, const wchar_t *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vfwprintf_chk (stdout, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vfwprintf_internal (stdout, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
-__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list arg)
+__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list ap)
{
- int res;
- __no_long_double = 1;
- res = __vasprintf_internal (ptr, fmt, arg,
- (flag > 0) ? PRINTF_FORTIFY : 0);
- __no_long_double = 0;
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vasprintf_internal (ptr, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vasprintf_chk)
int
attribute_compat_text_section
__nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vasprintf_chk (ptr, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vasprintf_internal (ptr, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
-__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list arg)
+__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list ap)
{
- int res;
- set_no_long_double ();
- res = __vdprintf_internal (d, fmt, arg, (flag > 0) ? PRINTF_FORTIFY : 0);
- clear_no_long_double ();
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __vdprintf_internal (d, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___vdprintf_chk)
int
attribute_compat_text_section
__nldbl___dprintf_chk (int d, int flag, const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___vdprintf_chk (d, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __vdprintf_internal (d, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
int
attribute_compat_text_section
__nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag,
- const char *fmt, va_list arg)
+ const char *fmt, va_list ap)
{
- int res;
- __no_long_double = 1;
- res = __obstack_vprintf_internal (obstack, fmt, arg,
- (flag > 0) ? PRINTF_FORTIFY : 0);
- __no_long_double = 0;
- return res;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
+
+ return __obstack_vprintf_internal (obstack, fmt, ap, mode);
}
-libc_hidden_def (__nldbl___obstack_vprintf_chk)
int
attribute_compat_text_section
__nldbl___obstack_printf_chk (struct obstack *obstack, int flag,
const char *fmt, ...)
{
- va_list arg;
- int done;
+ va_list ap;
+ int ret;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
- va_start (arg, fmt);
- done = __nldbl___obstack_vprintf_chk (obstack, flag, fmt, arg);
- va_end (arg);
+ va_start (ap, fmt);
+ ret = __obstack_vprintf_internal (obstack, fmt, ap, mode);
+ va_end (ap);
- return done;
+ return ret;
}
extern __typeof (printf_size) __printf_size;
@@ -837,18 +803,28 @@ __nldbl_syslog (int pri, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
- __nldbl___vsyslog_chk (pri, -1, fmt, ap);
+ __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap);
}
+void
+attribute_compat_text_section
+__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
+{
+ __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
+}
+
void
attribute_compat_text_section
__nldbl___syslog_chk (int pri, int flag, const char *fmt, ...)
{
va_list ap;
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
va_start (ap, fmt);
- __nldbl___vsyslog_chk (pri, flag, fmt, ap);
+ __vsyslog_internal (pri, fmt, ap, mode);
va_end(ap);
}
@@ -856,17 +832,11 @@ void
attribute_compat_text_section
__nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
{
- set_no_long_double ();
- __vsyslog_internal (pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0);
- clear_no_long_double ();
-}
-libc_hidden_def (__nldbl___vsyslog_chk)
+ unsigned int mode = PRINTF_LDBL_IS_DBL;
+ if (flag > 0)
+ mode |= PRINTF_FORTIFY;
-void
-attribute_compat_text_section
-__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
-{
- __nldbl___vsyslog_chk (pri, -1, fmt, ap);
+ __vsyslog_internal (pri, fmt, ap, mode);
}
int