crc32.cc File Reference

#include "zutil.h"
#include "crc32.h"

Go to the source code of this file.

Defines

#define local   static
#define TBLS   1
#define DO1   crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
#define DO8   DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1

Functions

const unsigned long FAR *ZEXPORT get_crc_table ()
unsigned long ZEXPORT crc32 (unsigned long crc, const unsigned char FAR *buf, unsigned len)


Define Documentation

#define DO1   crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)

Definition at line 209 of file crc32.cc.

#define DO8   DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1

Definition at line 210 of file crc32.cc.

#define local   static

Definition at line 31 of file crc32.cc.

#define TBLS   1

Definition at line 64 of file crc32.cc.


Function Documentation

unsigned long ZEXPORT crc32 ( unsigned long  crc,
const unsigned char FAR *  buf,
unsigned  len 
)

Definition at line 213 of file crc32.cc.

References DO1, and DO8.

Referenced by deflate(), deflateReset(), and read_buf().

00214 {
00215     if (buf == Z_NULL) return 0UL;
00216 
00217 #ifdef DYNAMIC_CRC_TABLE
00218     if (crc_table_empty)
00219         make_crc_table();
00220 #endif /* DYNAMIC_CRC_TABLE */
00221 
00222 #ifdef BYFOUR
00223     if (sizeof(void *) == sizeof(ptrdiff_t)) {
00224         u4 endian;
00225 
00226         endian = 1;
00227         if (*((unsigned char *)(&endian)))
00228             return crc32_little(crc, buf, len);
00229         else
00230             return crc32_big(crc, buf, len);
00231     }
00232 #endif /* BYFOUR */
00233     crc = crc ^ 0xffffffffUL;
00234     while (len >= 8) {
00235         DO8;
00236         len -= 8;
00237     }
00238     if (len) do {
00239         DO1;
00240     } while (--len);
00241     return crc ^ 0xffffffffUL;
00242 }

const unsigned long FAR* ZEXPORT get_crc_table (  ) 

Definition at line 199 of file crc32.cc.

00200 {
00201 #ifdef DYNAMIC_CRC_TABLE
00202     if (crc_table_empty)
00203         make_crc_table();
00204 #endif /* DYNAMIC_CRC_TABLE */
00205     return (const unsigned long FAR *)crc_table;
00206 }


Generated on Mon May 27 17:50:37 2013 for Geant4 by  doxygen 1.4.7