casaroli opened a new pull request, #21493: URL: https://github.com/apache/nuttx/pull/21493
depends-on: apache/nuttx/pull/21474 This branch holds the 19 commits of #21474 and 10 commits of its own, because these commits change the same code. **Review only the last 10 commits.** It stays a draft until #21474 merges. Part of #21467, step 2. ## Summary #21474 makes `printf` safe for correct calls and adds a few bytes. This PR lets a board take bytes out again, and gives three profiles: - **Default:** today's features. It is the default, and existing configs do not change. - **Minimal:** removes what a small board can do without. - **Full:** turns on floating point, numbered arguments and locale. Each option has its own prompt, so Minimal or Default can add or remove one feature at a time. A removed conversion still reads its argument at the right size and prints `?`, so the next conversion stays correct. | Option | Minimal | Default | Full | With the option off | |---|---|---|---|---| | `LIBC_FLOATINGPOINT` | off | as today | on | `%f`: `?` | | `LIBC_NUMBERED_ARGS` | off | off | on | as today | | `LIBC_LOCALE` | off | off | on | as today | | `LIBC_PRINTF_LONG_LONG` | on with `SYSLOG_TIMESTAMP` or `FS_PROCFS`, else off | on | on | `%lld`, `%jd`: `?` | | `LIBC_PRINTF_ALT_FORM` | off | on | on | `%#x` of 255 prints `ff`; `%p` keeps `0x` | | `LIBC_PRINTF_INT_PRECISION` | off | on | on | `%.3d`: `?`; `%.3s` stays | | `STREAM_OUT_BUFFER_SIZE` | 0 | 64 | 64 | each stream call of `dprintf()` is one `write()` | | `LIBC_PRINTF_OCTAL` | on | on | on | `%o`: `?` | | `LIBC_PRINTF_LEFT_JUSTIFY` | on | on | on | `%-5d` pads on the left | | `LIBC_PRINTF_SHORT` | on | on | on | `%hd`, `%hhx`: `?` | The 64-bit option stays on in Minimal with `SYSLOG_TIMESTAMP` or `FS_PROCFS`, because the log timestamps and `/proc` print `time_t` and `uint64_t`. Without them, `time` and `ulimit` in nsh print `?`. The last commit reads a `long` as an `int` where they have the same size. It has no option and does not change the output. ## Impact Default: no feature changes. 90 configs, on arm, arm64, risc-v, xtensa, sim and avr, have the same `savedefconfig` as #21474; their `.config` has only the new `LIBC_PRINTF_*` lines. No ABI change. Not a breaking change. No architecture code. Flat, protected and kernel builds. Image text against master, float and numbered arguments off: | | Cortex-M0 | Cortex-M3 | rv32 | arm64 | |---|---:|---:|---:|---:| | Minimal, `FS_PROCFS` and `SYSLOG_TIMESTAMP` off | -880 | -456 | -362 | -236 | | Minimal, `FS_PROCFS` on | -288 | -324 | -224 | -236 | Boards: `nucleo-f072rb:nsh`, `nucleo-f103rb:nsh`, `rv-virt:nsh`, `qemu-armv8a:nsh`. `FS_PROCFS` is on in the defconfig of all but the Cortex-M3 board. Image text with each board's defaults; rv32 and arm64 have float on by default: | | Cortex-M0 | Cortex-M3 | rv32 | arm64 | |---|---:|---:|---:|---:| | master | 46,668 | 34,320 | 230,006 | 327,968 | | Minimal | 46,380 | 33,864 | 227,990 | 325,588 | | Default | 46,736 | 34,444 | 230,442 | 328,304 | | Full | 57,872 | 39,508 | 231,698 | 330,068 | One option off from Default, float and numbered arguments off: | | Cortex-M0 | Cortex-M3 | rv32 | arm64 | |---|---:|---:|---:|---:| | 64-bit integers | -624 | -204 | -130 | 0 | | `#` | -112 | -160 | -114 | -152 | | integer precision | -104 | -176 | -48 | -40 | | `%h`, `%hh` | -128 | -172 | -52 | -88 | | `%o` | -52 | -92 | -50 | -64 | | `-` | -72 | -96 | -60 | -116 | | no `dprintf()` buffer | -148 | -160 | -202 | -284 | With #20996 merged, 64-bit integers off saves less, because libgcc no longer has the division: -252, -200, -168, 0. This PR has one line for that case, and it does nothing without #20996. Documentation: no page describes these options. The Kconfig help has the text, and step 5 of #21467 is the documentation. ## Testing - ostest and a test program for these cases, exit 0 and 0 failures: `rv-virt:nsh` Minimal with 64-bit on and off, `qemu-armv8a:knsh` Minimal, and both boards with Full. - Host harness under ASan and UBSan, 34 builds: each profile, each option added to Minimal or removed from Default. 0 reports, 0 timeouts, for correct and wrong usage. - Builds with `EXTRAFLAGS="-Wno-cpp -Werror"`, each of Minimal, Default and Full: `nucleo-f072rb:nsh`, `nucleo-f103rb:nsh`, `rv-virt:nsh`, `qemu-armv8a:nsh`, `mps2-an500:knsh` (protected), `qemu-armv8a:knsh`, `rv-virt:knsh` (kernel). Each single option off on the four flat boards. Default, Full, the harness and the single-option builds ran one rebuild before this head. The later commits are a style fix, the Kconfig default of the 64-bit option, and one line that has no effect without #20996. Not run: Cortex-M0 at run time; a protected or kernel build of 32-bit Minimal with 64-bit off on this head; the speed of `dprintf()` with no buffer; a size row with `SYSLOG_TIMESTAMP` on; a CMake build. `tools/checkpatch.sh -c -u -m -g` passes. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
