| From: |
| david.laight.linux-AT-gmail.com |
| To: |
| Willy Tarreau <w-AT-1wt.eu>, Thomas Weißschuh <linux-AT-weissschuh.net>, linux-kernel-AT-vger.kernel.org, Cheng Li <lechain-AT-gmail.com> |
| Subject: |
| [PATCH next 00/12] tools/nolibc: Enhance printf() |
| Date: |
| Tue, 03 Feb 2026 10:29:48 +0000 |
| Message-ID: |
| <20260203103000.20206-1-david.laight.linux@gmail.com> |
| Cc: |
| David Laight <david.laight.linux-AT-gmail.com> |
| Archive-link: |
| Article |
From: David Laight <david.laight.linux@gmail.com>
Update printf() so that it handles almost all the non-fp formats.
In particular:
- Left alignment.
- Zero padding.
- Field precision.
- Variable field width and precision.
- Width modifiers q, L, t and z.
- Conversion specifiers i and X (X generates lower case).
About the only thing that is missing is octal.
The tests are updated to match.
There is a slight increase in code size, but it is minimalised
by the the heavy use of bit-pattern matches.
vfprintf() is modified to buffer data for each call and do a single
write system call at the end.
This improves performance somewhat, but is actually most useful when
using strace.
David Laight (12):
tools/nolibc/printf: Move snprintf length check to callback
tools/nolibc/printf: Add buffering to vfprintf() callback.
tools/nolibc: change printf() to output pad in 16 byte chunks
selftests/nolibc: Improve reporting of vfprintf() errors
tools/nolibc/stdio: Simplify __nolibc_printf()
tools/nolibc: Add support for left alignment and %[tzq]d" to printf
tools/nolibc: printf() prepend the sign after a numeric conversion
tools/nolibc: use bit-match to detect valid printf conversion
character
tools/nolibc: add precision and zero padding to printf()
tools/nolibc: Use bit-pattern for printf integral formats
selftests/nolibc: Increase coverage of printf format tests
selftests/nolibc: Use printf("%.*s", n, "") to align output
tools/include/nolibc/stdio.h | 396 +++++++++++++------
tools/testing/selftests/nolibc/nolibc-test.c | 96 +++--
2 files changed, 336 insertions(+), 156 deletions(-)
--
2.39.5