]> www.infradead.org Git - users/hch/misc.git/commitdiff
uapi: wrap compiler_types.h in an ifdef instead of the implicit strip
authorJakub Kicinski <kuba@kernel.org>
Mon, 25 Aug 2025 20:18:28 +0000 (13:18 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 28 Aug 2025 11:06:48 +0000 (13:06 +0200)
The uAPI stddef header includes compiler_types.h, a kernel-only
header, to make sure that kernel definitions of annotations
like __counted_by() take precedence.

There is a hack in scripts/headers_install.sh which strips includes
of compiler.h and compiler_types.h when installing uAPI headers.
While explicit handling makes sense for compiler.h, which is included
all over the uAPI, compiler_types.h is only included by stddef.h
(within the uAPI, obviously it's included in kernel code a lot).

Remove the stripping from scripts/headers_install.sh and wrap
the include of compiler_types.h in #ifdef __KERNEL__ instead.
This should be equivalent functionally, but is easier to understand
to a casual reader of the code. It also makes it easier to work
with kernel headers directly from under tools/

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250825201828.2370083-1-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/uapi/linux/stddef.h
scripts/headers_install.sh

index b87df1b485c2a4e5d3843f88722f2ebc519d3c9b..9a28f7d9a3342d04f2e6b7a2b70f13311557d9b6 100644 (file)
@@ -2,7 +2,9 @@
 #ifndef _UAPI_LINUX_STDDEF_H
 #define _UAPI_LINUX_STDDEF_H
 
+#ifdef __KERNEL__
 #include <linux/compiler_types.h>
+#endif
 
 #ifndef __always_inline
 #define __always_inline inline
index 6bbccb43f7e72b21537d806186352e70b09633ef..4c20c62c4faf581c43c7f95aded7e02663121313 100755 (executable)
@@ -32,7 +32,7 @@ fi
 sed -E -e '
        s/([[:space:](])(__user|__force|__iomem)[[:space:]]/\1/g
        s/__attribute_const__([[:space:]]|$)/\1/g
-       s@^#include <linux/compiler(|_types).h>@@
+       s@^#include <linux/compiler.h>@@
        s/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g
        s/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g
        s@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @