aboutsummaryrefslogtreecommitdiff
path: root/crc32.c
diff options
context:
space:
mode:
Diffstat (limited to 'crc32.c')
-rw-r--r--crc32.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/crc32.c b/crc32.c
index ddf0025..95225ef 100644
--- a/crc32.c
+++ b/crc32.c
@@ -59,8 +59,6 @@
59/* Definitions for doing the crc four data bytes at a time. */ 59/* Definitions for doing the crc four data bytes at a time. */
60#ifdef BYFOUR 60#ifdef BYFOUR
61 typedef u4 crc_table_t; 61 typedef u4 crc_table_t;
62# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
63 (((w)&0xff00)<<8)+(((w)&0xff)<<24))
64 local unsigned long crc32_little OF((unsigned long, 62 local unsigned long crc32_little OF((unsigned long,
65 const unsigned char FAR *, unsigned)); 63 const unsigned char FAR *, unsigned));
66 local unsigned long crc32_big OF((unsigned long, 64 local unsigned long crc32_big OF((unsigned long,
@@ -145,11 +143,11 @@ local void make_crc_table()
145 and then the byte reversal of those as well as the first table */ 143 and then the byte reversal of those as well as the first table */
146 for (n = 0; n < 256; n++) { 144 for (n = 0; n < 256; n++) {
147 c = crc_table[0][n]; 145 c = crc_table[0][n];
148 crc_table[4][n] = REV(c); 146 crc_table[4][n] = ZSWAP32(c);
149 for (k = 1; k < 4; k++) { 147 for (k = 1; k < 4; k++) {
150 c = crc_table[0][c & 0xff] ^ (c >> 8); 148 c = crc_table[0][c & 0xff] ^ (c >> 8);
151 crc_table[k][n] = c; 149 crc_table[k][n] = c;
152 crc_table[k + 4][n] = REV(c); 150 crc_table[k + 4][n] = ZSWAP32(c);
153 } 151 }
154 } 152 }
155#endif /* BYFOUR */ 153#endif /* BYFOUR */
@@ -317,7 +315,7 @@ local unsigned long crc32_big(crc, buf, len)
317 register u4 c; 315 register u4 c;
318 register const u4 FAR *buf4; 316 register const u4 FAR *buf4;
319 317
320 c = REV((u4)crc); 318 c = ZSWAP32((u4)crc);
321 c = ~c; 319 c = ~c;
322 while (len && ((ptrdiff_t)buf & 3)) { 320 while (len && ((ptrdiff_t)buf & 3)) {
323 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); 321 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
@@ -341,7 +339,7 @@ local unsigned long crc32_big(crc, buf, len)
341 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8); 339 c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
342 } while (--len); 340 } while (--len);
343 c = ~c; 341 c = ~c;
344 return (unsigned long)(REV(c)); 342 return (unsigned long)(ZSWAP32(c));
345} 343}
346 344
347#endif /* BYFOUR */ 345#endif /* BYFOUR */