]> www.infradead.org Git - users/hch/misc.git/commit
tools/nolibc: include nolibc.h early from all header files
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Thu, 24 Apr 2025 11:48:12 +0000 (13:48 +0200)
committerThomas Weißschuh <linux@weissschuh.net>
Thu, 24 Apr 2025 13:20:49 +0000 (15:20 +0200)
commit4b3aa4b86190e89ee260090d1ba3e9aeb0a3b18c
tree457f55f500e7bfbe6d51c49a2378bff70cacc101
parenta17bca60658fa9b300b4496edd11d4966416ce51
tools/nolibc: include nolibc.h early from all header files

Inclusion of any nolibc header file should also bring all other headers.
On the other hand it should also be possible to include any nolibc header
files
in any order.

Currently this is implemented by including the catch-all nolibc.h after the
headers own definitions.
This is problematic if one nolibc header depends on another one.
The first header has to include the other one before defining any symbols.
That in turn will include the rest of nolibc while the current header has
not defined anything yet. If any other part of nolibc depends on
definitions from the current header, errors are encountered.
This is already the case today. Effectively nolibc can only be included in
the order of nolibc.h.

Restructure the way "nolibc.h" is included.
Move it to the beginning of the header files and before the include guards.
Now any header will behave exactly like "nolibc.h" while the include
guards prevent any duplicate definitions.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Acked-by: Willy Tarreau <w@1wt.eu>
Link: https://lore.kernel.org/r/20250424-nolibc-header-check-v1-2-011576b6ed6f@linutronix.de
20 files changed:
tools/include/nolibc/ctype.h
tools/include/nolibc/dirent.h
tools/include/nolibc/elf.h
tools/include/nolibc/errno.h
tools/include/nolibc/fcntl.h
tools/include/nolibc/getopt.h
tools/include/nolibc/signal.h
tools/include/nolibc/stdio.h
tools/include/nolibc/stdlib.h
tools/include/nolibc/string.h
tools/include/nolibc/sys.h
tools/include/nolibc/sys/auxv.h
tools/include/nolibc/sys/mman.h
tools/include/nolibc/sys/stat.h
tools/include/nolibc/sys/syscall.h
tools/include/nolibc/sys/time.h
tools/include/nolibc/sys/wait.h
tools/include/nolibc/time.h
tools/include/nolibc/types.h
tools/include/nolibc/unistd.h