]>
git.saurik.com Git - wxWidgets.git/blob - utils/Install/packzip/crc32.c
1 /* crc32.c -- compute the CRC-32 of a data stream
2 * Copyright (C) 1995 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h
8 #define __CRC32_C /* identifies this source module */
22 #define CRC32(c, b) (crc_table[((int)(c) ^ (b)) & 0xff] ^ ((c) >> 8))
23 #define DO1(buf) crc = CRC32(crc, *buf++)
24 #define DO2(buf) DO1(buf); DO1(buf)
25 #define DO4(buf) DO2(buf); DO2(buf)
26 #define DO8(buf) DO4(buf); DO4(buf)
28 /* ========================================================================= */
29 ulg
crc32(crc
, buf
, len
)
30 register ulg crc
; /* crc shift register */
31 register ZCONST uch
*buf
; /* pointer to bytes to pump through */
32 extent len
; /* number of bytes in buf[] */
33 /* Run a set of bytes through the crc shift register. If buf is a NULL
34 pointer, then initialize the crc shift register contents instead.
35 Return the current crc in either case. */
37 register ZCONST ulg near
*crc_table
;
39 if (buf
== NULL
) return 0L;
41 crc_table
= get_crc_table();
43 crc
= crc
^ 0xffffffffL
;
44 #ifndef NO_UNROLLED_LOOPS
53 return crc
^ 0xffffffffL
; /* (instead of ~c for 64-bit machines) */
56 #endif /* !USE_ZLIB */