aboutsummaryrefslogtreecommitdiffstats
path: root/src/vppinfra
diff options
context:
space:
mode:
Diffstat (limited to 'src/vppinfra')
-rw-r--r--src/vppinfra/crc32.h20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/vppinfra/crc32.h b/src/vppinfra/crc32.h
index 3b81daf28ca..2b20fef9027 100644
--- a/src/vppinfra/crc32.h
+++ b/src/vppinfra/crc32.h
@@ -76,23 +76,27 @@ clib_crc32c_u64 (u32 last, u64 data)
#ifdef clib_crc32c_uses_intrinsics
static_always_inline u32
-clib_crc32c (u8 * s, int len)
+clib_crc32c_with_init (u8 *s, int len, u32 last)
{
- u32 v = 0;
-
for (; len >= 8; len -= 8, s += 8)
- v = clib_crc32c_u64 (v, *((u64u *) s));
+ last = clib_crc32c_u64 (last, *((u64u *) s));
for (; len >= 4; len -= 4, s += 4)
- v = clib_crc32c_u32 (v, *((u32u *) s));
+ last = clib_crc32c_u32 (last, *((u32u *) s));
for (; len >= 2; len -= 2, s += 2)
- v = clib_crc32c_u16 (v, *((u16u *) s));
+ last = clib_crc32c_u16 (last, *((u16u *) s));
for (; len >= 1; len -= 1, s += 1)
- v = clib_crc32c_u8 (v, *((u8 *) s));
+ last = clib_crc32c_u8 (last, *((u8 *) s));
+
+ return last;
+}
- return v;
+static_always_inline u32
+clib_crc32c (u8 *s, int len)
+{
+ return clib_crc32c_with_init (s, len, 0);
}
#endif