]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix signature of crc32_combine(), crc32_combine64() and crc32_z() in compat mode.
authorMika Lindqvist <postmaster@raasu.org>
Fri, 17 Jul 2020 00:52:29 +0000 (03:52 +0300)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 14 Aug 2020 20:21:37 +0000 (22:21 +0200)
crc32.c
zlib.h

diff --git a/crc32.c b/crc32.c
index fa61a0d0736930ec15db9a63882a871485b34e96..adf9d55a931a45cc3099f3ed81ee55676f262070 100644 (file)
--- a/crc32.c
+++ b/crc32.c
@@ -29,11 +29,19 @@ const uint32_t * ZEXPORT PREFIX(get_crc_table)(void) {
     return (const uint32_t *)crc_table;
 }
 
+#ifdef ZLIB_COMPAT
+unsigned long ZEXPORT PREFIX(crc32_z)(unsigned long crc, const unsigned char *buf, size_t len) {
+    if (buf == NULL) return 0;
+
+    return (unsigned long) functable.crc32((uint32_t) crc, buf, len);
+}
+#else
 uint32_t ZEXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) {
     if (buf == NULL) return 0;
 
     return functable.crc32(crc, buf, len);
 }
+#endif
 /* ========================================================================= */
 #define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
 #define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
@@ -182,14 +190,18 @@ static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
 
 /* ========================================================================= */
 #ifdef ZLIB_COMPAT
-uint32_t ZEXPORT PREFIX(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off_t len2) {
-    return crc32_combine_(crc1, crc2, len2);
+unsigned long ZEXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) {
+    return (unsigned long) crc32_combine_((uint32_t) crc1, (uint32_t) crc2, len2);
 }
-#endif
 
+unsigned long ZEXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) {
+    return (unsigned long) crc32_combine_((uint32_t) crc1, (uint32_t) crc2, len2);
+}
+#else
 uint32_t ZEXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
     return crc32_combine_(crc1, crc2, len2);
 }
+#endif
 
 #ifdef X86_PCLMULQDQ_CRC
 #include "arch/x86/x86.h"
diff --git a/zlib.h b/zlib.h
index fe4fd86aac8c87b541d422749b83d1630233948f..5922c4d181968d90e24b1eb26240053f09616c0b 100644 (file)
--- a/zlib.h
+++ b/zlib.h
@@ -1697,13 +1697,13 @@ ZEXTERN unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char *buf,
      if (crc != original_crc) error();
 */
 
-ZEXTERN uint32_t ZEXPORT crc32_z (uint32_t crc, const unsigned char *buf, size_t len);
+ZEXTERN unsigned long ZEXPORT crc32_z (unsigned long crc, const unsigned char *buf, size_t len);
 /*
      Same as crc32(), but with a size_t length.
 */
 
 /*
-ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t crc1, uint32_t crc2, z_off64_t len2);
+ZEXTERN unsigned long ZEXPORT crc32_combine(unsigned long crc1, unsigned long crc2, z_off64_t len2);
 
      Combine two CRC-32 check values into one.  For two sequences of bytes,
    seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
@@ -1778,7 +1778,7 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file);  /* backward compatibility */
    ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
    ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
    ZEXTERN unsigned long ZEXPORT adler32_combine64(unsigned long, unsigned long, z_off64_t);
-   ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off64_t);
+   ZEXTERN unsigned long ZEXPORT crc32_combine64(unsigned long, unsigned long, z_off64_t);
    ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t);
 #endif
 
@@ -1796,7 +1796,7 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file);  /* backward compatibility */
      ZEXTERN z_off_t ZEXPORT gztell64(gzFile);
      ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile);
      ZEXTERN unsigned long ZEXPORT adler32_combine64(unsigned long, unsigned long, z_off_t);
-     ZEXTERN uint32_t ZEXPORT crc32_combine64(uint32_t, uint32_t, z_off_t);
+     ZEXTERN unsigned long ZEXPORT crc32_combine64(unsigned long, unsigned long, z_off_t);
      ZEXTERN void ZEXPORT crc32_combine_gen64(uint32_t *op, z_off64_t);
 #  endif
 #else
@@ -1805,7 +1805,7 @@ ZEXTERN int ZEXPORT gzgetc_(gzFile file);  /* backward compatibility */
    ZEXTERN z_off_t ZEXPORT gztell(gzFile);
    ZEXTERN z_off_t ZEXPORT gzoffset(gzFile);
    ZEXTERN unsigned long ZEXPORT adler32_combine(unsigned long, unsigned long, z_off_t);
-   ZEXTERN uint32_t ZEXPORT crc32_combine(uint32_t, uint32_t, z_off_t);
+   ZEXTERN unsigned long ZEXPORT crc32_combine(unsigned long, unsigned long, z_off_t);
    ZEXTERN void ZEXPORT crc32_combine_gen(uint32_t *op, z_off_t);
 #endif