raze-gles/polymer/eduke32/build/include/crc32.h
hendricks266 fcf9beae6a Work-in-progress adjustment to the C code to compile under C++. It builds for me without errors using Win32 MinGW-GCC, but it still generates warning soup. No guarantees about MSVC or anything using SDL. Enable C++ by building with CPLUSPLUS=1. C remains the default and should compile with no change in setup.
Credit to Plagman for the idea and doing the work on the game side, which is included in this commit.

(Building as C++ will give us features with which we can make improvements and optimizations on the multiplayer code and Polymer.)

git-svn-id: https://svn.eduke32.com/eduke32@3116 1a8010ca-5511-0410-912e-c29ae57300e0
2012-11-05 02:49:08 +00:00

39 lines
662 B
C

#ifndef __crc32_h__
#define __crc32_h__
#include "compat.h"
#ifdef EXTERNC
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 EXTERNC
}
#endif
#endif