[PATCH 4/4] ARM: Drop stdint.h type overrides from asm/neon-intrinsics.h
Ard Biesheuvel
ardb+git at google.com
Thu Oct 29 06:50:24 PDT 2026
From: Ard Biesheuvel <ardb at kernel.org>
None of the users of NEON intrinsics include <linux/types.h> anymore,
and so there is no longer a need to override the compiler's predefined
macros that are used to define the C99 [u]int32_t and [u]intptr_t types
in order to make them compatible with the kernel's definitions. So drop
the overrides from asm/neon-intrinsics.h.
Update the documentation accordingly.
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
Documentation/arch/arm/kernel_mode_neon.rst | 10 +++--
arch/arm/include/asm/neon-intrinsics.h | 43 +++-----------------
2 files changed, 12 insertions(+), 41 deletions(-)
diff --git a/Documentation/arch/arm/kernel_mode_neon.rst b/Documentation/arch/arm/kernel_mode_neon.rst
index 1efb6d35b7bd..73331f17b2c0 100644
--- a/Documentation/arch/arm/kernel_mode_neon.rst
+++ b/Documentation/arch/arm/kernel_mode_neon.rst
@@ -121,6 +121,10 @@ observe the following in addition to the rules above:
* Compile the unit containing the NEON intrinsics with '-ffreestanding' so GCC
uses its builtin version of <stdint.h> (this is a C99 header which the kernel
does not supply);
-* Do not include <arm_neon.h> directly: instead, include <asm/neon-intrinsics.h>,
- which tweaks some macro definitions so that system headers can be included
- safely.
+* Do not include <arm_neon.h> directly: instead, include <asm/neon-intrinsics.h>;
+* Do not include <linux/types.h>, or any other kernel header that includes it,
+ into the same compilation unit: some of the C99 types it defines (e.g.,
+ intptr_t) are incompatible with the ones defined by <stdint.h>. The kernel's
+ own u8, u16, u32 and u64 types are provided by <asm/neon-intrinsics.h>, and
+ can be used safely in the prototypes of functions that are called from code
+ that does include <linux/types.h>.
diff --git a/arch/arm/include/asm/neon-intrinsics.h b/arch/arm/include/asm/neon-intrinsics.h
index 8b80c05ce1d7..449f6556ac67 100644
--- a/arch/arm/include/asm/neon-intrinsics.h
+++ b/arch/arm/include/asm/neon-intrinsics.h
@@ -7,46 +7,13 @@
#error You should compile this file with '-march=armv7-a -mfloat-abi=softfp -mfpu=neon'
#endif
-#include <asm-generic/int-ll64.h>
-
/*
- * The C99 types uintXX_t that are usually defined in 'stdint.h' are not as
- * unambiguous on ARM as you would expect. For the types below, there is a
- * difference on ARM between GCC built for bare metal ARM, GCC built for glibc
- * and the kernel itself, which results in build errors if you try to build
- * with -ffreestanding and include 'stdint.h' (such as when you include
- * 'arm_neon.h' in order to use NEON intrinsics)
- *
- * As the typedefs for these types in 'stdint.h' are based on builtin defines
- * supplied by GCC, we can tweak these to align with the kernel's idea of those
- * types, so 'linux/types.h' and 'stdint.h' can be safely included from the
- * same source file (provided that -ffreestanding is used).
- *
- * int32_t uint32_t intptr_t uintptr_t
- * bare metal GCC long unsigned long int unsigned int
- * glibc GCC int unsigned int int unsigned int
- * kernel int unsigned int long unsigned long
+ * <arm_neon.h> includes <stdint.h>, which defines some C99 types differently
+ * from <linux/types.h>, so the latter must not be included into code that uses
+ * NEON intrinsics. The kernel's u8/u16/u32/u64 types can be used alongside the
+ * C99 ones, so provide those instead.
*/
-
-#ifdef __INT32_TYPE__
-#undef __INT32_TYPE__
-#define __INT32_TYPE__ int
-#endif
-
-#ifdef __UINT32_TYPE__
-#undef __UINT32_TYPE__
-#define __UINT32_TYPE__ unsigned int
-#endif
-
-#ifdef __INTPTR_TYPE__
-#undef __INTPTR_TYPE__
-#define __INTPTR_TYPE__ long
-#endif
-
-#ifdef __UINTPTR_TYPE__
-#undef __UINTPTR_TYPE__
-#define __UINTPTR_TYPE__ unsigned long
-#endif
+#include <asm-generic/int-ll64.h>
/*
* genksyms chokes on the ARM NEON instrinsics system header, but we
--
2.56.0.313.g2479322e68-goog
More information about the linux-arm-kernel
mailing list