From: phk Date: Mon, 6 Aug 2007 09:19:20 +0000 (+0000) Subject: Add piecemal crc32 function back, we will need it for the scatter/gather X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1291ff699d3c277994685750a88d8f2cf61f6fa5;p=varnish Add piecemal crc32 function back, we will need it for the scatter/gather hash string. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1804 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/include/libvarnish.h b/varnish-cache/include/libvarnish.h index 7022d3e4..6bac9eb9 100644 --- a/varnish-cache/include/libvarnish.h +++ b/varnish-cache/include/libvarnish.h @@ -42,6 +42,7 @@ void FreeArgv(char **argv); char **ParseArgv(const char *s, int comment); /* from libvarnish/crc32.c */ +uint32_t crc32(uint32_t crc, const void *p1, unsigned l); uint32_t crc32_l(const void *p1, unsigned l); /* from libvarnish/time.c */ diff --git a/varnish-cache/lib/libvarnish/crc32.c b/varnish-cache/lib/libvarnish/crc32.c index c63cab62..8ea42553 100644 --- a/varnish-cache/lib/libvarnish/crc32.c +++ b/varnish-cache/lib/libvarnish/crc32.c @@ -82,14 +82,21 @@ static uint32_t crc32bits[] = { }; uint32_t -crc32_l(const void *p1, unsigned l) +crc32(uint32_t crc, const void *p1, unsigned l) { const unsigned char *p; - uint32_t crc; - - crc = ~0U; for (p = (const unsigned char*)p1; l-- > 0; p++) crc = (crc >> 8) ^ crc32bits[(crc ^ *p) & 0xff]; + return (crc); +} + +uint32_t +crc32_l(const void *p1, unsigned l) +{ + uint32_t crc; + + crc = crc32(~0U, p1, l); return (crc ^ ~0U); } +