From: Zack Weinberg <zackw@panix.com>
To: libc-alpha@sourceware.org
Subject: [PATCH 8/9] Use PRINTF_LDBL_IS_DBL instead of __ldbl_is_dbl.
Date: Wed, 07 Mar 2018 19:32:00 -0000 [thread overview]
Message-ID: <20180307193205.4751-9-zackw@panix.com> (raw)
In-Reply-To: <20180307193205.4751-1-zackw@panix.com>
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.
* 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
(__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. Remove libc_hidden_proto and libc_hidden_def.
---
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 | 5 -
sysdeps/ieee754/ldbl-opt/nldbl-compat.c | 472 ++++++++++++++++---------------
5 files changed, 238 insertions(+), 246 deletions(-)
diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
index e2f44b74f3..2d9016e83b 100644
--- a/stdio-common/vfprintf-internal.c
+++ b/stdio-common/vfprintf-internal.c
@@ -1282,10 +1282,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;
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
diff --git a/sysdeps/ieee754/ldbl-opt/Makefile b/sysdeps/ieee754/ldbl-opt/Makefile
index 2340e4ce29..f23c6312ed 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 \
diff --git a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
index ee70d085fd..2b8f3e3c10 100644
--- a/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
+++ b/sysdeps/ieee754/ldbl-opt/math_ldbl_opt.h
@@ -42,9 +42,4 @@
#ifndef __ASSEMBLER__
# include <math.h>
# include <math_private.h>
-
-/* 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
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
index f29c28e888..e9cb5d32de 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -44,7 +44,6 @@ 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)
@@ -55,17 +54,6 @@ 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
@@ -75,14 +63,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)
@@ -90,28 +78,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)
@@ -119,28 +107,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)
@@ -148,14 +136,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)
@@ -163,11 +151,7 @@ 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)
@@ -176,11 +160,7 @@ 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)
@@ -191,11 +171,7 @@ 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)
@@ -203,63 +179,55 @@ 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)
@@ -267,11 +235,7 @@ 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)
@@ -279,7 +243,7 @@ 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
@@ -287,11 +251,7 @@ 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)
@@ -301,11 +261,7 @@ 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)
@@ -313,21 +269,21 @@ 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_28)
@@ -490,42 +446,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
@@ -533,54 +498,72 @@ 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)
@@ -588,11 +571,11 @@ 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)
@@ -600,7 +583,11 @@ 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
@@ -611,12 +598,11 @@ __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)
@@ -628,12 +614,11 @@ __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)
@@ -645,12 +630,11 @@ __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)
@@ -658,33 +642,39 @@ 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)
@@ -692,25 +682,28 @@ 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)
@@ -718,27 +711,29 @@ 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)
@@ -747,14 +742,17 @@ 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;
@@ -836,18 +834,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);
}
@@ -855,17 +863,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
--
2.16.2
next prev parent reply other threads:[~2018-03-07 19:32 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-07 19:32 [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-07 19:32 ` Zack Weinberg [this message]
2018-03-07 19:32 ` [PATCH 3/9] Use SCANF_ISOC99_A instead of _IO_FLAGS2_SCANF_STD Zack Weinberg
2018-03-26 15:35 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 5/9] Add __v*printf_internal with flags arguments Zack Weinberg
2018-03-26 15:41 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 1/9] Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-12 20:36 ` Adhemerval Zanella
2018-03-12 21:11 ` Zack Weinberg
2018-03-13 11:45 ` Adhemerval Zanella
2018-03-26 15:17 ` Gabriel F. T. Gomes
2018-03-26 15:40 ` Zack Weinberg
2018-03-26 15:52 ` Gabriel F. T. Gomes
2018-03-07 19:32 ` [PATCH 6/9] Add __vsyslog_internal, with same flags as __v*printf_internal Zack Weinberg
2018-03-13 11:59 ` Florian Weimer
2018-03-13 12:39 ` Zack Weinberg
2018-03-13 12:43 ` Florian Weimer
2018-03-13 13:37 ` Zack Weinberg
2018-03-13 13:50 ` Florian Weimer
2018-03-13 14:11 ` Zack Weinberg
2018-03-13 14:13 ` Florian Weimer
2018-03-07 19:32 ` [PATCH 2/9] Add __vfscanf_internal and __vfwscanf_internal with flags arguments Zack Weinberg
2018-03-13 12:35 ` Adhemerval Zanella
2018-06-29 14:04 ` Florian Weimer
2018-03-26 15:28 ` Gabriel F. T. Gomes
2018-06-29 14:12 ` Florian Weimer
2018-06-29 14:24 ` Florian Weimer
2018-06-29 14:29 ` Florian Weimer
2018-03-07 19:32 ` [PATCH 4/9] Use SCANF_LDBL_IS_DBL instead of __ldbl_is_dbl Zack Weinberg
2018-03-14 12:22 ` Florian Weimer
2018-03-26 15:36 ` Gabriel F. T. Gomes
2018-03-07 19:51 ` [PATCH 9/9] Post-cleanup: don't include math.h/math_private.h in math_ldbl_opt.h Zack Weinberg
2018-03-07 19:51 ` [PATCH 7/9] Use PRINTF_FORTIFY instead of _IO_FLAGS2_FORTIFY Zack Weinberg
2018-03-12 15:29 ` [PATCH 0/9] Use more flags parameters instead of global bits in stdio Zack Weinberg
2018-03-26 15:16 ` Gabriel F. T. Gomes
2018-03-26 15:47 ` Zack Weinberg
2018-06-27 15:50 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180307193205.4751-9-zackw@panix.com \
--to=zackw@panix.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).