summaryrefslogtreecommitdiff
path: root/tools/include/nolibc/sys
diff options
context:
space:
mode:
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>2025-04-24 13:48:12 +0200
committerThomas Weißschuh <linux@weissschuh.net>2025-05-21 15:31:50 +0200
commit3785289f97e2118b157332ffaae9fd2ec71237c8 (patch)
treeb7c8310fa6399bb3a38cbb8a61024dcb34820399 /tools/include/nolibc/sys
parenta6a054c8ad32b04c2e5d3cc5592fa737a2bb771f (diff)
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
Diffstat (limited to 'tools/include/nolibc/sys')
-rw-r--r--tools/include/nolibc/sys/auxv.h6
-rw-r--r--tools/include/nolibc/sys/mman.h6
-rw-r--r--tools/include/nolibc/sys/stat.h7
-rw-r--r--tools/include/nolibc/sys/syscall.h6
-rw-r--r--tools/include/nolibc/sys/time.h6
-rw-r--r--tools/include/nolibc/sys/wait.h7
6 files changed, 18 insertions, 20 deletions
diff --git a/tools/include/nolibc/sys/auxv.h b/tools/include/nolibc/sys/auxv.h
index 04c2b9cbe51a..c52463d6c18d 100644
--- a/tools/include/nolibc/sys/auxv.h
+++ b/tools/include/nolibc/sys/auxv.h
@@ -4,6 +4,9 @@
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
#ifndef _NOLIBC_SYS_AUXV_H
#define _NOLIBC_SYS_AUXV_H
@@ -35,7 +38,4 @@ unsigned long getauxval(unsigned long type)
return ret;
}
-/* make sure to include all global symbols */
-#include "../nolibc.h"
-
#endif /* _NOLIBC_SYS_AUXV_H */
diff --git a/tools/include/nolibc/sys/mman.h b/tools/include/nolibc/sys/mman.h
index ad9d06b6b791..41c7bf45e427 100644
--- a/tools/include/nolibc/sys/mman.h
+++ b/tools/include/nolibc/sys/mman.h
@@ -4,6 +4,9 @@
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
#ifndef _NOLIBC_SYS_MMAN_H
#define _NOLIBC_SYS_MMAN_H
@@ -57,7 +60,4 @@ int munmap(void *addr, size_t length)
return __sysret(sys_munmap(addr, length));
}
-/* make sure to include all global symbols */
-#include "../nolibc.h"
-
#endif /* _NOLIBC_SYS_MMAN_H */
diff --git a/tools/include/nolibc/sys/stat.h b/tools/include/nolibc/sys/stat.h
index 0eaf5496ce23..987c8bb52502 100644
--- a/tools/include/nolibc/sys/stat.h
+++ b/tools/include/nolibc/sys/stat.h
@@ -4,6 +4,9 @@
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
#ifndef _NOLIBC_SYS_STAT_H
#define _NOLIBC_SYS_STAT_H
@@ -67,8 +70,4 @@ int stat(const char *path, struct stat *buf)
return 0;
}
-
-/* make sure to include all global symbols */
-#include "../nolibc.h"
-
#endif /* _NOLIBC_SYS_STAT_H */
diff --git a/tools/include/nolibc/sys/syscall.h b/tools/include/nolibc/sys/syscall.h
index 59efdec8fd1c..4bf97f1386a0 100644
--- a/tools/include/nolibc/sys/syscall.h
+++ b/tools/include/nolibc/sys/syscall.h
@@ -4,6 +4,9 @@
* Copyright (C) 2024 Thomas Weißschuh <linux@weissschuh.net>
*/
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
#ifndef _NOLIBC_SYS_SYSCALL_H
#define _NOLIBC_SYS_SYSCALL_H
@@ -13,7 +16,4 @@
#define _syscall_n(N, ...) _syscall(N, __VA_ARGS__)
#define syscall(...) _syscall_n(_syscall_narg(__VA_ARGS__), ##__VA_ARGS__)
-/* make sure to include all global symbols */
-#include "../nolibc.h"
-
#endif /* _NOLIBC_SYS_SYSCALL_H */
diff --git a/tools/include/nolibc/sys/time.h b/tools/include/nolibc/sys/time.h
index 1d326c05ee62..785961c52fa3 100644
--- a/tools/include/nolibc/sys/time.h
+++ b/tools/include/nolibc/sys/time.h
@@ -4,6 +4,9 @@
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
#ifndef _NOLIBC_SYS_TIME_H
#define _NOLIBC_SYS_TIME_H
@@ -30,7 +33,4 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
return __sysret(sys_gettimeofday(tv, tz));
}
-/* make sure to include all global symbols */
-#include "../nolibc.h"
-
#endif /* _NOLIBC_SYS_TIME_H */
diff --git a/tools/include/nolibc/sys/wait.h b/tools/include/nolibc/sys/wait.h
index 9a68e6a6b1df..f27be86ad5e4 100644
--- a/tools/include/nolibc/sys/wait.h
+++ b/tools/include/nolibc/sys/wait.h
@@ -4,6 +4,9 @@
* Copyright (C) 2017-2021 Willy Tarreau <w@1wt.eu>
*/
+/* make sure to include all global symbols */
+#include "../nolibc.h"
+
#ifndef _NOLIBC_SYS_WAIT_H
#define _NOLIBC_SYS_WAIT_H
@@ -110,8 +113,4 @@ pid_t waitpid(pid_t pid, int *status, int options)
return info.si_pid;
}
-
-/* make sure to include all global symbols */
-#include "../nolibc.h"
-
#endif /* _NOLIBC_SYS_WAIT_H */