16 #ifndef __included_crc32_h__ 17 #define __included_crc32_h__ 22 #define clib_crc32c_uses_intrinsics 23 #include <x86intrin.h> 26 clib_crc32c (
u8 * s,
int len)
31 for (; len >= 8; len -= 8, s += 8)
32 v = _mm_crc32_u64 (v, *((
u64 *) s));
36 volatile (
"":::
"memory");
39 for (; len >= 4; len -= 4, s += 4)
40 v = _mm_crc32_u32 (v, *((
u32 *) s));
42 for (; len >= 2; len -= 2, s += 2)
43 v = _mm_crc32_u16 (v, *((
u16 *) s));
45 for (; len >= 1; len -= 1, s += 1)
46 v = _mm_crc32_u8 (v, *((
u16 *) s));
51 #elif __ARM_FEATURE_CRC32 52 #define clib_crc32c_with_intrinsics 56 clib_crc32c (
u8 * s,
int len)
60 for (; len >= 8; len -= 8, s += 8)
61 v = __crc32cd (v, *((
u64 *) s));
63 for (; len >= 4; len -= 4, s += 4)
64 v = __crc32cw (v, *((
u32 *) s));
66 for (; len >= 2; len -= 2, s += 2)
67 v = __crc32ch (v, *((
u16 *) s));
69 for (; len >= 1; len -= 1, s += 1)
70 v = __crc32cb (v, *((
u8 *) s));
#define static_always_inline