diff options
author | Nathan Moinvaziri <nathan@nathanm.com> | 2020-08-15 20:06:26 -0700 |
---|---|---|
committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2020-08-16 17:37:04 +0200 |
commit | 193d8fd7dfb7927facab7a3034daa27ad5b9df1c (patch) | |
tree | 5c339842008015efb2d13bdc32c25c8595284e0b /adler32_p.h | |
parent | bcb1d58c05a06c61dac50318bb124413619fb436 (diff) |
Remove NO_DIVIDE from adler32.
Diffstat (limited to 'adler32_p.h')
-rw-r--r-- | adler32_p.h | 42 |
1 files changed, 1 insertions, 41 deletions
diff --git a/adler32_p.h b/adler32_p.h index c196732..7f75c71 100644 --- a/adler32_p.h +++ b/adler32_p.h @@ -18,46 +18,6 @@ #define DO8(sum1, sum2, buf, i) {DO4(sum1, sum2, buf, i); DO4(sum1, sum2, buf, i+4);} #define DO16(sum1, sum2, buf) {DO8(sum1, sum2, buf, 0); DO8(sum1, sum2, buf, 8);} -/* use NO_DIVIDE if your processor does not do division in hardware -- - try it both ways to see which is faster */ -#ifdef NO_DIVIDE -/* note that this assumes BASE is 65521, where 65536 % 65521 == 15 - (thank you to John Reiser for pointing this out) */ -# define CHOP(a) \ - do { \ - uint32_t tmp = a >> 16; \ - a &= 0xffff; \ - a += (tmp << 4) - tmp; \ - } while (0) -# define MOD28(a) \ - do { \ - CHOP(a); \ - if (a >= BASE) a -= BASE; \ - } while (0) -# define MOD(a) \ - do { \ - CHOP(a); \ - MOD28(a); \ - } while (0) -# define MOD63(a) \ - do { /* this assumes a is not negative */ \ - z_off64_t tmp = a >> 32; \ - a &= 0xffffffffL; \ - a += (tmp << 8) - (tmp << 5) + tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - tmp = a >> 16; \ - a &= 0xffffL; \ - a += (tmp << 4) - tmp; \ - if (a >= BASE) a -= BASE; \ - } while (0) -#else -# define MOD(a) a %= BASE -# define MOD28(a) a %= BASE -# define MOD63(a) a %= BASE -#endif - static inline uint32_t adler32_len_1(uint32_t adler, const unsigned char *buf, uint32_t sum2) { adler += buf[0]; if (adler >= BASE) @@ -76,7 +36,7 @@ static inline uint32_t adler32_len_16(uint32_t adler, const unsigned char *buf, } if (adler >= BASE) adler -= BASE; - MOD28(sum2); /* only added so many BASE's */ + sum2 %= BASE; /* only added so many BASE's */ return adler | (sum2 << 16); } |