16 #ifndef __included_crc32_h__ 17 #define __included_crc32_h__ 22 #define clib_crc32c_uses_intrinsics 23 #include <x86intrin.h> 25 #define crc32_u64 _mm_crc32_u64 26 #define crc32_u32 _mm_crc32_u32 29 clib_crc32c (
u8 * s,
int len)
33 #if defined(__x86_64__) 34 for (; len >= 8; len -= 8, s += 8)
35 v = _mm_crc32_u64 (v, *((
u64 *) s));
39 #if !defined (__i686__) 40 asm volatile (
"":::
"memory");
44 for (; len >= 4; len -= 4, s += 4)
45 v = _mm_crc32_u32 (v, *((
u32 *) s));
47 for (; len >= 2; len -= 2, s += 2)
48 v = _mm_crc32_u16 (v, *((
u16 *) s));
50 for (; len >= 1; len -= 1, s += 1)
51 v = _mm_crc32_u8 (v, *((
u16 *) s));
56 #elif __ARM_FEATURE_CRC32 57 #define clib_crc32c_uses_intrinsics 61 #define crc32_u64 __crc32cd 62 #define crc32_u32 __crc32cw 65 clib_crc32c (
u8 * s,
int len)
69 for (; len >= 8; len -= 8, s += 8)
70 v = __crc32cd (v, *((
u64 *) s));
72 for (; len >= 4; len -= 4, s += 4)
73 v = __crc32cw (v, *((
u32 *) s));
75 for (; len >= 2; len -= 2, s += 2)
76 v = __crc32ch (v, *((
u16 *) s));
78 for (; len >= 1; len -= 1, s += 1)
79 v = __crc32cb (v, *((
u8 *) s));
#define static_always_inline