mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Use STRFMON_LDBL_IS_DBL instead of __ldbl_is_dbl.
On platforms where long double used to have the same format as double, but later switched to a different format (alpha, s390, sparc, and powerpc), accessing the older behavior is possible and it happens via __nldbl_* functions (not on the API, but accessible from header redirection and from compat symbols). These functions write to the global flag __ldbl_is_dbl, which tells other functions that long double variables should be handled as double. This patch takes the first step towards removing this global flag and creates __vstrfmon_l_internal, which takes an explicit flags parameter. This change arguably makes the generated code slightly worse on architectures where __ldbl_is_dbl is never true; right now, on those architectures, it's a compile-time constant; after this change, the compiler could theoretically prove that __vstrfmon_l_internal was never called with a nonzero flags argument, but it would probably need LTO to do it. This is not performance critical code and I tend to think that the maintainability benefits of removing action at a distance are worth it. However, we _could_ wrap the runtime flag check with a macro that was defined to ignore its argument and always return false on architectures where __ldbl_is_dbl is never true, if people think the codegen benefits are important. Tested for powerpc and powerpc64le.
This commit is contained in:
committed by
Gabriel F. T. Gomes
parent
346ef23f19
commit
c75772e3f0
@ -76,8 +76,8 @@
|
||||
too. Some of the information contradicts the information which can
|
||||
be specified in format string. */
|
||||
ssize_t
|
||||
__vstrfmon_l (char *s, size_t maxsize, locale_t loc, const char *format,
|
||||
va_list ap)
|
||||
__vstrfmon_l_internal (char *s, size_t maxsize, locale_t loc,
|
||||
const char *format, va_list ap, unsigned int flags)
|
||||
{
|
||||
struct __locale_data *current = loc->__locales[LC_MONETARY];
|
||||
_IO_strfile f;
|
||||
@ -268,7 +268,7 @@ __vstrfmon_l (char *s, size_t maxsize, locale_t loc, const char *format,
|
||||
if (*fmt == 'L')
|
||||
{
|
||||
++fmt;
|
||||
if (!__ldbl_is_dbl)
|
||||
if (__glibc_likely ((flags & STRFMON_LDBL_IS_DBL) == 0))
|
||||
is_long_double = 1;
|
||||
}
|
||||
|
||||
@ -608,7 +608,7 @@ ___strfmon_l (char *s, size_t maxsize, locale_t loc, const char *format, ...)
|
||||
|
||||
va_start (ap, format);
|
||||
|
||||
ssize_t res = __vstrfmon_l (s, maxsize, loc, format, ap);
|
||||
ssize_t res = __vstrfmon_l_internal (s, maxsize, loc, format, ap, 0);
|
||||
|
||||
va_end (ap);
|
||||
|
||||
|
Reference in New Issue
Block a user