2007-01-29 01:18:16 +00:00
|
|
|
#ifndef __crc32_h__
|
|
|
|
#define __crc32_h__
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
#include "compat.h"
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2009-12-14 05:23:29 +00:00
|
|
|
extern uint32_t crc32table[256];
|
|
|
|
|
2007-01-29 01:18:16 +00:00
|
|
|
void initcrc32table(void);
|
|
|
|
|
2009-01-09 09:29:17 +00:00
|
|
|
uint32_t crc32once(uint8_t *blk, uint32_t len);
|
2007-01-29 01:18:16 +00:00
|
|
|
|
2009-12-14 05:23:29 +00:00
|
|
|
static inline void crc32init(uint32_t *crcvar)
|
|
|
|
{
|
|
|
|
if (!crcvar) return;
|
|
|
|
*crcvar = 0xffffffffl;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void crc32block(uint32_t *crcvar, uint8_t *blk, uint32_t len)
|
|
|
|
{
|
|
|
|
uint32_t crc = *crcvar;
|
|
|
|
while (len--) crc = crc32table[(crc ^ *(blk++)) & 0xffl] ^(crc >> 8);
|
|
|
|
*crcvar = crc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t crc32finish(uint32_t *crcvar)
|
|
|
|
{
|
|
|
|
*crcvar = *crcvar ^ 0xffffffffl;
|
|
|
|
return *crcvar;
|
|
|
|
}
|
2007-01-29 01:18:16 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|