glibc/sysdeps/ieee754/ldbl-96
Florian Weimer e88b9f0e5c stdio-common: Convert vfprintf and related functions to buffers
vfprintf is entangled with vfwprintf (of course), __printf_fp,
__printf_fphex, __vstrfmon_l_internal, and the strfrom family of
functions.  The latter use the internal snprintf functionality,
so vsnprintf is converted as well.

The simples conversion is __printf_fphex, followed by
__vstrfmon_l_internal and __printf_fp, and finally
__vfprintf_internal and __vfwprintf_internal.  __vsnprintf_internal
and strfrom* are mostly consuming the new interfaces, so they
are comparatively simple.

__printf_fp is a public symbol, so the FILE *-based interface
had to preserved.

The __printf_fp rewrite does not change the actual binary-to-decimal
conversion algorithm, and digits are still not emitted directly to
the target buffer.  However, the staging buffer now uses bytes
instead of wide characters, and one buffer copy is eliminated.

The changes are at least performance-neutral in my testing.
Floating point printing and snprintf improved measurably, so that
this Lua script

  for i=1,5000000 do
      print(i, i * math.pi)
  end

runs about 5% faster for me.  To preserve fprintf performance for
a simple "%d" format, this commit has some logic changes under
LABEL (unsigned_number) to avoid additional function calls.  There
are certainly some very easy performance improvements here: binary,
octal and hexadecimal formatting can easily avoid the temporary work
buffer (the number of digits can be computed ahead-of-time using one
of the __builtin_clz* built-ins). Decimal formatting can use a
specialized version of _itoa_word for base 10.

The existing (inconsistent) width handling between strfmon and printf
is preserved here.  __print_fp_buffer_1 would have to use
__translated_number_width to achieve ISO conformance for printf.

Test expectations in libio/tst-vtables-common.c are adjusted because
the internal staging buffer merges all virtual function calls into
one.

In general, stack buffer usage is greatly reduced, particularly for
unbuffered input streams.  __printf_fp can still use a large buffer
in binary128 mode for %g, though.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-12-19 18:56:54 +01:00
..
bits Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
include/bits Add canonicalize, canonicalizef, canonicalizel. 2016-10-26 23:14:31 +00:00
e_acoshl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
e_asinl.c Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
e_atanhl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
e_coshl.c Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
e_gammal_r.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
e_hypotl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
e_j0l.c Adjust thresholds in Bessel function implementations (bug 14469). 2020-02-14 14:16:25 +00:00
e_j1l.c Adjust thresholds in Bessel function implementations (bug 14469). 2020-02-14 14:16:25 +00:00
e_jnl.c Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
e_lgammal_r.c Add libm_alias_finite for _finite symbols 2020-01-03 10:02:04 -03:00
e_rem_pio2l.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
e_sinhl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
gamma_product.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
gamma_productl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
k_cosl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
k_sinl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
k_tanl.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
ldbl2mpn.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
lgamma_negl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
lgamma_product.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
lgamma_productl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
Makeconfig add workload traces for cbrtl 2021-05-10 18:45:34 +02:00
Makefile Fix build with GCC 13 _FloatN, _FloatNx built-in functions 2022-10-31 23:20:08 +00:00
math_ldbl.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
math-nan-payload-ldouble.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
mpn2ldbl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
nan-pseudo-number.h Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
printf_fphex.c stdio-common: Convert vfprintf and related functions to buffers 2022-12-19 18:56:54 +01:00
s_asinhl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_cbrtl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_copysignl.c math: Use builtin for ldbl-96 copysign 2022-04-07 14:54:14 -03:00
s_cosl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_daddl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_ddivl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_dfmal.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_dmull.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_dsqrtl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_dsubl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_erfl.c Prefer https to http for gnu.org and fsf.org URLs 2019-09-07 02:43:31 -07:00
s_fabsl.c math: Add math-use-builtins-fabs (BZ#29027) 2022-05-23 17:49:18 -03:00
s_faddl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_fdivl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_ffmal.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_fma.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_fmal.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_fmull.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_frexpl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_fromfpl_main.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_fromfpl.c Use libm_alias_ldouble for ldbl-96 functions. 2017-10-05 21:13:40 +00:00
s_fromfpxl.c Use libm_alias_ldouble for ldbl-96 functions. 2017-10-05 21:13:40 +00:00
s_fsqrtl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_fsubl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_getpayloadl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_iscanonicall.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_issignalingl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_llrintl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_llroundl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_lrintl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_lroundl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_modfl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_nexttoward.c Do not include math-barriers.h in math_private.h. 2018-05-11 15:11:38 +00:00
s_nexttowardf.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_nextupl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_remquol.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_roundevenl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_roundl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_scalblnl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_setpayloadl_main.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_setpayloadl.c Use libm_alias_ldouble for ldbl-96 functions. 2017-10-05 21:13:40 +00:00
s_setpayloadsigl.c Use libm_alias_ldouble for ldbl-96 functions. 2017-10-05 21:13:40 +00:00
s_signbitl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_sincosl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_sinl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_tanhl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_tanl.c Remove "Contributed by" lines 2021-09-03 22:06:44 +05:30
s_totalorderl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_totalordermagl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
s_ufromfpl.c Use libm_alias_ldouble for ldbl-96 functions. 2017-10-05 21:13:40 +00:00
s_ufromfpxl.c Use libm_alias_ldouble for ldbl-96 functions. 2017-10-05 21:13:40 +00:00
strtold_l.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
t_sincosl.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
test-canonical-ldbl-96.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
test-sinl-pseudo.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
test-totalorderl-ldbl-96.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
x2y2m1.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00
x2y2m1l.c Update copyright dates with scripts/update-copyrights 2022-01-01 11:40:24 -08:00