Skip to content

nolibc: update to resync with out-of-tree project

Willy Tarreau lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest42 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/42tools/nolibc: use pselect6 on RISCVtools/include/nolibc/nolibc.h+3 -00 replies
2/42tools/nolibc: guard the main file against multiple inclusiontools/include/nolibc/nolibc.h+4 -00 replies
3/42tools/nolibc/std: move the standard type definitions to std.htools/include/nolibc/nolibc.h tools/include/nolibc/std.h+54 -370 replies
4/42tools/nolibc/types: split syscall-specific definitions into their own filestools/include/nolibc/nolibc.h tools/include/nolibc/types.h+135 -1080 replies
5/42tools/nolibc/arch: split arch-specific code into individual filestools/include/nolibc/arch-aarch64.h tools/include/nolibc/arch-arm.h tools/include/nolibc/arch-i386.h +5 more+1266 -11860 replies
6/42tools/nolibc/sys: split the syscall definitions into their own filetools/include/nolibc/nolibc.h tools/include/nolibc/sys.h+1192 -9620 replies
7/42tools/nolibc/stdlib: extract the stdlib-specific functions to their own filetools/include/nolibc/nolibc.h tools/include/nolibc/stdlib.h+86 -660 replies
8/42tools/nolibc/string: split the string functions into string.htools/include/nolibc/nolibc.h tools/include/nolibc/string.h+108 -950 replies
9/42tools/nolibc/ctype: split the is* functions to ctype.htools/include/nolibc/ctype.h tools/include/nolibc/nolibc.h+23 -60 replies
10/42tools/nolibc/ctype: add the missing is* functionstools/include/nolibc/ctype.h+78 -10 replies
11/42tools/nolibc/types: move the FD_* functions to macros in types.htools/include/nolibc/nolibc.h tools/include/nolibc/types.h+30 -143 replies
12/42tools/nolibc/types: make FD_SETSIZE configurabletools/include/nolibc/types.h+4 -22 replies
13/42tools/nolibc/types: move makedev to types.h and make it a macrotools/include/nolibc/nolibc.h tools/include/nolibc/types.h+5 -90 replies
14/42tools/nolibc/stdlib: move ltoa() to stdlib.htools/include/nolibc/nolibc.h tools/include/nolibc/stdlib.h+32 -220 replies
15/42tools/nolibc/stdlib: replace the ltoa() function with more efficient onestools/include/nolibc/stdlib.h+87 -200 replies
16/42tools/nolibc/stdlib: add i64toa() and u64toa()tools/include/nolibc/stdlib.h+72 -00 replies
17/42tools/nolibc/stdlib: add utoh() and u64toh()tools/include/nolibc/stdlib.h+80 -00 replies
18/42tools/nolibc/stdio: add a minimal set of stdio functionstools/include/nolibc/nolibc.h tools/include/nolibc/stdio.h+58 -00 replies
19/42tools/nolibc/stdio: add stdin/stdout/stderr and fget*/fput* functionstools/include/nolibc/stdio.h+89 -60 replies
20/42tools/nolibc/stdio: add fwrite() to stdiotools/include/nolibc/stdio.h+28 -70 replies
21/42tools/nolibc/stdio: add a minimal [vf]printf() implementationtools/include/nolibc/stdio.h+128 -00 replies
22/42tools/nolibc/types: define EXIT_SUCCESS and EXIT_FAILUREtools/include/nolibc/types.h+3 -00 replies
23/42tools/nolibc/stdio: add perror() to report the errno valuetools/include/nolibc/stdio.h+6 -00 replies
24/42tools/nolibc/sys: make open() take a vararg on the 3rd argumenttools/include/nolibc/sys.h+15 -30 replies
25/42tools/nolibc/stdlib: avoid a 64-bit shift in u64toh_r()tools/include/nolibc/stdlib.h+10 -60 replies
26/42tools/nolibc/stdlib: make raise() use the lower level syscalls onlytools/include/nolibc/stdlib.h+1 -10 replies
27/42tools/nolibc/sys: make getpgrp(), getpid(), gettid() not set errnotools/include/nolibc/sys.h+3 -210 replies
28/42tools/nolibc/string: use unidirectional variants for memcpy()tools/include/nolibc/string.h+23 -10 replies
29/42tools/nolibc/string: slightly simplify memmove()tools/include/nolibc/string.h+14 -60 replies
30/42tools/nolibc/string: add strncpy() and strlcpy()tools/include/nolibc/string.h+28 -00 replies
31/42tools/nolibc/string: add tiny versions of strncat() and strlcat()tools/include/nolibc/string.h+41 -00 replies
32/42tools/nolibc: move exported functions to their own sectiontools/include/nolibc/stdlib.h tools/include/nolibc/string.h+2 -20 replies
33/42tools/nolibc/arch: mark the _start symbol as weaktools/include/nolibc/arch-aarch64.h tools/include/nolibc/arch-arm.h tools/include/nolibc/arch-i386.h +3 more+6 -00 replies
34/42tools/nolibc/types: define PATH_MAX and MAXPATHLENtools/include/nolibc/types.h+11 -00 replies
35/42tools/nolibc/string: export memset() and memmove()tools/include/nolibc/string.h+8 -20 replies
36/42tools/nolibc/errno: extract errno.h from sys.htools/include/nolibc/errno.h tools/include/nolibc/stdio.h tools/include/nolibc/sys.h+29 -160 replies
37/42tools/nolibc/unistd: extract msleep(), sleep(), tcsetpgrp() to unistd.htools/include/nolibc/nolibc.h tools/include/nolibc/stdlib.h tools/include/nolibc/unistd.h+47 -300 replies
38/42tools/nolibc/unistd: add usleep()tools/include/nolibc/unistd.h+8 -00 replies
39/42tools/nolibc/signal: move raise() to signal.htools/include/nolibc/nolibc.h tools/include/nolibc/signal.h tools/include/nolibc/stdlib.h+23 -70 replies
40/42tools/nolibc/time: create time.h with time()tools/include/nolibc/nolibc.h tools/include/nolibc/time.h+29 -00 replies
41/42tools/nolibc: also mention how to build by just setting the include pathtools/include/nolibc/nolibc.h+20 -100 replies
42/42tools/nolibc/stdlib: implement abort()tools/include/nolibc/stdlib.h+8 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/42] nolibc: update to resync with out-of-tree project

Hello Paul,

Here comes an update to the nolibc subsystem to keep it in sync with the out-of-tree project and to bring a number of usability improvements.

The approach here consists in better splitting the layers so that arch-specific syscall functions are now in their own files (one per arch), then syscalls are implemented on top of this in a generic file, then the generic libc stuff is exposed. This way it becomes easier to add support for new architectures if needed.

I exported 3 functions as weak symbols: memset(), memmove() and abort(). For the first two ones, gcc/clang may issue calls to them and will not always fall back to the builtin equivalent. For abort(), I've seen it referenced by libgcc from some divide functions.

A few stdio-level functions were added (unbuffered), including a quite limited but usable printf() which significantly eases debugging of test programs by allowing to print return codes or pointers for example.

A few functions and syscalls like abort(), raise(), time() and usleep() were added. More str* functions were added as well. open() now takes a vararg on the 3rd argument so as to ease porting of existing programs.

Finally, the functions and definitions were moved to the appropriate files as documented in their man pages when relevant, so that simple programs which only use a few include files among stdio.h, stdlib.h, string.h, unistd.h, errno.h, ctype.h, signal.h, time.h or types.h can build without modification. Obviously this remains fairly limited in scope, but for test programs that's usually fine.

I could verify that a few of my programs and that your rcutorture test continue to work (not much surprising since most of the work only consists in moving functions between files).

There's obviously no rush, but I preferred to resync the version here given that Mark expressed some interest recently, and I'd hate it if he had to add new syscalls that already existed out of tree! Comments, suggestions and feature requests welcome as usual. If you prefer to pull, it's also available here, on top of 5.17-rc3:

git://git.kernel.org/pub/scm/linux/kernel/git/wtarreau/nolibc.git 20220206-nolibc-split-2

Thank you!
Willy

---
Willy Tarreau (42):
tools/nolibc: use pselect6 on RISCV
tools/nolibc: guard the main file against multiple inclusion tools/nolibc/std: move the standard type definitions to std.h tools/nolibc/types: split syscall-specific definitions into their own files tools/nolibc/arch: split arch-specific code into individual files tools/nolibc/sys: split the syscall definitions into their own file tools/nolibc/stdlib: extract the stdlib-specific functions to their own file tools/nolibc/string: split the string functions into string.h tools/nolibc/ctype: split the is* functions to ctype.h tools/nolibc/ctype: add the missing is* functions tools/nolibc/types: move the FD_* functions to macros in types.h tools/nolibc/types: make FD_SETSIZE configurable tools/nolibc/types: move makedev to types.h and make it a macro tools/nolibc/stdlib: move ltoa() to stdlib.h tools/nolibc/stdlib: replace the ltoa() function with more efficient ones tools/nolibc/stdlib: add i64toa() and u64toa() tools/nolibc/stdlib: add utoh() and u64toh() tools/nolibc/stdio: add a minimal set of stdio functions tools/nolibc/stdio: add stdin/stdout/stderr and fget*/fput* functions tools/nolibc/stdio: add fwrite() to stdio
tools/nolibc/stdio: add a minimal [vf]printf() implementation tools/nolibc/types: define EXIT_SUCCESS and EXIT_FAILURE tools/nolibc/stdio: add perror() to report the errno value tools/nolibc/sys: make open() take a vararg on the 3rd argument tools/nolibc/stdlib: avoid a 64-bit shift in u64toh_r() tools/nolibc/stdlib: make raise() use the lower level syscalls only tools/nolibc/sys: make getpgrp(), getpid(), gettid() not set errno tools/nolibc/string: use unidirectional variants for memcpy() tools/nolibc/string: slightly simplify memmove() tools/nolibc/string: add strncpy() and strlcpy() tools/nolibc/string: add tiny versions of strncat() and strlcat() tools/nolibc: move exported functions to their own section tools/nolibc/arch: mark the _start symbol as weak tools/nolibc/types: define PATH_MAX and MAXPATHLEN tools/nolibc/string: export memset() and memmove() tools/nolibc/errno: extract errno.h from sys.h tools/nolibc/unistd: extract msleep(), sleep(), tcsetpgrp() to unistd.h tools/nolibc/unistd: add usleep()
tools/nolibc/signal: move raise() to signal.h tools/nolibc/time: create time.h with time()
tools/nolibc: also mention how to build by just setting the include path tools/nolibc/stdlib: implement abort()

 tools/include/nolibc/arch-aarch64.h |  200 +++
 tools/include/nolibc/arch-arm.h     |  205 +++
 tools/include/nolibc/arch-i386.h    |  197 +++
 tools/include/nolibc/arch-mips.h    |  216 +++
 tools/include/nolibc/arch-riscv.h   |  205 +++
 tools/include/nolibc/arch-x86_64.h  |  216 +++
 tools/include/nolibc/arch.h         |   32 +
 tools/include/nolibc/ctype.h        |   99 ++
 tools/include/nolibc/errno.h        |   27 +
 tools/include/nolibc/nolibc.h       | 2540 +--------------------------
 tools/include/nolibc/signal.h       |   22 +
 tools/include/nolibc/std.h          |   49 +
 tools/include/nolibc/stdio.h        |  296 ++++
 tools/include/nolibc/stdlib.h       |  311 ++++
 tools/include/nolibc/string.h       |  212 +++
 tools/include/nolibc/sys.h          | 1168 ++++++++++++
 tools/include/nolibc/time.h         |   28 +
 tools/include/nolibc/types.h        |  184 ++
 tools/include/nolibc/unistd.h       |   54 +
 19 files changed, 3756 insertions(+), 2505 deletions(-)
 create mode 100644 tools/include/nolibc/arch-aarch64.h
 create mode 100644 tools/include/nolibc/arch-arm.h
 create mode 100644 tools/include/nolibc/arch-i386.h
 create mode 100644 tools/include/nolibc/arch-mips.h
 create mode 100644 tools/include/nolibc/arch-riscv.h
 create mode 100644 tools/include/nolibc/arch-x86_64.h
 create mode 100644 tools/include/nolibc/arch.h
 create mode 100644 tools/include/nolibc/ctype.h
 create mode 100644 tools/include/nolibc/errno.h
 create mode 100644 tools/include/nolibc/signal.h
 create mode 100644 tools/include/nolibc/std.h
 create mode 100644 tools/include/nolibc/stdio.h
 create mode 100644 tools/include/nolibc/stdlib.h
 create mode 100644 tools/include/nolibc/string.h
 create mode 100644 tools/include/nolibc/sys.h
 create mode 100644 tools/include/nolibc/time.h
 create mode 100644 tools/include/nolibc/types.h
 create mode 100644 tools/include/nolibc/unistd.h
Signature · 1 line
2.35.1