]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
kbuild: uapi: provide stub includes for some libc headers
authorThomas Weißschuh <linux@weissschuh.net>
Fri, 27 Feb 2026 06:38:04 +0000 (07:38 +0100)
committerNicolas Schier <nsc@kernel.org>
Thu, 12 Mar 2026 11:48:08 +0000 (12:48 +0100)
Some UAPI headers incorrectly use libc headers. To compile-test these
UAPI headers, their respective libc dependencies need to be present.
Not all kernel toolchains provide these headers, reducing test coverage.

Introduce some stub headers which provide just enough symbols to test
all UAPI headers. Most headers are empty anyways, as their symbols are
only used in macros which are not actually evaluated.

As these headers are only ever used with newer kernel toolchains, they
can defer to compiler builtins in many cases.

As more UAPI headers are cleaned up to not require these stubs anymore,
they can be removed again.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Tested-by: Nicolas Schier <nsc@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Link: https://patch.msgid.link/20260227-kbuild-uapi-libc-v1-6-c17de0d19776@weissschuh.net
Signed-off-by: Nicolas Schier <nsc@kernel.org>
13 files changed:
usr/dummy-include/endian.h [new file with mode: 0644]
usr/dummy-include/limits.h [new file with mode: 0644]
usr/dummy-include/netinet/if_ether.h [new file with mode: 0644]
usr/dummy-include/netinet/in.h [new file with mode: 0644]
usr/dummy-include/stddef.h [new file with mode: 0644]
usr/dummy-include/stdint.h [new file with mode: 0644]
usr/dummy-include/string.h [new file with mode: 0644]
usr/dummy-include/sys/ioctl.h [new file with mode: 0644]
usr/dummy-include/sys/socket.h [new file with mode: 0644]
usr/dummy-include/sys/time.h [new file with mode: 0644]
usr/dummy-include/sys/types.h [new file with mode: 0644]
usr/dummy-include/time.h [new file with mode: 0644]
usr/dummy-include/unistd.h [new file with mode: 0644]

diff --git a/usr/dummy-include/endian.h b/usr/dummy-include/endian.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/dummy-include/limits.h b/usr/dummy-include/limits.h
new file mode 100644 (file)
index 0000000..49b17c1
--- /dev/null
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _DUMMY_LIMITS_H
+#define _DUMMY_LIMITS_H
+
+#define INT_MAX ((int)(~0U >> 1))
+#define INT_MIN (-INT_MAX - 1)
+
+#endif /* _DUMMY_LIMITS_H */
diff --git a/usr/dummy-include/netinet/if_ether.h b/usr/dummy-include/netinet/if_ether.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/dummy-include/netinet/in.h b/usr/dummy-include/netinet/in.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/dummy-include/stddef.h b/usr/dummy-include/stddef.h
new file mode 100644 (file)
index 0000000..a61703d
--- /dev/null
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _DUMMY_STDDEF_H
+#define _DUMMY_STDDEF_H
+
+#define offsetof(TYPE, MEMBER) __builtin_offsetof(TYPE, MEMBER)
+#define NULL ((void *)0)
+
+#endif /* _DUMMY_STDDEF_H */
diff --git a/usr/dummy-include/stdint.h b/usr/dummy-include/stdint.h
new file mode 100644 (file)
index 0000000..93b1962
--- /dev/null
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _DUMMY_STDINT_H
+#define _DUMMY_STDINT_H
+
+#include <linux/types.h>
+
+typedef        __u64   uint64_t;
+typedef        __u32   uint32_t;
+typedef        __u16   uint16_t;
+typedef        __u8    uint8_t;
+
+typedef        __s64   int64_t;
+typedef        __s32   int32_t;
+typedef        __s16   int16_t;
+typedef        __s8    int8_t;
+
+#endif /* _DUMMY_STDINT_H */
diff --git a/usr/dummy-include/string.h b/usr/dummy-include/string.h
new file mode 100644 (file)
index 0000000..e059808
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _DUMMY_STRING_H
+#define _DUMMY_STRING_H
+
+#include <stddef.h>
+
+#define memset(_s, _c, _n) __builtin_memset(_s, _c, _n)
+#define memcpy(_dest, _src, _n) __builtin_memcpy(_dest, _src, _n)
+
+#define strlen(_s) __builtin_strlen(_s)
+
+#endif /* _DUMMY_STRING_H */
diff --git a/usr/dummy-include/sys/ioctl.h b/usr/dummy-include/sys/ioctl.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/dummy-include/sys/socket.h b/usr/dummy-include/sys/socket.h
new file mode 100644 (file)
index 0000000..748751f
--- /dev/null
@@ -0,0 +1,12 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _DUMMY_SYS_SOCKET_H
+#define _DUMMY_SYS_SOCKET_H
+
+#include <linux/socket.h>
+
+struct sockaddr {
+       __kernel_sa_family_t    sa_family;      /* address family, AF_xxx       */
+       char                    sa_data[14];    /* 14 bytes of protocol address */
+};
+
+#endif /* _DUMMY_SYS_SOCKET_H */
diff --git a/usr/dummy-include/sys/time.h b/usr/dummy-include/sys/time.h
new file mode 100644 (file)
index 0000000..9817b8a
--- /dev/null
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <linux/time.h>
diff --git a/usr/dummy-include/sys/types.h b/usr/dummy-include/sys/types.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/dummy-include/time.h b/usr/dummy-include/time.h
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/usr/dummy-include/unistd.h b/usr/dummy-include/unistd.h
new file mode 100644 (file)
index 0000000..e69de29