diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:22:37 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2011-09-09 23:22:37 -0700 |
commit | 4b5a43a219d51066c01ff2ab86af18b967f2d0dd (patch) | |
tree | 4dcaf0cd18751d04cf638a9a6ec521990d4f2e90 /crc32.c | |
parent | 086e982175da84b3db958191031380794315f95f (diff) | |
download | zlib-4b5a43a219d51066c01ff2ab86af18b967f2d0dd.tar.gz zlib-4b5a43a219d51066c01ff2ab86af18b967f2d0dd.tar.bz2 zlib-4b5a43a219d51066c01ff2ab86af18b967f2d0dd.zip |
zlib 1.2.0.5v1.2.0.5
Diffstat (limited to 'crc32.c')
-rw-r--r-- | crc32.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -5,8 +5,8 @@ | |||
5 | * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster | 5 | * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster |
6 | * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing | 6 | * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing |
7 | * tables for updating the shift register in one step with three exclusive-ors | 7 | * tables for updating the shift register in one step with three exclusive-ors |
8 | * instead of four steps with four exclusive-ors. This results about a 50% | 8 | * instead of four steps with four exclusive-ors. This results about a factor |
9 | * increase in speed on a Power PC using gcc -O3. | 9 | * of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3. |
10 | */ | 10 | */ |
11 | 11 | ||
12 | /* @(#) $Id$ */ | 12 | /* @(#) $Id$ */ |
@@ -18,7 +18,7 @@ | |||
18 | # endif /* !DYNAMIC_CRC_TABLE */ | 18 | # endif /* !DYNAMIC_CRC_TABLE */ |
19 | #endif /* MAKECRCH */ | 19 | #endif /* MAKECRCH */ |
20 | 20 | ||
21 | #include "zutil.h" /* for STDC and FAR definitions */ | 21 | #include "zutil.h" /* for STDC and FAR definitions */ |
22 | 22 | ||
23 | #define local static | 23 | #define local static |
24 | 24 | ||
@@ -203,7 +203,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
203 | #endif /* DYNAMIC_CRC_TABLE */ | 203 | #endif /* DYNAMIC_CRC_TABLE */ |
204 | 204 | ||
205 | #ifdef BYFOUR | 205 | #ifdef BYFOUR |
206 | { | 206 | if (sizeof(void *) == sizeof(ptrdiff_t)) { |
207 | u4 endian; | 207 | u4 endian; |
208 | 208 | ||
209 | endian = 1; | 209 | endian = 1; |
@@ -212,7 +212,7 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
212 | else | 212 | else |
213 | return crc32_big(crc, buf, len); | 213 | return crc32_big(crc, buf, len); |
214 | } | 214 | } |
215 | #else /* !BYFOUR */ | 215 | #endif /* BYFOUR */ |
216 | crc = crc ^ 0xffffffffUL; | 216 | crc = crc ^ 0xffffffffUL; |
217 | while (len >= 8) { | 217 | while (len >= 8) { |
218 | DO8; | 218 | DO8; |
@@ -222,7 +222,6 @@ unsigned long ZEXPORT crc32(crc, buf, len) | |||
222 | DO1; | 222 | DO1; |
223 | } while (--len); | 223 | } while (--len); |
224 | return crc ^ 0xffffffffUL; | 224 | return crc ^ 0xffffffffUL; |
225 | #endif /* BYFOUR */ | ||
226 | } | 225 | } |
227 | 226 | ||
228 | #ifdef BYFOUR | 227 | #ifdef BYFOUR |
@@ -244,7 +243,7 @@ local unsigned long crc32_little(crc, buf, len) | |||
244 | 243 | ||
245 | c = (u4)crc; | 244 | c = (u4)crc; |
246 | c = ~c; | 245 | c = ~c; |
247 | while (len && ((size_t)buf & 3)) { | 246 | while (len && ((ptrdiff_t)buf & 3)) { |
248 | c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); | 247 | c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8); |
249 | len--; | 248 | len--; |
250 | } | 249 | } |
@@ -284,7 +283,7 @@ local unsigned long crc32_big(crc, buf, len) | |||
284 | 283 | ||
285 | c = REV((u4)crc); | 284 | c = REV((u4)crc); |
286 | c = ~c; | 285 | c = ~c; |
287 | while (len && ((size_t)buf & 3)) { | 286 | while (len && ((ptrdiff_t)buf & 3)) { |
288 | c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); | 287 | c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); |
289 | len--; | 288 | len--; |
290 | } | 289 | } |