summaryrefslogtreecommitdiff
path: root/adler32.c
diff options
context:
space:
mode:
authorHans Kristian Rosbach <hk-git@circlestorm.org>2015-05-25 23:03:25 +0200
committerHans Kristian Rosbach <hk-git@circlestorm.org>2015-05-25 23:03:25 +0200
commitd9b63c782f7f7ed44ce1e332a17e137796e8b2d1 (patch)
tree6937c47b52acb60af25dc491a48cce509c3cc58f /adler32.c
parent7e13ce3e3da11a83a893988fc0aa59302866f1e4 (diff)
Style cleanup for adler/crc code
Diffstat (limited to 'adler32.c')
-rw-r--r--adler32.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/adler32.c b/adler32.c
index 7cded1d..f2dd922 100644
--- a/adler32.c
+++ b/adler32.c
@@ -7,17 +7,17 @@
#include "zutil.h"
-static uint32_t adler32_combine_ (uint32_t adler1, uint32_t adler2, z_off64_t len2);
+static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2);
#define BASE 65521 /* largest prime smaller than 65536 */
#define NMAX 5552
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
+#define DO1(buf, i) {adler += (buf)[i]; sum2 += adler;}
+#define DO2(buf, i) DO1(buf, i); DO1(buf, i+1);
+#define DO4(buf, i) DO2(buf, i); DO2(buf, i+2);
+#define DO8(buf, i) DO4(buf, i); DO4(buf, i+4);
+#define DO16(buf) DO8(buf, 0); DO8(buf, 8);
/* use NO_DIVIDE if your processor does not do division in hardware --
try it both ways to see which is faster */
@@ -60,8 +60,7 @@ static uint32_t adler32_combine_ (uint32_t adler1, uint32_t adler2, z_off64_t le
#endif
/* ========================================================================= */
-uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len)
-{
+uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len) {
uint32_t sum2;
unsigned n;
@@ -109,7 +108,7 @@ uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len)
DO16(buf); /* 16 sums unrolled */
buf += 16;
#else
- DO8(buf,0); /* 8 sums unrolled */
+ DO8(buf, 0); /* 8 sums unrolled */
buf += 8;
#endif
} while (--n);
@@ -144,8 +143,7 @@ uint32_t ZEXPORT adler32(uint32_t adler, const unsigned char *buf, uInt len)
}
/* ========================================================================= */
-static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2)
-{
+static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2) {
uint32_t sum1;
uint32_t sum2;
unsigned rem;
@@ -170,12 +168,10 @@ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len
}
/* ========================================================================= */
-uint32_t ZEXPORT adler32_combine(uint32_t adler1, uint32_t adler2, z_off_t len2)
-{
+uint32_t ZEXPORT adler32_combine(uint32_t adler1, uint32_t adler2, z_off_t len2) {
return adler32_combine_(adler1, adler2, len2);
}
-uint32_t ZEXPORT adler32_combine64(uint32_t adler1, uint32_t adler2, z_off64_t len2)
-{
+uint32_t ZEXPORT adler32_combine64(uint32_t adler1, uint32_t adler2, z_off64_t len2) {
return adler32_combine_(adler1, adler2, len2);
}