mirror of
https://github.com/GerbilSoft/zlib-ng.git
synced 2025-06-18 11:35:35 -04:00
Replace DO1/DO8 macros
This commit is contained in:
parent
5fb2a1c493
commit
ed30965e29
14
adler32_p.h
14
adler32_p.h
@ -12,11 +12,11 @@
|
|||||||
#define NMAX 5552
|
#define NMAX 5552
|
||||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||||
|
|
||||||
#define DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);}
|
#define ADLER_DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);}
|
||||||
#define DO2(sum1, sum2, buf, i) {DO1(sum1, sum2, buf, i); DO1(sum1, sum2, buf, i+1);}
|
#define ADLER_DO2(sum1, sum2, buf, i) {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
|
||||||
#define DO4(sum1, sum2, buf, i) {DO2(sum1, sum2, buf, i); DO2(sum1, sum2, buf, i+2);}
|
#define ADLER_DO4(sum1, sum2, buf, i) {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
|
||||||
#define DO8(sum1, sum2, buf, i) {DO4(sum1, sum2, buf, i); DO4(sum1, sum2, buf, i+4);}
|
#define ADLER_DO8(sum1, sum2, buf, i) {ADLER_DO4(sum1, sum2, buf, i); ADLER_DO4(sum1, sum2, buf, i+4);}
|
||||||
#define DO16(sum1, sum2, buf) {DO8(sum1, sum2, buf, 0); DO8(sum1, sum2, buf, 8);}
|
#define ADLER_DO16(sum1, sum2, buf) {ADLER_DO8(sum1, sum2, buf, 0); ADLER_DO8(sum1, sum2, buf, 8);}
|
||||||
|
|
||||||
static inline uint32_t adler32_len_1(uint32_t adler, const uint8_t *buf, uint32_t sum2) {
|
static inline uint32_t adler32_len_1(uint32_t adler, const uint8_t *buf, uint32_t sum2) {
|
||||||
adler += buf[0];
|
adler += buf[0];
|
||||||
@ -54,12 +54,12 @@ static inline uint32_t adler32_len_64(uint32_t adler, const uint8_t *buf, size_t
|
|||||||
#ifdef UNROLL_MORE
|
#ifdef UNROLL_MORE
|
||||||
while (len >= 16) {
|
while (len >= 16) {
|
||||||
len -= 16;
|
len -= 16;
|
||||||
DO16(adler, sum2, buf);
|
ADLER_DO16(adler, sum2, buf);
|
||||||
buf += 16;
|
buf += 16;
|
||||||
#else
|
#else
|
||||||
while (len >= 8) {
|
while (len >= 8) {
|
||||||
len -= 8;
|
len -= 8;
|
||||||
DO8(adler, sum2, buf, 0);
|
ADLER_DO8(adler, sum2, buf, 0);
|
||||||
buf += 8;
|
buf += 8;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -38,10 +38,10 @@ Z_INTERNAL uint32_t adler32_c(uint32_t adler, const uint8_t *buf, size_t len) {
|
|||||||
#endif
|
#endif
|
||||||
do {
|
do {
|
||||||
#ifdef UNROLL_MORE
|
#ifdef UNROLL_MORE
|
||||||
DO16(adler, sum2, buf); /* 16 sums unrolled */
|
ADLER_DO16(adler, sum2, buf); /* 16 sums unrolled */
|
||||||
buf += 16;
|
buf += 16;
|
||||||
#else
|
#else
|
||||||
DO8(adler, sum2, buf, 0); /* 8 sums unrolled */
|
ADLER_DO8(adler, sum2, buf, 0); /* 8 sums unrolled */
|
||||||
buf += 8;
|
buf += 8;
|
||||||
#endif
|
#endif
|
||||||
} while (--n);
|
} while (--n);
|
||||||
|
@ -72,7 +72,7 @@ Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t
|
|||||||
/* Compute the CRC up to a z_word_t boundary. */
|
/* Compute the CRC up to a z_word_t boundary. */
|
||||||
while (len && ((uintptr_t)buf & (BRAID_W - 1)) != 0) {
|
while (len && ((uintptr_t)buf & (BRAID_W - 1)) != 0) {
|
||||||
len--;
|
len--;
|
||||||
DO1;
|
CRC_DO1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compute the CRC on as many BRAID_N z_word_t blocks as are available. */
|
/* Compute the CRC on as many BRAID_N z_word_t blocks as are available. */
|
||||||
@ -201,11 +201,11 @@ Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t
|
|||||||
/* Complete the computation of the CRC on any remaining bytes. */
|
/* Complete the computation of the CRC on any remaining bytes. */
|
||||||
while (len >= 8) {
|
while (len >= 8) {
|
||||||
len -= 8;
|
len -= 8;
|
||||||
DO8;
|
CRC_DO8;
|
||||||
}
|
}
|
||||||
while (len) {
|
while (len) {
|
||||||
len--;
|
len--;
|
||||||
DO1;
|
CRC_DO1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the CRC, post-conditioned. */
|
/* Return the CRC, post-conditioned. */
|
||||||
|
@ -398,7 +398,7 @@ static inline uint32_t crc32_small(uint32_t crc, const uint8_t *buf, size_t len)
|
|||||||
|
|
||||||
while (len) {
|
while (len) {
|
||||||
len--;
|
len--;
|
||||||
DO1;
|
CRC_DO1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c ^ 0xffffffff;
|
return c ^ 0xffffffff;
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
# error "No endian defined"
|
# error "No endian defined"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
|
#define CRC_DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
|
||||||
#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
|
#define CRC_DO8 CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1
|
||||||
|
|
||||||
/* CRC polynomial. */
|
/* CRC polynomial. */
|
||||||
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
|
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
|
||||||
|
Loading…
Reference in New Issue
Block a user