Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
crc32.cc File Reference
#include "zutil.h"
#include "crc32.h"

Go to the source code of this file.

Macros

#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)
 

Macro Definition Documentation

◆ DO1

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

Definition at line 209 of file crc32.cc.

◆ DO8

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

Definition at line 210 of file crc32.cc.

◆ local

#define local   static

Definition at line 31 of file crc32.cc.

◆ TBLS

#define TBLS   1

Definition at line 64 of file crc32.cc.

Function Documentation

◆ crc32()

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

Definition at line 213 of file crc32.cc.

214{
215 if (buf == Z_NULL) return 0UL;
216
217#ifdef DYNAMIC_CRC_TABLE
218 if (crc_table_empty)
219 make_crc_table();
220#endif /* DYNAMIC_CRC_TABLE */
221
222#ifdef BYFOUR
223 if (sizeof(void *) == sizeof(ptrdiff_t)) {
224 u4 endian;
225
226 endian = 1;
227 if (*((unsigned char *)(&endian)))
228 return crc32_little(crc, buf, len);
229 else
230 return crc32_big(crc, buf, len);
231 }
232#endif /* BYFOUR */
233 crc = crc ^ 0xffffffffUL;
234 while (len >= 8) {
235 DO8;
236 len -= 8;
237 }
238 if (len) do {
239 DO1;
240 } while (--len);
241 return crc ^ 0xffffffffUL;
242}
#define DO8
Definition: crc32.cc:210
#define DO1
Definition: crc32.cc:209
#define Z_NULL
Definition: zlib.h:180

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

◆ get_crc_table()

const unsigned long FAR *ZEXPORT get_crc_table ( )

Definition at line 199 of file crc32.cc.

200{
201#ifdef DYNAMIC_CRC_TABLE
202 if (crc_table_empty)
203 make_crc_table();
204#endif /* DYNAMIC_CRC_TABLE */
205 return (const unsigned long FAR *)crc_table;
206}
const unsigned long FAR crc_table[TBLS][256]
Definition: crc32.h:5
#define FAR
Definition: zconf.h:251