22 #pragma csect( CODE, "adler32C" )
23 #pragma csect( STATIC, "adler32S" )
24 #pragma csect( TEST, "adler32T" )
28 #if defined( INC_ALL )
42 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
43 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
44 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
45 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
46 #define DO16(buf) DO8(buf,0); DO8(buf,8);
52 if (a >= (BASE << 16)) a -= (BASE << 16); \
53 if (a >= (BASE << 15)) a -= (BASE << 15); \
54 if (a >= (BASE << 14)) a -= (BASE << 14); \
55 if (a >= (BASE << 13)) a -= (BASE << 13); \
56 if (a >= (BASE << 12)) a -= (BASE << 12); \
57 if (a >= (BASE << 11)) a -= (BASE << 11); \
58 if (a >= (BASE << 10)) a -= (BASE << 10); \
59 if (a >= (BASE << 9)) a -= (BASE << 9); \
60 if (a >= (BASE << 8)) a -= (BASE << 8); \
61 if (a >= (BASE << 7)) a -= (BASE << 7); \
62 if (a >= (BASE << 6)) a -= (BASE << 6); \
63 if (a >= (BASE << 5)) a -= (BASE << 5); \
64 if (a >= (BASE << 4)) a -= (BASE << 4); \
65 if (a >= (BASE << 3)) a -= (BASE << 3); \
66 if (a >= (BASE << 2)) a -= (BASE << 2); \
67 if (a >= (BASE << 1)) a -= (BASE << 1); \
68 if (a >= BASE) a -= BASE; \
72 if (a >= (BASE << 4)) a -= (BASE << 4); \
73 if (a >= (BASE << 3)) a -= (BASE << 3); \
74 if (a >= (BASE << 2)) a -= (BASE << 2); \
75 if (a >= (BASE << 1)) a -= (BASE << 1); \
76 if (a >= BASE) a -= BASE; \
79 # define MOD(a) a %= BASE
80 # define MOD4(a) a %= BASE
90 sum2 = (adler >> 16) & 0xffff;
101 return adler | (sum2 << 16);
117 return adler | (sum2 << 16);
121 while (len >=
NMAX) {
148 return adler | (sum2 << 16);
159 rem = (unsigned)(len2 %
BASE);
160 sum1 = adler1 & 0xffff;
163 sum1 += (adler2 & 0xffff) + BASE - 1;
164 sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
165 if (sum1 >= BASE) sum1 -=
BASE;
166 if (sum1 >= BASE) sum1 -=
BASE;
167 if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
168 if (sum2 >= BASE) sum2 -=
BASE;
169 return sum1 | (sum2 << 16);