mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 12:10:41 +00:00
b46bd5fa19
git-svn-id: https://svn.eduke32.com/eduke32@1567 1a8010ca-5511-0410-912e-c29ae57300e0
39 lines
670 B
C
39 lines
670 B
C
#ifndef __crc32_h__
|
|
#define __crc32_h__
|
|
|
|
#include "compat.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern uint32_t crc32table[256];
|
|
|
|
void initcrc32table(void);
|
|
|
|
uint32_t crc32once(uint8_t *blk, uint32_t len);
|
|
|
|
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;
|
|
}
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|