Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl.

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.
This commit is contained in:
Zack Weinberg 2018-03-07 14:32:04 -05:00 committed by Gabriel F. T. Gomes
parent 4e2f43f842
commit 35caceb145
6 changed files with 280 additions and 280 deletions

View File

@ -1,3 +1,45 @@
2018-12-05 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.
2018-12-05 Zack Weinberg <zackw@panix.com> 2018-12-05 Zack Weinberg <zackw@panix.com>
Gabriel F. T. Gomes <gabriel@inconstante.eti.br> Gabriel F. T. Gomes <gabriel@inconstante.eti.br>

View File

@ -1280,10 +1280,6 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap, unsigned int mode_flags)
0 if unknown. */ 0 if unknown. */
int readonly_format = 0; int readonly_format = 0;
/* Temporarily honor environmental settings. */
if (__ldbl_is_dbl)
mode_flags |= PRINTF_LDBL_IS_DBL;
/* Orient the stream. */ /* Orient the stream. */
#ifdef ORIENT #ifdef ORIENT
ORIENT; ORIENT;

View File

@ -15,4 +15,3 @@
#define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname) #define ldbl_weak_alias(name, aliasname) weak_alias (name, aliasname)
#define ldbl_compat_symbol(lib, local, symbol, version) \ #define ldbl_compat_symbol(lib, local, symbol, version) \
compat_symbol (lib, local, symbol, version) compat_symbol (lib, local, symbol, version)
#define __ldbl_is_dbl 0

View File

@ -8,7 +8,7 @@ endif
ifeq ($(subdir),math) ifeq ($(subdir),math)
libm-routines += s_nexttowardfd libm-routines += s_nexttowardfd
routines += math_ldbl_opt nldbl-compat routines += nldbl-compat
extra-libs += libnldbl extra-libs += libnldbl
libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \ libnldbl-calls = asprintf dprintf fprintf fscanf fwprintf fwscanf iovfscanf \

View File

@ -40,10 +40,3 @@
weak_alias (local, symbol) weak_alias (local, symbol)
# endif # endif
#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

View File

@ -30,43 +30,15 @@
#include "nldbl-compat.h" #include "nldbl-compat.h"
libc_hidden_proto (__nldbl_vfprintf)
libc_hidden_proto (__nldbl_vsscanf) libc_hidden_proto (__nldbl_vsscanf)
libc_hidden_proto (__nldbl_vsprintf)
libc_hidden_proto (__nldbl_vfscanf) libc_hidden_proto (__nldbl_vfscanf)
libc_hidden_proto (__nldbl_vfwscanf) libc_hidden_proto (__nldbl_vfwscanf)
libc_hidden_proto (__nldbl_vdprintf)
libc_hidden_proto (__nldbl_vswscanf) 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_vsscanf)
libc_hidden_proto (__nldbl___isoc99_vfscanf) libc_hidden_proto (__nldbl___isoc99_vfscanf)
libc_hidden_proto (__nldbl___isoc99_vswscanf) libc_hidden_proto (__nldbl___isoc99_vswscanf)
libc_hidden_proto (__nldbl___isoc99_vfwscanf) 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. /* Compatibility with IEEE double as long double.
IEEE quad long double is used by default for most programs, so 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 we don't need to split this into one file per function for the
@ -76,14 +48,14 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___asprintf (char **string_ptr, const char *fmt, ...) __nldbl___asprintf (char **string_ptr, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vasprintf (string_ptr, fmt, arg); ret = __vasprintf_internal (string_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
weak_alias (__nldbl___asprintf, __nldbl_asprintf) weak_alias (__nldbl___asprintf, __nldbl_asprintf)
@ -91,28 +63,28 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl_dprintf (int d, const char *fmt, ...) __nldbl_dprintf (int d, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vdprintf (d, fmt, arg); ret = __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_fprintf (FILE *stream, const char *fmt, ...) __nldbl_fprintf (FILE *stream, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfprintf (stream, fmt, arg); ret = __vfprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
weak_alias (__nldbl_fprintf, __nldbl__IO_fprintf) weak_alias (__nldbl_fprintf, __nldbl__IO_fprintf)
@ -120,28 +92,28 @@ int
attribute_compat_text_section weak_function attribute_compat_text_section weak_function
__nldbl_fwprintf (FILE *stream, const wchar_t *fmt, ...) __nldbl_fwprintf (FILE *stream, const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfwprintf (stream, fmt, arg); ret = __vfwprintf_internal (stream, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_printf (const char *fmt, ...) __nldbl_printf (const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfprintf (stdout, fmt, arg); ret = __vfprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
strong_alias (__nldbl_printf, __nldbl__IO_printf) strong_alias (__nldbl_printf, __nldbl__IO_printf)
@ -149,14 +121,14 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl_sprintf (char *s, const char *fmt, ...) __nldbl_sprintf (char *s, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vsprintf (s, fmt, arg); ret = __vsprintf_internal (s, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
strong_alias (__nldbl_sprintf, __nldbl__IO_sprintf) strong_alias (__nldbl_sprintf, __nldbl__IO_sprintf)
@ -164,123 +136,93 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl_vfprintf (FILE *s, const char *fmt, va_list ap) __nldbl_vfprintf (FILE *s, const char *fmt, va_list ap)
{ {
int done; return __vfprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
set_no_long_double ();
done = __vfprintf_internal (s, fmt, ap, 0);
clear_no_long_double ();
return done;
} }
libc_hidden_def (__nldbl_vfprintf)
strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf) strong_alias (__nldbl_vfprintf, __nldbl__IO_vfprintf)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vsprintf (char *string, const char *fmt, va_list ap) __nldbl___vsprintf (char *string, const char *fmt, va_list ap)
{ {
int done; return __vsprintf_internal (string, -1, fmt, ap, PRINTF_LDBL_IS_DBL);
__no_long_double = 1;
done = __vsprintf_internal (string, -1, fmt, ap, 0);
__no_long_double = 0;
return done;
} }
strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf) strong_alias (__nldbl___vsprintf, __nldbl__IO_vsprintf)
weak_alias (__nldbl___vsprintf, __nldbl_vsprintf) weak_alias (__nldbl___vsprintf, __nldbl_vsprintf)
libc_hidden_def (__nldbl_vsprintf)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt, __nldbl_obstack_vprintf (struct obstack *obstack, const char *fmt,
va_list ap) va_list ap)
{ {
int done; return __obstack_vprintf_internal (obstack, fmt, ap, PRINTF_LDBL_IS_DBL);
__no_long_double = 1;
done = __obstack_vprintf_internal (obstack, fmt, ap, 0);
__no_long_double = 0;
return done;
} }
libc_hidden_def (__nldbl_obstack_vprintf)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_obstack_printf (struct obstack *obstack, const char *fmt, ...) __nldbl_obstack_printf (struct obstack *obstack, const char *fmt, ...)
{ {
int result; int ret;
va_list ap; va_list ap;
va_start (ap, fmt); 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); va_end (ap);
return result; return ret;
} }
int int
attribute_compat_text_section weak_function attribute_compat_text_section weak_function
__nldbl_snprintf (char *s, size_t maxlen, const char *fmt, ...) __nldbl_snprintf (char *s, size_t maxlen, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vsnprintf (s, maxlen, fmt, arg); ret = __vsnprintf_internal (s, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_swprintf (wchar_t *s, size_t n, const wchar_t *fmt, ...) __nldbl_swprintf (wchar_t *s, size_t n, const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vswprintf (s, n, fmt, arg); ret = __vswprintf_internal (s, n, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section weak_function attribute_compat_text_section weak_function
__nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap) __nldbl_vasprintf (char **result_ptr, const char *fmt, va_list ap)
{ {
int res; return __vasprintf_internal (result_ptr, fmt, ap, PRINTF_LDBL_IS_DBL);
__no_long_double = 1;
res = __vasprintf_internal (result_ptr, fmt, ap, 0);
__no_long_double = 0;
return res;
} }
libc_hidden_def (__nldbl_vasprintf)
int int
attribute_compat_text_section 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; return __vdprintf_internal (d, fmt, ap, PRINTF_LDBL_IS_DBL);
set_no_long_double ();
res = __vdprintf_internal (d, fmt, arg, 0);
clear_no_long_double ();
return res;
} }
libc_hidden_def (__nldbl_vdprintf)
int int
attribute_compat_text_section weak_function attribute_compat_text_section weak_function
__nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap) __nldbl_vfwprintf (FILE *s, const wchar_t *fmt, va_list ap)
{ {
int res; return __vfwprintf_internal (s, fmt, ap, PRINTF_LDBL_IS_DBL);
set_no_long_double ();
res = __vfwprintf_internal (s, fmt, ap, 0);
clear_no_long_double ();
return res;
} }
libc_hidden_def (__nldbl_vfwprintf)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_vprintf (const char *fmt, va_list ap) __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 int
@ -288,13 +230,8 @@ attribute_compat_text_section
__nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt, __nldbl_vsnprintf (char *string, size_t maxlen, const char *fmt,
va_list ap) va_list ap)
{ {
int res; return __vsnprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
__no_long_double = 1;
res = __vsnprintf_internal (string, maxlen, fmt, ap, 0);
__no_long_double = 0;
return res;
} }
libc_hidden_def (__nldbl_vsnprintf)
weak_alias (__nldbl_vsnprintf, __nldbl___vsnprintf) weak_alias (__nldbl_vsnprintf, __nldbl___vsnprintf)
int int
@ -302,33 +239,28 @@ attribute_compat_text_section weak_function
__nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt, __nldbl_vswprintf (wchar_t *string, size_t maxlen, const wchar_t *fmt,
va_list ap) va_list ap)
{ {
int res; return __vswprintf_internal (string, maxlen, fmt, ap, PRINTF_LDBL_IS_DBL);
__no_long_double = 1;
res = __vswprintf_internal (string, maxlen, fmt, ap, 0);
__no_long_double = 0;
return res;
} }
libc_hidden_def (__nldbl_vswprintf)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl_vwprintf (const wchar_t *fmt, va_list ap) __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 int
attribute_compat_text_section attribute_compat_text_section
__nldbl_wprintf (const wchar_t *fmt, ...) __nldbl_wprintf (const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl_vfwprintf (stdout, fmt, arg); ret = __vfwprintf_internal (stdout, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (arg); va_end (ap);
return done; return ret;
} }
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29) #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_29)
@ -491,42 +423,51 @@ int
attribute_compat_text_section attribute_compat_text_section
__nldbl___fprintf_chk (FILE *stream, int flag, const char *fmt, ...) __nldbl___fprintf_chk (FILE *stream, int flag, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___vfprintf_chk (stream, flag, fmt, arg); ret = __vfprintf_internal (stream, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___fwprintf_chk (FILE *stream, int flag, const wchar_t *fmt, ...) __nldbl___fwprintf_chk (FILE *stream, int flag, const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___vfwprintf_chk (stream, flag, fmt, arg); ret = __vfwprintf_internal (stream, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___printf_chk (int flag, const char *fmt, ...) __nldbl___printf_chk (int flag, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___vfprintf_chk (stdout, flag, fmt, arg); ret = __vfprintf_internal (stdout, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
@ -534,74 +475,94 @@ attribute_compat_text_section
__nldbl___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen, __nldbl___snprintf_chk (char *s, size_t maxlen, int flag, size_t slen,
const char *fmt, ...) const char *fmt, ...)
{ {
va_list arg; if (__glibc_unlikely (slen < maxlen))
int done; __chk_fail ();
va_start (arg, fmt); va_list ap;
done = __nldbl___vsnprintf_chk (s, maxlen, flag, slen, fmt, arg); int ret;
va_end (arg); 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 int
attribute_compat_text_section attribute_compat_text_section
__nldbl___sprintf_chk (char *s, int flag, size_t slen, const char *fmt, ...) __nldbl___sprintf_chk (char *s, int flag, size_t slen, const char *fmt, ...)
{ {
va_list arg; if (slen == 0)
int done; __chk_fail ();
va_start (arg, fmt); va_list ap;
done = __nldbl___vsprintf_chk (s, flag, slen, fmt, arg); int ret;
va_end (arg); unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return done; va_start (ap, fmt);
ret = __vsprintf_internal (s, slen, fmt, ap, mode);
va_end (ap);
return ret;
} }
int int
attribute_compat_text_section 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, ...) const wchar_t *fmt, ...)
{ {
va_list arg; if (__glibc_unlikely (slen < maxlen))
int done; __chk_fail ();
va_start (arg, fmt); va_list ap;
done = __nldbl___vswprintf_chk (s, n, flag, slen, fmt, arg); int ret;
va_end (arg); unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
return done; va_start (ap, fmt);
ret = __vswprintf_internal (s, maxlen, fmt, ap, mode);
va_end (ap);
return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vfprintf_chk (FILE *s, int flag, const char *fmt, va_list ap) __nldbl___vfprintf_chk (FILE *s, int flag, const char *fmt, va_list ap)
{ {
int res; unsigned int mode = PRINTF_LDBL_IS_DBL;
set_no_long_double (); if (flag > 0)
res = __vfprintf_internal (s, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); mode |= PRINTF_FORTIFY;
clear_no_long_double ();
return res; return __vfprintf_internal (s, fmt, ap, mode);
} }
libc_hidden_def (__nldbl___vfprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vfwprintf_chk (FILE *s, int flag, const wchar_t *fmt, va_list ap) __nldbl___vfwprintf_chk (FILE *s, int flag, const wchar_t *fmt, va_list ap)
{ {
int res; unsigned int mode = PRINTF_LDBL_IS_DBL;
set_no_long_double (); if (flag > 0)
res = __vfwprintf_internal (s, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); mode |= PRINTF_FORTIFY;
clear_no_long_double ();
return res; return __vfwprintf_internal (s, fmt, ap, mode);
} }
libc_hidden_def (__nldbl___vfwprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vprintf_chk (int flag, const char *fmt, va_list ap) __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 int
@ -612,14 +573,12 @@ __nldbl___vsnprintf_chk (char *string, size_t maxlen, int flag, size_t slen,
if (__glibc_unlikely (slen < maxlen)) if (__glibc_unlikely (slen < maxlen))
__chk_fail (); __chk_fail ();
int res; unsigned int mode = PRINTF_LDBL_IS_DBL;
__no_long_double = 1; if (flag > 0)
res = __vsnprintf_internal (string, maxlen, fmt, ap, mode |= PRINTF_FORTIFY;
(flag > 0) ? PRINTF_FORTIFY : 0);
__no_long_double = 0; return __vsnprintf_internal (string, maxlen, fmt, ap, mode);
return res;
} }
libc_hidden_def (__nldbl___vsnprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
@ -629,14 +588,12 @@ __nldbl___vsprintf_chk (char *string, int flag, size_t slen, const char *fmt,
if (slen == 0) if (slen == 0)
__chk_fail (); __chk_fail ();
int res; unsigned int mode = PRINTF_LDBL_IS_DBL;
__no_long_double = 1; if (flag > 0)
res = __vsprintf_internal (string, slen, fmt, ap, mode |= PRINTF_FORTIFY;
(flag > 0) ? PRINTF_FORTIFY : 0);
__no_long_double = 0; return __vsprintf_internal (string, slen, fmt, ap, mode);
return res;
} }
libc_hidden_def (__nldbl___vsprintf_chk)
int int
attribute_compat_text_section 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)) if (__glibc_unlikely (slen < maxlen))
__chk_fail (); __chk_fail ();
int res; unsigned int mode = PRINTF_LDBL_IS_DBL;
__no_long_double = 1; if (flag > 0)
res = __vswprintf_internal (string, maxlen, fmt, ap, mode |= PRINTF_FORTIFY;
(flag > 0) ? PRINTF_FORTIFY : 0);
__no_long_double = 0; return __vswprintf_internal (string, maxlen, fmt, ap, mode);
return res;
} }
libc_hidden_def (__nldbl___vswprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___vwprintf_chk (int flag, const wchar_t *fmt, va_list ap) __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 int
attribute_compat_text_section attribute_compat_text_section
__nldbl___wprintf_chk (int flag, const wchar_t *fmt, ...) __nldbl___wprintf_chk (int flag, const wchar_t *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___vfwprintf_chk (stdout, flag, fmt, arg); ret = __vfwprintf_internal (stdout, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section 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; unsigned int mode = PRINTF_LDBL_IS_DBL;
__no_long_double = 1; if (flag > 0)
res = __vasprintf_internal (ptr, fmt, arg, mode |= PRINTF_FORTIFY;
(flag > 0) ? PRINTF_FORTIFY : 0);
__no_long_double = 0; return __vasprintf_internal (ptr, fmt, ap, mode);
return res;
} }
libc_hidden_def (__nldbl___vasprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...) __nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___vasprintf_chk (ptr, flag, fmt, arg); ret = __vasprintf_internal (ptr, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section 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; unsigned int mode = PRINTF_LDBL_IS_DBL;
set_no_long_double (); if (flag > 0)
res = __vdprintf_internal (d, fmt, arg, (flag > 0) ? PRINTF_FORTIFY : 0); mode |= PRINTF_FORTIFY;
clear_no_long_double ();
return res; return __vdprintf_internal (d, fmt, ap, mode);
} }
libc_hidden_def (__nldbl___vdprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___dprintf_chk (int d, int flag, const char *fmt, ...) __nldbl___dprintf_chk (int d, int flag, const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___vdprintf_chk (d, flag, fmt, arg); ret = __vdprintf_internal (d, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag, __nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag,
const char *fmt, va_list arg) const char *fmt, va_list ap)
{ {
int res; unsigned int mode = PRINTF_LDBL_IS_DBL;
__no_long_double = 1; if (flag > 0)
res = __obstack_vprintf_internal (obstack, fmt, arg, mode |= PRINTF_FORTIFY;
(flag > 0) ? PRINTF_FORTIFY : 0);
__no_long_double = 0; return __obstack_vprintf_internal (obstack, fmt, ap, mode);
return res;
} }
libc_hidden_def (__nldbl___obstack_vprintf_chk)
int int
attribute_compat_text_section attribute_compat_text_section
__nldbl___obstack_printf_chk (struct obstack *obstack, int flag, __nldbl___obstack_printf_chk (struct obstack *obstack, int flag,
const char *fmt, ...) const char *fmt, ...)
{ {
va_list arg; va_list ap;
int done; int ret;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (arg, fmt); va_start (ap, fmt);
done = __nldbl___obstack_vprintf_chk (obstack, flag, fmt, arg); ret = __obstack_vprintf_internal (obstack, fmt, ap, mode);
va_end (arg); va_end (ap);
return done; return ret;
} }
extern __typeof (printf_size) __printf_size; extern __typeof (printf_size) __printf_size;
@ -837,18 +803,28 @@ __nldbl_syslog (int pri, const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start (ap, fmt); va_start (ap, fmt);
__nldbl___vsyslog_chk (pri, -1, fmt, ap); __vsyslog_internal (pri, fmt, ap, PRINTF_LDBL_IS_DBL);
va_end (ap); 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 void
attribute_compat_text_section attribute_compat_text_section
__nldbl___syslog_chk (int pri, int flag, const char *fmt, ...) __nldbl___syslog_chk (int pri, int flag, const char *fmt, ...)
{ {
va_list ap; va_list ap;
unsigned int mode = PRINTF_LDBL_IS_DBL;
if (flag > 0)
mode |= PRINTF_FORTIFY;
va_start (ap, fmt); va_start (ap, fmt);
__nldbl___vsyslog_chk (pri, flag, fmt, ap); __vsyslog_internal (pri, fmt, ap, mode);
va_end(ap); va_end(ap);
} }
@ -856,17 +832,11 @@ void
attribute_compat_text_section attribute_compat_text_section
__nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap) __nldbl___vsyslog_chk (int pri, int flag, const char *fmt, va_list ap)
{ {
set_no_long_double (); unsigned int mode = PRINTF_LDBL_IS_DBL;
__vsyslog_internal (pri, fmt, ap, (flag > 0) ? PRINTF_FORTIFY : 0); if (flag > 0)
clear_no_long_double (); mode |= PRINTF_FORTIFY;
}
libc_hidden_def (__nldbl___vsyslog_chk)
void __vsyslog_internal (pri, fmt, ap, mode);
attribute_compat_text_section
__nldbl_vsyslog (int pri, const char *fmt, va_list ap)
{
__nldbl___vsyslog_chk (pri, -1, fmt, ap);
} }
int int