summaryrefslogtreecommitdiff
path: root/crc32.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2012-02-11 00:26:38 -0800
committerMark Adler <madler@alumni.caltech.edu>2012-02-11 00:26:38 -0800
commit7d45cf5a1dbe9d34f9fb18e2f485efda83019493 (patch)
tree290e01d92e398389e83c943ca26e4c9201d3a5bb /crc32.c
parent1a4ba8cd912466fe538f62d61fbcc25eead6d31a (diff)
downloadzlib-7d45cf5a1dbe9d34f9fb18e2f485efda83019493.tar.gz
Use optimized byte swap operations for Microsoft and GNU [Snyder].
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 @@
/* Definitions for doing the crc four data bytes at a time. */
#ifdef BYFOUR
typedef u4 crc_table_t;
-# define REV(w) ((((w)>>24)&0xff)+(((w)>>8)&0xff00)+ \
- (((w)&0xff00)<<8)+(((w)&0xff)<<24))
local unsigned long crc32_little OF((unsigned long,
const unsigned char FAR *, unsigned));
local unsigned long crc32_big OF((unsigned long,
@@ -145,11 +143,11 @@ local void make_crc_table()
and then the byte reversal of those as well as the first table */
for (n = 0; n < 256; n++) {
c = crc_table[0][n];
- crc_table[4][n] = REV(c);
+ crc_table[4][n] = ZSWAP32(c);
for (k = 1; k < 4; k++) {
c = crc_table[0][c & 0xff] ^ (c >> 8);
crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
+ crc_table[k + 4][n] = ZSWAP32(c);
}
}
#endif /* BYFOUR */
@@ -317,7 +315,7 @@ local unsigned long crc32_big(crc, buf, len)
register u4 c;
register const u4 FAR *buf4;
- c = REV((u4)crc);
+ c = ZSWAP32((u4)crc);
c = ~c;
while (len && ((ptrdiff_t)buf & 3)) {
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
@@ -341,7 +339,7 @@ local unsigned long crc32_big(crc, buf, len)
c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
} while (--len);
c = ~c;
- return (unsigned long)(REV(c));
+ return (unsigned long)(ZSWAP32(c));
}
#endif /* BYFOUR */