new facility for formatted output
Peter A. Bigot
With the merge of https://github.com/zephyrproject-rtos/zephyr/pull/29876 Zephyr printk, shell_printf, minimal libc sprintf, and some other in-tree facilities use a common formatting functionality that supports almost everything in C18 *printf, with Kconfig options to reduce the code size impact based on controlling feature availability.
That PR added a C99 stdio value formatter capability named cbprintf() (plus related variants) where generated text is emitted through a callback. This allows generation of arbitrarily long output without a buffer, functionality that is core to printk, logging, and other system and application needs.
The formater supports most C99 specifications, excluding:
Kconfig options allow disabling features like floating-point conversion if they are not necessary.
Benefits include:No more inconsistencies between printk, logging, and shell formatting capabilities.
You may see either an increase or a decrease in code size depending on what your application uses. Some code size can be reduced by switching in-tree use of snprintf to snprintfcb to avoid pulling in libc formatters.
I expect there'll be a burn-in period while we identify Kconfig settings that have to change to maintain compatibility. Please mention me (@pabigot) in any issues or slack questions that you have about this.