[PATCH 0/4] tools/nolibc: add stdint and more integer types

From: Willy Tarreau
Date: Sat Mar 04 2023 - 09:26:34 EST


Hello Paul,

This first series of patches against nolibc is Vincent Dagonneau's final
work with the kind help from Thomas Wei�chuh who reviewed it.

It adds stdint, the accompanying types (uint64_t etc) and their limits.
Vincent wrote extensive tests for these limits that were added at the
end of the stdlib test series. What's nice is that the definitions are
mostly based on calculations from the compiler's provided limits while
the tests are made against hard-coded hex values, so this may possibly
help spot unexpected surprises with some uncommon compiler settings (or
even bugs in the printf implementation). And given that it required
several round trips to get to work on all archs, I tend to think that
it's quite sensitive to misconfigurations, which is a nice feature.

Running it on x86_64 gives me this:
19 limit_int8_max = 127 [OK]
20 limit_int8_min = -128 [OK]
21 limit_uint8_max = 255 [OK]
22 limit_int16_max = 32767 [OK]
23 limit_int16_min = -32768 [OK]
24 limit_uint16_max = 65535 [OK]
25 limit_int32_max = 2147483647 [OK]
26 limit_int32_min = -2147483648 [OK]
27 limit_uint32_max = 4294967295 [OK]
28 limit_int64_max = 9223372036854775807 [OK]
29 limit_int64_min = -9223372036854775808 [OK]
30 limit_uint64_max = -1 [OK]
31 limit_int_least8_max = 127 [OK]
32 limit_int_least8_min = -128 [OK]
33 limit_uint_least8_max = 255 [OK]
34 limit_int_least16_max = 32767 [OK]
35 limit_int_least16_min = -32768 [OK]
36 limit_uint_least16_max = 65535 [OK]
37 limit_int_least32_max = 2147483647 [OK]
38 limit_int_least32_min = -2147483648 [OK]
39 limit_uint_least32_max = 4294967295 [OK]
40 limit_int_least64_min = -9223372036854775808 [OK]
41 limit_int_least64_max = 9223372036854775807 [OK]
42 limit_uint_least64_max = -1 [OK]
43 limit_int_fast8_max = 127 [OK]
44 limit_int_fast8_min = -128 [OK]
45 limit_uint_fast8_max = 255 [OK]
46 limit_int_fast16_min = -9223372036854775808 [OK]
47 limit_int_fast16_max = 9223372036854775807 [OK]
48 limit_uint_fast16_max = -1 [OK]
49 limit_int_fast32_min = -9223372036854775808 [OK]
50 limit_int_fast32_max = 9223372036854775807 [OK]
51 limit_uint_fast32_max = -1 [OK]
52 limit_int_fast64_min = -9223372036854775808 [OK]
53 limit_int_fast64_max = 9223372036854775807 [OK]
54 limit_uint_fast64_max = -1 [OK]
56 limit_intptr_min = -9223372036854775808 [OK]
57 limit_intptr_max = 9223372036854775807 [OK]
58 limit_uintptr_max = -1 [OK]
59 limit_ptrdiff_min = -9223372036854775808 [OK]
60 limit_ptrdiff_max = 9223372036854775807 [OK]
61 limit_size_max = -1 [OK]

This series was rebased on top of your dev.2023.02.22a branch that was
recently merged into rcu/next. If you want me to rebase it on any other
branch, just let me know. If it could make it for 6.4, it would be great.

Thank you!
Willy

Vincent Dagonneau (4):
tools/nolibc: add stdint.h
tools/nolibc: add integer types and integer limit macros
tools/nolibc: enlarge column width of tests
tools/nolibc: add tests for the integer limits in stdint.h

tools/include/nolibc/Makefile | 4 +-
tools/include/nolibc/std.h | 15 +-
tools/include/nolibc/stdint.h | 99 ++++++++++++
tools/testing/selftests/nolibc/nolibc-test.c | 149 +++++++++++++------
4 files changed, 203 insertions(+), 64 deletions(-)
create mode 100644 tools/include/nolibc/stdint.h

--
2.17.5