]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
adler32: unsigned long -> uint32_t
authorDaniel Axtens <dja@axtens.net>
Mon, 11 May 2015 13:23:13 +0000 (23:23 +1000)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 11 May 2015 19:06:04 +0000 (21:06 +0200)
Authored by Danial Axtens, with some minor merge fixups by Hans Kristian Rosbach.

Conflicts:
adler32.c
zlib.h
zutil.h

adler32.c
zlib.h
zutil.h

index 3eb1153287493f347725e4ce999d746547ae7c35..6d32159c13f32f5caf0e9148923efb244c9afe13 100644 (file)
--- a/adler32.c
+++ b/adler32.c
@@ -6,10 +6,9 @@
 /* @(#) $Id$ */
 
 #include "zutil.h"
+#include <stdint.h>
 
-#define local static
-
-static uLong adler32_combine_ (uLong adler1, uLong 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
@@ -28,8 +27,8 @@ static uLong adler32_combine_ (uLong adler1, uLong adler2, z_off64_t len2);
    (thank you to John Reiser for pointing this out) */
 #  define CHOP(a) \
     do { \
-        unsigned long tmp = a >> 16; \
-        a &= 0xffffUL; \
+        uint32_t tmp = a >> 16; \
+        a &= 0xffff; \
         a += (tmp << 4) - tmp; \
     } while (0)
 #  define MOD28(a) \
@@ -62,12 +61,12 @@ static uLong adler32_combine_ (uLong adler1, uLong adler2, z_off64_t len2);
 #endif
 
 /* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
-    uLong adler;
+uint32_t ZEXPORT adler32(adler, buf, len)
+    uint32_t adler;
     const Byte *buf;
     uInt len;
 {
-    unsigned long sum2;
+    uint32_t sum2;
     unsigned n;
 
     /* split Adler-32 into component sums */
@@ -149,15 +148,15 @@ uLong ZEXPORT adler32(adler, buf, len)
 }
 
 /* ========================================================================= */
-static uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
+static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2)
 {
-    unsigned long sum1;
-    unsigned long sum2;
+    uint32_t sum1;
+    uint32_t sum2;
     unsigned rem;
 
     /* for negative len, return invalid adler32 as a clue for debugging */
     if (len2 < 0)
-        return 0xffffffffUL;
+        return 0xffffffff;
 
     /* the derivation of this formula is left as an exercise for the reader */
     MOD63(len2);                /* assumes len2 >= 0 */
@@ -175,17 +174,17 @@ static uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2)
 }
 
 /* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
-    uLong adler1;
-    uLong adler2;
+uint32_t ZEXPORT adler32_combine(adler1, adler2, len2)
+    uint32_t adler1;
+    uint32_t adler2;
     z_off_t len2;
 {
     return adler32_combine_(adler1, adler2, len2);
 }
 
-uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
-    uLong adler1;
-    uLong adler2;
+uint32_t ZEXPORT adler32_combine64(adler1, adler2, len2)
+    uint32_t adler1;
+    uint32_t adler2;
     z_off64_t len2;
 {
     return adler32_combine_(adler1, adler2, len2);
diff --git a/zlib.h b/zlib.h
index 2d5b6298a0dfb0617c4ca64311137e95f77abd35..cc52572cc3f45327e52ca7f5c5b1b639629fe3ab 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -107,7 +107,7 @@ typedef struct z_stream_s {
     void      *opaque;  /* private data object passed to zalloc and zfree */
 
     int     data_type;  /* best guess about the data type: binary or text */
-    uLong   adler;      /* adler32 value of the uncompressed data */
+    uint32_t   adler;      /* adler32 value of the uncompressed data */
     uLong   reserved;   /* reserved for future use */
 } z_stream;
 
@@ -1564,7 +1564,7 @@ ZEXTERN void ZEXPORT gzclearerr (gzFile file);
    library.
 */
 
-ZEXTERN uLong ZEXPORT adler32 (uLong adler, const Byte *buf, uInt len);
+ZEXTERN uint32_t ZEXPORT adler32 (uint32_t adler, const Byte *buf, uInt len);
 /*
      Update a running Adler-32 checksum with the bytes buf[0..len-1] and
    return the updated checksum.  If buf is Z_NULL, this function returns the
@@ -1575,7 +1575,7 @@ ZEXTERN uLong ZEXPORT adler32 (uLong adler, const Byte *buf, uInt len);
 
    Usage example:
 
-     uLong adler = adler32(0L, Z_NULL, 0);
+     uint32_t adler = adler32(0L, Z_NULL, 0);
 
      while (read_buffer(buffer, length) != EOF) {
        adler = adler32(adler, buffer, length);
@@ -1584,7 +1584,7 @@ ZEXTERN uLong ZEXPORT adler32 (uLong adler, const Byte *buf, uInt len);
 */
 
 /*
-ZEXTERN uLong ZEXPORT adler32_combine (uLong adler1, uLong adler2,
+ZEXTERN uint32_t ZEXPORT adler32_combine (uint32_t adler1, uint32_t adler2,
                                           z_off_t len2);
 
      Combine two Adler-32 checksums into one.  For two sequences of bytes, seq1
@@ -1684,7 +1684,7 @@ ZEXTERN int ZEXPORT gzgetc_ (gzFile file);  /* backward compatibility */
    ZEXTERN z_off64_t ZEXPORT gzseek64 (gzFile, z_off64_t, int);
    ZEXTERN z_off64_t ZEXPORT gztell64 (gzFile);
    ZEXTERN z_off64_t ZEXPORT gzoffset64 (gzFile);
-   ZEXTERN uLong ZEXPORT adler32_combine64 (uLong, uLong, z_off64_t);
+   ZEXTERN uint32_t ZEXPORT adler32_combine64 (uint32_t, uint32_t, z_off64_t);
    ZEXTERN uint32_t ZEXPORT crc32_combine64 (uint32_t, uint32_t, z_off64_t);
 #endif
 
@@ -1709,7 +1709,7 @@ ZEXTERN int ZEXPORT gzgetc_ (gzFile file);  /* backward compatibility */
      ZEXTERN z_off_t ZEXPORT gzseek64 (gzFile, z_off_t, int);
      ZEXTERN z_off_t ZEXPORT gztell64 (gzFile);
      ZEXTERN z_off_t ZEXPORT gzoffset64 (gzFile);
-     ZEXTERN uLong ZEXPORT adler32_combine64 (uLong, uLong, z_off_t);
+     ZEXTERN uint32_t ZEXPORT adler32_combine64 (uint32_t, uint32_t, z_off_t);
      ZEXTERN uint32_t ZEXPORT crc32_combine64 (uint32_t, uint32_t, z_off_t);
 #  endif
 #else
@@ -1717,7 +1717,7 @@ ZEXTERN int ZEXPORT gzgetc_ (gzFile file);  /* backward compatibility */
    ZEXTERN z_off_t ZEXPORT gzseek (gzFile, z_off_t, int);
    ZEXTERN z_off_t ZEXPORT gztell (gzFile);
    ZEXTERN z_off_t ZEXPORT gzoffset (gzFile);
-   ZEXTERN uLong ZEXPORT adler32_combine (uLong, uLong, z_off_t);
+   ZEXTERN uint32_t ZEXPORT adler32_combine (uint32_t, uint32_t, z_off_t);
    ZEXTERN uint32_t ZEXPORT crc32_combine (uint32_t, uint32_t, z_off_t);
 #endif
 
diff --git a/zutil.h b/zutil.h
index d512015514511f34d8901fdd2bbe850959f33c89..31b411dbcb54f538cfa57bde7e2e227892c3b096 100644 (file)
--- a/zutil.h
+++ b/zutil.h
@@ -88,7 +88,7 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
 
 /* provide prototypes for these when building zlib without LFS */
 #if !defined(_WIN32) && (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
-    ZEXTERN uLong ZEXPORT adler32_combine64 (uLong, uLong, z_off_t);
+    ZEXTERN uint32_t ZEXPORT adler32_combine64 (uint32_t, uint32_t, z_off_t);
     ZEXTERN uint32_t ZEXPORT crc32_combine64 (uint32_t, uint32_t, z_off_t);
 #endif