From 9c454937cbc25458219961503137127a631088d8 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Thu, 10 Jul 2008 17:42:18 +0000 Subject: [PATCH] Add crc32_ext() - allows continuation of a 32 bit crc. --- sys/libkern/crc32.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/sys/libkern/crc32.c b/sys/libkern/crc32.c index 9b6d41c560..9d5df6e05d 100644 --- a/sys/libkern/crc32.c +++ b/sys/libkern/crc32.c @@ -39,7 +39,7 @@ * CRC32 code derived from work by Gary S. Brown. * * $FreeBSD: src/sys/libkern/crc32.c,v 1.1.2.1 2002/07/31 09:08:34 imp Exp $ - * $DragonFly: src/sys/libkern/crc32.c,v 1.4 2008/02/05 20:50:31 dillon Exp $ + * $DragonFly: src/sys/libkern/crc32.c,v 1.5 2008/07/10 17:42:18 dillon Exp $ */ /* @@ -118,3 +118,18 @@ crc32(const void *buf, size_t size) return crc ^ ~0U; } +uint32_t +crc32_ext(const void *buf, size_t size, uint32_t ocrc) +{ + const uint8_t *p; + uint32_t crc; + + p = buf; + crc = ~ocrc; + + while (size--) + crc = crc32_tab[(crc ^ *p++) & 0xFF] ^ (crc >> 8); + + return crc ^ ~0U; +} + -- 2.11.4.GIT