[PATCH 1/4] lib/crc: Don't include <linux/types.h> in NEON intrinsics code
Thomas Huth
thuth at redhat.com
Fri Nov 13 01:03:24 PST 2026
Am 29.10.26 um 14:50 schrieb Ard Biesheuvel:
> From: Ard Biesheuvel <ardb at kernel.org>
>
> The kernel's definitions of uint64_t and int64_t in <linux/types.h> are based
> on [unsigned] long long, whereas the ones provided by <stdint.h>, which is
> included by <arm_neon.h>, are based on [unsigned] long on arm64. On 32-bit ARM,
> a similar mismatch exists for intptr_t.
>
> Including both into the same compilation unit currently only works because
> asm/neon-intrinsics.h overrides the predefined macros that the compiler's
> freestanding <stdint.h> uses to define these types. In order to be able to get
> rid of those overrides, stop including <linux/types.h> into the CRC64 NEON
> intrinsics code.
>
> Instead, use <stddef.h> for the definition of size_t, and rely on
> <asm/neon-intrinsics.h> to provide the u8 and u64 types used in the prototype
> of crc64_nvme_neon(), which is shared with code that does include
> <linux/types.h>. Use uint64_t for the arrays of constants that are passed to
> vld1q_u64(), so that they match its prototype regardless of how uint64_t is
> defined.
>
> No change in generated code.
>
> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
> ---
> lib/crc/crc64-neon.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/lib/crc/crc64-neon.c b/lib/crc/crc64-neon.c
> index 4753fb94a4be..1267df1310be 100644
> --- a/lib/crc/crc64-neon.c
> +++ b/lib/crc/crc64-neon.c
> @@ -3,7 +3,7 @@
> * Accelerated CRC64 (NVMe) using ARM NEON C intrinsics
> */
>
> -#include <linux/types.h>
> +#include <stddef.h>
> #include <asm/neon-intrinsics.h>
>
> #include "crc64-neon.h"
> @@ -11,11 +11,11 @@
> u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len);
>
> /* x^191 mod G, x^127 mod G */
> -static const u64 fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
> - 0x21e9761e252621acULL };
> +static const uint64_t fold_consts_val[2] = { 0xeadc41fd2ba3d420ULL,
> + 0x21e9761e252621acULL };
> /* floor(x^127 / G), (G - x^64) / x */
> -static const u64 bconsts_val[2] = { 0x27ecfa329aef9f77ULL,
> - 0x34d926535897936aULL };
> +static const uint64_t bconsts_val[2] = { 0x27ecfa329aef9f77ULL,
> + 0x34d926535897936aULL };
>
> u64 crc64_nvme_neon(u64 crc, const u8 *p, size_t len)
> {
Reviewed-by: Thomas Huth <thuth at redhat.com>
More information about the linux-arm-kernel
mailing list