Fix CRC32 hashing for x86_64

This commit is contained in:
dhewg 2011-12-10 18:48:09 +01:00 committed by Daniel Gibson
parent dec4098879
commit ed4ee5a9f3
3 changed files with 18 additions and 18 deletions

View file

@ -235,7 +235,7 @@ idDict::Checksum
================
*/
int idDict::Checksum( void ) const {
unsigned long ret;
unsigned int ret;
int i, n;
idList<idKeyValue> sorted = args;

View file

@ -7,12 +7,12 @@
Copyright (C) 1995-1998 Mark Adler
*/
#define CRC32_INIT_VALUE 0xffffffffL
#define CRC32_XOR_VALUE 0xffffffffL
#define CRC32_INIT_VALUE 0xffffffff
#define CRC32_XOR_VALUE 0xffffffff
#ifdef CREATE_CRC_TABLE
static unsigned long crctable[256];
static unsigned int crctable[256];
/*
Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
@ -41,7 +41,7 @@ static unsigned long crctable[256];
void make_crc_table( void ) {
int i, j;
unsigned long c, poly;
unsigned int c, poly;
/* terms of polynomial defining this crc (except x^32): */
static const byte p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
@ -52,7 +52,7 @@ void make_crc_table( void ) {
}
for ( i = 0; i < 256; i++ ) {
c = (unsigned long)i;
c = (unsigned int)i;
for ( j = 0; j < 8; j++ ) {
c = ( c & 1 ) ? poly ^ ( c >> 1 ) : ( c >> 1 );
}
@ -65,7 +65,7 @@ void make_crc_table( void ) {
/*
Table of CRC-32's of all single-byte values (made by make_crc_table)
*/
static unsigned long crctable[256] = {
static unsigned int crctable[256] = {
0x00000000L, 0x77073096L, 0xee0e612cL, 0x990951baL,
0x076dc419L, 0x706af48fL, 0xe963a535L, 0x9e6495a3L,
0x0edb8832L, 0x79dcb8a4L, 0xe0d5e91eL, 0x97d2d988L,
@ -134,16 +134,16 @@ static unsigned long crctable[256] = {
#endif
void CRC32_InitChecksum( unsigned long &crcvalue ) {
void CRC32_InitChecksum( unsigned int &crcvalue ) {
crcvalue = CRC32_INIT_VALUE;
}
void CRC32_Update( unsigned long &crcvalue, const byte data ) {
void CRC32_Update( unsigned int &crcvalue, const byte data ) {
crcvalue = crctable[ ( crcvalue ^ data ) & 0xff ] ^ ( crcvalue >> 8 );
}
void CRC32_UpdateChecksum( unsigned long &crcvalue, const void *data, int length ) {
unsigned long crc;
void CRC32_UpdateChecksum( unsigned int &crcvalue, const void *data, int length ) {
unsigned int crc;
const unsigned char *buf = (const unsigned char *) data;
crc = crcvalue;
@ -153,12 +153,12 @@ void CRC32_UpdateChecksum( unsigned long &crcvalue, const void *data, int length
crcvalue = crc;
}
void CRC32_FinishChecksum( unsigned long &crcvalue ) {
void CRC32_FinishChecksum( unsigned int &crcvalue ) {
crcvalue ^= CRC32_XOR_VALUE;
}
unsigned long CRC32_BlockChecksum( const void *data, int length ) {
unsigned long crc;
unsigned int CRC32_BlockChecksum( const void *data, int length ) {
unsigned int crc;
CRC32_InitChecksum( crc );
CRC32_UpdateChecksum( crc, data, length );

View file

@ -10,9 +10,9 @@
===============================================================================
*/
void CRC32_InitChecksum( unsigned long &crcvalue );
void CRC32_UpdateChecksum( unsigned long &crcvalue, const void *data, int length );
void CRC32_FinishChecksum( unsigned long &crcvalue );
unsigned long CRC32_BlockChecksum( const void *data, int length );
void CRC32_InitChecksum( unsigned int &crcvalue );
void CRC32_UpdateChecksum( unsigned int &crcvalue, const void *data, int length );
void CRC32_FinishChecksum( unsigned int &crcvalue );
unsigned int CRC32_BlockChecksum( const void *data, int length );
#endif /* !__CRC32_H__ */