about summary refs log tree commit diff
path: root/src/signal/sigrtmax.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2024-08-26 16:01:11 -0400
committerRich Felker <dalias@aerifal.cx>2024-08-26 16:01:11 -0400
commit572a2e2eb91f00f2f25d301cfb50f435e7ae16b3 (patch)
tree08c826277b16d6e70b983f9e9b8cc103eeec23d1 /src/signal/sigrtmax.c
parentc94a0c16f08894ce3be6dafb0fe80baa77a6ff2a (diff)
downloadmusl-572a2e2eb91f00f2f25d301cfb50f435e7ae16b3.tar.gz
musl-572a2e2eb91f00f2f25d301cfb50f435e7ae16b3.tar.xz
musl-572a2e2eb91f00f2f25d301cfb50f435e7ae16b3.zip
printf: drastically reduce stack usage without [long] double args
internally, printf always works with the maximal-size supported
integer and floating point formats. however, the space needed to
format a floating point number is proportional to the mantissa and
exponent ranges. on archs where long double is larger than double,
knowing that the actual value fit in double allows us to use a much
smaller buffer, roughly 1/16 the size.

as a bonus, making the working buffer a VLA whose dimension depends on
the format specifier prevents the compiler from lifting the stack
adjustment to the top of printf_core. this makes it so printf calls
without floating point arguments do not waste even the smaller amount
of stack space needed for double, making it much more practical to use
printf in tightly stack-constrained environments.
Diffstat (limited to 'src/signal/sigrtmax.c')
0 files changed, 0 insertions, 0 deletions