aboutsummaryrefslogtreecommitdiff
path: root/crc32.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2011-09-09 23:26:40 -0700
committerMark Adler <madler@alumni.caltech.edu>2011-09-09 23:26:40 -0700
commitf6194ef39af5864f792412460c354cc339dde7d1 (patch)
tree5ea1e6849128e9b2194c66ee3d82afa36b4ac07c /crc32.c
parent639be997883d9016baaf46017a2802b2ce1698bd (diff)
downloadzlib-f6194ef39af5864f792412460c354cc339dde7d1.tar.gz
zlib-f6194ef39af5864f792412460c354cc339dde7d1.tar.bz2
zlib-f6194ef39af5864f792412460c354cc339dde7d1.zip
zlib 1.2.3.4v1.2.3.4
Diffstat (limited to 'crc32.c')
-rw-r--r--crc32.c32
1 files changed, 7 insertions, 25 deletions
diff --git a/crc32.c b/crc32.c
index b34a510..1acc7ed 100644
--- a/crc32.c
+++ b/crc32.c
@@ -53,7 +53,7 @@
53 53
54/* Definitions for doing the crc four data bytes at a time. */ 54/* Definitions for doing the crc four data bytes at a time. */
55#ifdef BYFOUR 55#ifdef BYFOUR
56# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \ 56# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
57 (((w)&0xff00)<<8)+(((w)&0xff)<<24)) 57 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
58 local unsigned long crc32_little OF((unsigned long, 58 local unsigned long crc32_little OF((unsigned long,
59 const unsigned char FAR *, unsigned)); 59 const unsigned char FAR *, unsigned));
@@ -68,11 +68,7 @@
68local unsigned long gf2_matrix_times OF((unsigned long *mat, 68local unsigned long gf2_matrix_times OF((unsigned long *mat,
69 unsigned long vec)); 69 unsigned long vec));
70local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat)); 70local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
71#ifdef _LARGEFILE64_SOURCE 71local uLong crc32_combine_(uLong crc1, uLong crc2, z_off64_t len2);
72 local uLong crc32_combine_(uLong crc1, uLong crc2, off64_t len2);
73#else
74 local uLong crc32_combine_(uLong crc1, uLong crc2, z_off_t len2);
75#endif
76 72
77 73
78#ifdef DYNAMIC_CRC_TABLE 74#ifdef DYNAMIC_CRC_TABLE
@@ -376,23 +372,19 @@ local void gf2_matrix_square(square, mat)
376local uLong crc32_combine_(crc1, crc2, len2) 372local uLong crc32_combine_(crc1, crc2, len2)
377 uLong crc1; 373 uLong crc1;
378 uLong crc2; 374 uLong crc2;
379#ifdef _LARGEFILE64_SOURCE 375 z_off64_t len2;
380 off64_t len2;
381#else
382 z_off_t len2;
383#endif
384{ 376{
385 int n; 377 int n;
386 unsigned long row; 378 unsigned long row;
387 unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */ 379 unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
388 unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */ 380 unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
389 381
390 /* degenerate case */ 382 /* degenerate case (also disallow negative lengths) */
391 if (len2 == 0) 383 if (len2 <= 0)
392 return crc1; 384 return crc1;
393 385
394 /* put operator for one zero bit in odd */ 386 /* put operator for one zero bit in odd */
395 odd[0] = 0xedb88320L; /* CRC-32 polynomial */ 387 odd[0] = 0xedb88320UL; /* CRC-32 polynomial */
396 row = 1; 388 row = 1;
397 for (n = 1; n < GF2_DIM; n++) { 389 for (n = 1; n < GF2_DIM; n++) {
398 odd[n] = row; 390 odd[n] = row;
@@ -441,20 +433,10 @@ uLong ZEXPORT crc32_combine(crc1, crc2, len2)
441 return crc32_combine_(crc1, crc2, len2); 433 return crc32_combine_(crc1, crc2, len2);
442} 434}
443 435
444#ifdef _LARGEFILE64_SOURCE
445uLong ZEXPORT crc32_combine64(crc1, crc2, len2) 436uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
446 uLong crc1; 437 uLong crc1;
447 uLong crc2; 438 uLong crc2;
448 off64_t len2; 439 z_off64_t len2;
449{
450 return crc32_combine_(crc1, crc2, len2);
451}
452#else
453uLong ZEXPORT crc32_combine64(crc1, crc2, len2)
454 uLong crc1;
455 uLong crc2;
456 z_off_t len2;
457{ 440{
458 return crc32_combine_(crc1, crc2, len2); 441 return crc32_combine_(crc1, crc2, len2);
459} 442}
460#endif