summaryrefslogtreecommitdiff
path: root/adler32.c
diff options
context:
space:
mode:
Diffstat (limited to 'adler32.c')
-rw-r--r--adler32.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/adler32.c b/adler32.c
index 007ba26..8bf7dc4 100644
--- a/adler32.c
+++ b/adler32.c
@@ -1,5 +1,5 @@
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-2006 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
@@ -8,6 +8,15 @@
8#define ZLIB_INTERNAL 8#define ZLIB_INTERNAL
9#include "zlib.h" 9#include "zlib.h"
10 10
11#define local static
12
13#ifdef _LARGEFILE64_SOURCE
14 local uLong adler32_combine_(uLong adler1, uLong adler2, off64_t len2);
15#else
16 local uLong adler32_combine_(uLong adler1, uLong adler2, z_off_t len2);
17#endif
18
19
11#define BASE 65521UL /* largest prime smaller than 65536 */ 20#define BASE 65521UL /* largest prime smaller than 65536 */
12#define NMAX 5552 21#define NMAX 5552
13/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 22/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
@@ -125,10 +134,14 @@ uLong ZEXPORT adler32(adler, buf, len)
125} 134}
126 135
127/* ========================================================================= */ 136/* ========================================================================= */
128uLong ZEXPORT adler32_combine(adler1, adler2, len2) 137local uLong adler32_combine_(adler1, adler2, len2)
129 uLong adler1; 138 uLong adler1;
130 uLong adler2; 139 uLong adler2;
140#ifdef _LARGEFILE64_SOURCE
141 off64_t len2;
142#else
131 z_off_t len2; 143 z_off_t len2;
144#endif
132{ 145{
133 unsigned long sum1; 146 unsigned long sum1;
134 unsigned long sum2; 147 unsigned long sum2;
@@ -147,3 +160,30 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
147 if (sum2 > BASE) sum2 -= BASE; 160 if (sum2 > BASE) sum2 -= BASE;
148 return sum1 | (sum2 << 16); 161 return sum1 | (sum2 << 16);
149} 162}
163
164/* ========================================================================= */
165uLong ZEXPORT adler32_combine(adler1, adler2, len2)
166 uLong adler1;
167 uLong adler2;
168 z_off_t len2;
169{
170 return adler32_combine_(adler1, adler2, len2);
171}
172
173#ifdef _LARGEFILE64_SOURCE
174uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
175 uLong adler1;
176 uLong adler2;
177 off64_t len2;
178{
179 return adler32_combine_(adler1, adler2, len2);
180}
181#else
182uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
183 uLong adler1;
184 uLong adler2;
185 z_off_t len2;
186{
187 return adler32_combine_(adler1, adler2, len2);
188}
189#endif