Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(405)

Side by Side Diff: third_party/zlib/adler32.c

Issue 8806004: Update zlib to 1.2.5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « third_party/zlib/README.chromium ('k') | third_party/zlib/compress.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* adler32.c -- compute the Adler-32 checksum of a data stream 1 /* adler32.c -- compute the Adler-32 checksum of a data stream
2 * Copyright (C) 1995-2004 Mark Adler 2 * Copyright (C) 1995-2007 Mark Adler
3 * For conditions of distribution and use, see copyright notice in zlib.h 3 * For conditions of distribution and use, see copyright notice in zlib.h
4 */ 4 */
5 5
6 /* @(#) $Id: adler32.c,v 3.6 2005/08/04 19:14:14 tor%cs.brown.edu Exp $ */ 6 /* @(#) $Id$ */
7 7
8 #define ZLIB_INTERNAL 8 #include "zutil.h"
9 #include "zlib.h" 9
10 #define local static
11
12 local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
10 13
11 #define BASE 65521UL /* largest prime smaller than 65536 */ 14 #define BASE 65521UL /* largest prime smaller than 65536 */
12 #define NMAX 5552 15 #define NMAX 5552
13 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 16 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
14 17
15 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 18 #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
16 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 19 #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
17 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 20 #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
18 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 21 #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
19 #define DO16(buf) DO8(buf,0); DO8(buf,8); 22 #define DO16(buf) DO8(buf,0); DO8(buf,8);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 } 121 }
119 MOD(adler); 122 MOD(adler);
120 MOD(sum2); 123 MOD(sum2);
121 } 124 }
122 125
123 /* return recombined sums */ 126 /* return recombined sums */
124 return adler | (sum2 << 16); 127 return adler | (sum2 << 16);
125 } 128 }
126 129
127 /* ========================================================================= */ 130 /* ========================================================================= */
128 uLong ZEXPORT adler32_combine(adler1, adler2, len2) 131 local uLong adler32_combine_(adler1, adler2, len2)
129 uLong adler1; 132 uLong adler1;
130 uLong adler2; 133 uLong adler2;
131 z_off_t len2; 134 z_off64_t len2;
132 { 135 {
133 unsigned long sum1; 136 unsigned long sum1;
134 unsigned long sum2; 137 unsigned long sum2;
135 unsigned rem; 138 unsigned rem;
136 139
137 /* the derivation of this formula is left as an exercise for the reader */ 140 /* the derivation of this formula is left as an exercise for the reader */
138 rem = (unsigned)(len2 % BASE); 141 rem = (unsigned)(len2 % BASE);
139 sum1 = adler1 & 0xffff; 142 sum1 = adler1 & 0xffff;
140 sum2 = rem * sum1; 143 sum2 = rem * sum1;
141 MOD(sum2); 144 MOD(sum2);
142 sum1 += (adler2 & 0xffff) + BASE - 1; 145 sum1 += (adler2 & 0xffff) + BASE - 1;
143 sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 146 sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
144 if (sum1 > BASE) sum1 -= BASE; 147 if (sum1 >= BASE) sum1 -= BASE;
145 if (sum1 > BASE) sum1 -= BASE; 148 if (sum1 >= BASE) sum1 -= BASE;
146 if (sum2 > (BASE << 1)) sum2 -= (BASE << 1); 149 if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
147 if (sum2 > BASE) sum2 -= BASE; 150 if (sum2 >= BASE) sum2 -= BASE;
148 return sum1 | (sum2 << 16); 151 return sum1 | (sum2 << 16);
149 } 152 }
153
154 /* ========================================================================= */
155 uLong ZEXPORT adler32_combine(adler1, adler2, len2)
156 uLong adler1;
157 uLong adler2;
158 z_off_t len2;
159 {
160 return adler32_combine_(adler1, adler2, len2);
161 }
162
163 uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
164 uLong adler1;
165 uLong adler2;
166 z_off64_t len2;
167 {
168 return adler32_combine_(adler1, adler2, len2);
169 }
OLDNEW
« no previous file with comments | « third_party/zlib/README.chromium ('k') | third_party/zlib/compress.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698