summaryrefslogtreecommitdiffstats
path: root/Modules/zlib/adler32.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2010-07-30 20:03:17 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2010-07-30 20:03:17 (GMT)
commitce126edfd0df77da41b961f85d82d94c450c61f1 (patch)
tree10f6b5021ff273b85aa70f05e9cd1e450944dea5 /Modules/zlib/adler32.c
parentd496c4c9360b481ca68b68b6bba6b6687136e442 (diff)
downloadcpython-ce126edfd0df77da41b961f85d82d94c450c61f1.zip
cpython-ce126edfd0df77da41b961f85d82d94c450c61f1.tar.gz
cpython-ce126edfd0df77da41b961f85d82d94c450c61f1.tar.bz2
Import files from zlib 1.2.5.
Diffstat (limited to 'Modules/zlib/adler32.c')
-rw-r--r--Modules/zlib/adler32.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/Modules/zlib/adler32.c b/Modules/zlib/adler32.c
index 007ba26..65ad6a5 100644
--- a/Modules/zlib/adler32.c
+++ b/Modules/zlib/adler32.c
@@ -1,12 +1,15 @@
/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
+ * Copyright (C) 1995-2007 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
-#define ZLIB_INTERNAL
-#include "zlib.h"
+#include "zutil.h"
+
+#define local static
+
+local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2);
#define BASE 65521UL /* largest prime smaller than 65536 */
#define NMAX 5552
@@ -125,10 +128,10 @@ uLong ZEXPORT adler32(adler, buf, len)
}
/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
+local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
- z_off_t len2;
+ z_off64_t len2;
{
unsigned long sum1;
unsigned long sum2;
@@ -141,9 +144,26 @@ uLong ZEXPORT adler32_combine(adler1, adler2, len2)
MOD(sum2);
sum1 += (adler2 & 0xffff) + BASE - 1;
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 > BASE) sum2 -= BASE;
+ if (sum1 >= BASE) sum1 -= BASE;
+ if (sum1 >= BASE) sum1 -= BASE;
+ if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1);
+ if (sum2 >= BASE) sum2 -= BASE;
return sum1 | (sum2 << 16);
}
+
+/* ========================================================================= */
+uLong ZEXPORT adler32_combine(adler1, adler2, len2)
+ uLong adler1;
+ uLong adler2;
+ z_off_t len2;
+{
+ return adler32_combine_(adler1, adler2, len2);
+}
+
+uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
+ uLong adler1;
+ uLong adler2;
+ z_off64_t len2;
+{
+ return adler32_combine_(adler1, adler2, len2);
+}