]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Use PREFIX() for some of the Z_INTERNAL symbols
authorIlya Leoshkevich <iii@linux.ibm.com>
Tue, 12 Apr 2022 13:16:20 +0000 (15:16 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 27 Apr 2022 08:37:43 +0000 (10:37 +0200)
https://github.com/powturbo/TurboBench links zlib and zlib-ng into the
same binary, causing non-static symbol conflicts. Fix by using PREFIX()
for flush_pending(), bi_reverse(), inflate_ensure_window() and all of
the IBM Z symbols.

Note: do not use an explicit zng_, since one of the long-term goals is
to be able to link two versions of zlib-ng into the same binary for
benchmarking [1].

[1] https://github.com/zlib-ng/zlib-ng/pull/1248#issuecomment-1096648932

23 files changed:
arch/s390/crc32-vx.c
arch/s390/dfltcc_common.c
arch/s390/dfltcc_common.h
arch/s390/dfltcc_deflate.c
arch/s390/dfltcc_deflate.h
arch/s390/dfltcc_inflate.c
arch/s390/dfltcc_inflate.h
arch/s390/s390_features.c
arch/s390/s390_features.h
cpu_features.c
cpu_features.h
deflate.c
deflate.h
deflate_p.h
deflate_quick.c
deflate_stored.c
functable.c
inflate.c
inflate.h
test/benchmarks/benchmark_crc32.cc
test/test_crc32.cc
tools/maketrees.c
trees.c

index e7a6109502705214994ae705a8b1cf2c2354f24c..3477743ddba1a80223850ee403323cfd3be0a48c 100644 (file)
@@ -198,7 +198,7 @@ static uint32_t crc32_le_vgfm_16(uint32_t crc, const unsigned char *buf, size_t
 #define VX_ALIGNMENT 16L
 #define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
 
-uint32_t Z_INTERNAL s390_crc32_vx(uint32_t crc, const unsigned char *buf, uint64_t len) {
+uint32_t Z_INTERNAL PREFIX(s390_crc32_vx)(uint32_t crc, const unsigned char *buf, uint64_t len) {
     uint64_t prealign, aligned, remaining;
 
     if (len < VX_MIN_LEN + VX_ALIGN_MASK)
index f1ae904ad57934261edc40de7241d6fc9d023157..a5b5e1f3f31ad40e3987f5a4e3295ce8b55112c9 100644 (file)
@@ -35,7 +35,7 @@ static inline int is_dfltcc_enabled(void) {
     return is_bit_set((const char *)facilities, DFLTCC_FACILITY);
 }
 
-void Z_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) {
+void Z_INTERNAL PREFIX(dfltcc_reset)(PREFIX3(streamp) strm, uInt size) {
     struct dfltcc_state *dfltcc_state = (struct dfltcc_state *)((char *)strm->state + ALIGN_UP(size, 8));
     struct dfltcc_qaf_param *param = (struct dfltcc_qaf_param *)&dfltcc_state->param;
 
@@ -58,17 +58,17 @@ void Z_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size) {
     dfltcc_state->param.ribm = DFLTCC_RIBM;
 }
 
-void Z_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size) {
+void Z_INTERNAL *PREFIX(dfltcc_alloc_state)(PREFIX3(streamp) strm, uInt items, uInt size) {
     return ZALLOC(strm, ALIGN_UP(items * size, 8) + sizeof(struct dfltcc_state), sizeof(unsigned char));
 }
 
-void Z_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size) {
+void Z_INTERNAL PREFIX(dfltcc_copy_state)(void *dst, const void *src, uInt size) {
     memcpy(dst, src, ALIGN_UP(size, 8) + sizeof(struct dfltcc_state));
 }
 
 static const int PAGE_ALIGN = 0x1000;
 
-void Z_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size) {
+void Z_INTERNAL *PREFIX(dfltcc_alloc_window)(PREFIX3(streamp) strm, uInt items, uInt size) {
     void *p;
     void *w;
 
@@ -83,7 +83,7 @@ void Z_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt siz
     return w;
 }
 
-void Z_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w) {
+void Z_INTERNAL PREFIX(dfltcc_free_window)(PREFIX3(streamp) strm, void *w) {
     if (w)
         ZFREE(strm, *(void **)((unsigned char *)w - sizeof(void *)));
 }
index df4b8b5784454e0130037c95f44045567ab5dd60..374e06e27161c32d9c2fddda63d717a9f38b38a3 100644 (file)
@@ -3,23 +3,23 @@
 
 #include "zutil.h"
 
-void Z_INTERNAL *dfltcc_alloc_state(PREFIX3(streamp) strm, uInt items, uInt size);
-void Z_INTERNAL dfltcc_copy_state(void *dst, const void *src, uInt size);
-void Z_INTERNAL dfltcc_reset(PREFIX3(streamp) strm, uInt size);
-void Z_INTERNAL *dfltcc_alloc_window(PREFIX3(streamp) strm, uInt items, uInt size);
-void Z_INTERNAL dfltcc_free_window(PREFIX3(streamp) strm, void *w);
+void Z_INTERNAL *PREFIX(dfltcc_alloc_state)(PREFIX3(streamp) strm, uInt items, uInt size);
+void Z_INTERNAL PREFIX(dfltcc_copy_state)(void *dst, const void *src, uInt size);
+void Z_INTERNAL PREFIX(dfltcc_reset)(PREFIX3(streamp) strm, uInt size);
+void Z_INTERNAL *PREFIX(dfltcc_alloc_window)(PREFIX3(streamp) strm, uInt items, uInt size);
+void Z_INTERNAL PREFIX(dfltcc_free_window)(PREFIX3(streamp) strm, void *w);
 
-#define ZALLOC_STATE dfltcc_alloc_state
+#define ZALLOC_STATE PREFIX(dfltcc_alloc_state)
 
 #define ZFREE_STATE ZFREE
 
-#define ZCOPY_STATE dfltcc_copy_state
+#define ZCOPY_STATE PREFIX(dfltcc_copy_state)
 
-#define ZALLOC_WINDOW dfltcc_alloc_window
+#define ZALLOC_WINDOW PREFIX(dfltcc_alloc_window)
 
-#define ZFREE_WINDOW dfltcc_free_window
+#define ZFREE_WINDOW PREFIX(dfltcc_free_window)
 
-#define TRY_FREE_WINDOW dfltcc_free_window
+#define TRY_FREE_WINDOW PREFIX(dfltcc_free_window)
 
 #define DFLTCC_BLOCK_HEADER_BITS 3
 #define DFLTCC_HLITS_COUNT_BITS 5
index dcb3f7c5d73ebe55edb600b37c371a0027136503..b0889130176bf524ad4d8dc2e802a8fe08b1170c 100644 (file)
@@ -43,7 +43,7 @@ static inline int dfltcc_can_deflate_with_params(PREFIX3(streamp) strm, int leve
     return 1;
 }
 
-int Z_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm) {
+int Z_INTERNAL PREFIX(dfltcc_can_deflate)(PREFIX3(streamp) strm) {
     deflate_state *state = (deflate_state *)strm->state;
 
     return dfltcc_can_deflate_with_params(strm, state->level, state->w_bits, state->strategy, state->reproducible);
@@ -77,8 +77,8 @@ static inline dfltcc_cc dfltcc_cmpr(PREFIX3(streamp) strm) {
 static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0 *param) {
     deflate_state *state = (deflate_state *)strm->state;
 
-    send_bits(state, bi_reverse(param->eobs >> (15 - param->eobl), param->eobl), param->eobl, state->bi_buf, state->bi_valid);
-    flush_pending(strm);
+    send_bits(state, PREFIX(bi_reverse)(param->eobs >> (15 - param->eobl), param->eobl), param->eobl, state->bi_buf, state->bi_valid);
+    PREFIX(flush_pending)(strm);
     if (state->pending != 0) {
         /* The remaining data is located in pending_out[0:pending]. If someone
          * calls put_byte() - this might happen in deflate() - the byte will be
@@ -94,7 +94,7 @@ static inline void send_eobs(PREFIX3(streamp) strm, const struct dfltcc_param_v0
 #endif
 }
 
-int Z_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result) {
+int Z_INTERNAL PREFIX(dfltcc_deflate)(PREFIX3(streamp) strm, int flush, block_state *result) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
@@ -104,7 +104,7 @@ int Z_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *res
     int soft_bcc;
     int no_flush;
 
-    if (!dfltcc_can_deflate(strm)) {
+    if (!PREFIX(dfltcc_can_deflate)(strm)) {
         /* Clear history. */
         if (flush == Z_FULL_FLUSH)
             param->hl = 0;
@@ -299,9 +299,9 @@ static int dfltcc_was_deflate_used(PREFIX3(streamp) strm) {
     return strm->total_in > 0 || param->nt == 0 || param->hl > 0;
 }
 
-int Z_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy, int *flush) {
+int Z_INTERNAL PREFIX(dfltcc_deflate_params)(PREFIX3(streamp) strm, int level, int strategy, int *flush) {
     deflate_state *state = (deflate_state *)strm->state;
-    int could_deflate = dfltcc_can_deflate(strm);
+    int could_deflate = PREFIX(dfltcc_can_deflate)(strm);
     int can_deflate = dfltcc_can_deflate_with_params(strm, level, state->w_bits, strategy, state->reproducible);
 
     if (can_deflate == could_deflate)
@@ -317,7 +317,7 @@ int Z_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strat
     return Z_OK;
 }
 
-int Z_INTERNAL dfltcc_deflate_done(PREFIX3(streamp) strm, int flush) {
+int Z_INTERNAL PREFIX(dfltcc_deflate_done)(PREFIX3(streamp) strm, int flush) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
@@ -333,10 +333,10 @@ int Z_INTERNAL dfltcc_deflate_done(PREFIX3(streamp) strm, int flush) {
      * buffered some data (Continuation Flag is set), or has not written EOBS
      * yet (Block-Continuation Flag is set).
      */
-    return !dfltcc_can_deflate(strm) || (!param->cf && !param->bcf);
+    return !PREFIX(dfltcc_can_deflate)(strm) || (!param->cf && !param->bcf);
 }
 
-int Z_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible) {
+int Z_INTERNAL PREFIX(dfltcc_can_set_reproducible)(PREFIX3(streamp) strm, int reproducible) {
     deflate_state *state = (deflate_state *)strm->state;
 
     return reproducible != state->reproducible && !dfltcc_was_deflate_used(strm);
@@ -375,7 +375,7 @@ static void append_history(struct dfltcc_param_v0 *param, unsigned char *history
     }
 }
 
-int Z_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
+int Z_INTERNAL PREFIX(dfltcc_deflate_set_dictionary)(PREFIX3(streamp) strm,
                                                 const unsigned char *dictionary, uInt dict_length) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
@@ -387,7 +387,7 @@ int Z_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
     return Z_OK;
 }
 
-int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length) {
+int Z_INTERNAL PREFIX(dfltcc_deflate_get_dictionary)(PREFIX3(streamp) strm, unsigned char *dictionary, uInt *dict_length) {
     deflate_state *state = (deflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
index 218e5946932de08b60f8b8943ed713eca493fe83..15473540c9d5bb223c04ccaeaa408ef38b54b131 100644 (file)
@@ -3,53 +3,53 @@
 
 #include "dfltcc_common.h"
 
-int Z_INTERNAL dfltcc_can_deflate(PREFIX3(streamp) strm);
-int Z_INTERNAL dfltcc_deflate(PREFIX3(streamp) strm, int flush, block_state *result);
-int Z_INTERNAL dfltcc_deflate_params(PREFIX3(streamp) strm, int level, int strategy, int *flush);
-int Z_INTERNAL dfltcc_deflate_done(PREFIX3(streamp) strm, int flush);
-int Z_INTERNAL dfltcc_can_set_reproducible(PREFIX3(streamp) strm, int reproducible);
-int Z_INTERNAL dfltcc_deflate_set_dictionary(PREFIX3(streamp) strm,
+int Z_INTERNAL PREFIX(dfltcc_can_deflate)(PREFIX3(streamp) strm);
+int Z_INTERNAL PREFIX(dfltcc_deflate)(PREFIX3(streamp) strm, int flush, block_state *result);
+int Z_INTERNAL PREFIX(dfltcc_deflate_params)(PREFIX3(streamp) strm, int level, int strategy, int *flush);
+int Z_INTERNAL PREFIX(dfltcc_deflate_done)(PREFIX3(streamp) strm, int flush);
+int Z_INTERNAL PREFIX(dfltcc_can_set_reproducible)(PREFIX3(streamp) strm, int reproducible);
+int Z_INTERNAL PREFIX(dfltcc_deflate_set_dictionary)(PREFIX3(streamp) strm,
                                                 const unsigned char *dictionary, uInt dict_length);
-int Z_INTERNAL dfltcc_deflate_get_dictionary(PREFIX3(streamp) strm, unsigned char *dictionary, uInt* dict_length);
+int Z_INTERNAL PREFIX(dfltcc_deflate_get_dictionary)(PREFIX3(streamp) strm, unsigned char *dictionary, uInt* dict_length);
 
 #define DEFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) \
     do { \
-        if (dfltcc_can_deflate((strm))) \
-            return dfltcc_deflate_set_dictionary((strm), (dict), (dict_len)); \
+        if (PREFIX(dfltcc_can_deflate)((strm))) \
+            return PREFIX(dfltcc_deflate_set_dictionary)((strm), (dict), (dict_len)); \
     } while (0)
 
 #define DEFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) \
     do { \
-        if (dfltcc_can_deflate((strm))) \
-            return dfltcc_deflate_get_dictionary((strm), (dict), (dict_len)); \
+        if (PREFIX(dfltcc_can_deflate)((strm))) \
+            return PREFIX(dfltcc_deflate_get_dictionary)((strm), (dict), (dict_len)); \
     } while (0)
 
 #define DEFLATE_RESET_KEEP_HOOK(strm) \
-    dfltcc_reset((strm), sizeof(deflate_state))
+    PREFIX(dfltcc_reset)((strm), sizeof(deflate_state))
 
 #define DEFLATE_PARAMS_HOOK(strm, level, strategy, hook_flush) \
     do { \
         int err; \
 \
-        err = dfltcc_deflate_params((strm), (level), (strategy), (hook_flush)); \
+        err = PREFIX(dfltcc_deflate_params)((strm), (level), (strategy), (hook_flush)); \
         if (err == Z_STREAM_ERROR) \
             return err; \
     } while (0)
 
-#define DEFLATE_DONE dfltcc_deflate_done
+#define DEFLATE_DONE PREFIX(dfltcc_deflate_done)
 
 #define DEFLATE_BOUND_ADJUST_COMPLEN(strm, complen, source_len) \
     do { \
-        if (dfltcc_can_deflate((strm))) \
+        if (PREFIX(dfltcc_can_deflate)((strm))) \
             (complen) = DEFLATE_BOUND_COMPLEN(source_len); \
     } while (0)
 
-#define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) (dfltcc_can_deflate((strm)))
+#define DEFLATE_NEED_CONSERVATIVE_BOUND(strm) (PREFIX(dfltcc_can_deflate)((strm)))
 
-#define DEFLATE_HOOK dfltcc_deflate
+#define DEFLATE_HOOK PREFIX(dfltcc_deflate)
 
-#define DEFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_deflate((strm)))
+#define DEFLATE_NEED_CHECKSUM(strm) (!PREFIX(dfltcc_can_deflate)((strm)))
 
-#define DEFLATE_CAN_SET_REPRODUCIBLE dfltcc_can_set_reproducible
+#define DEFLATE_CAN_SET_REPRODUCIBLE PREFIX(dfltcc_can_set_reproducible)
 
 #endif
index 253506466d80f828da9e5a60605e42e539a471ed..99024dc9c5898c8960d0a3e507afdb31b37ea377 100644 (file)
@@ -20,7 +20,7 @@
 #include "dfltcc_inflate.h"
 #include "dfltcc_detail.h"
 
-int Z_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm) {
+int Z_INTERNAL PREFIX(dfltcc_can_inflate)(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 
@@ -47,7 +47,7 @@ static inline dfltcc_cc dfltcc_xpnd(PREFIX3(streamp) strm) {
     return cc;
 }
 
-dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret) {
+dfltcc_inflate_action Z_INTERNAL PREFIX(dfltcc_inflate)(PREFIX3(streamp) strm, int flush, int *ret) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
     struct dfltcc_param_v0 *param = &dfltcc_state->param;
@@ -55,7 +55,7 @@ dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush
 
     if (flush == Z_BLOCK || flush == Z_TREES) {
         /* DFLTCC does not support stopping on block boundaries */
-        if (dfltcc_inflate_disable(strm)) {
+        if (PREFIX(dfltcc_inflate_disable)(strm)) {
             *ret = Z_STREAM_ERROR;
             return DFLTCC_INFLATE_BREAK;
         } else
@@ -75,7 +75,7 @@ dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush
     if (strm->avail_in == 0 && !param->cf)
         return DFLTCC_INFLATE_BREAK;
 
-    if (inflate_ensure_window(state)) {
+    if (PREFIX(inflate_ensure_window)(state)) {
         state->mode = MEM;
         return DFLTCC_INFLATE_CONTINUE;
     }
@@ -112,20 +112,20 @@ dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush
         DFLTCC_INFLATE_BREAK : DFLTCC_INFLATE_CONTINUE;
 }
 
-int Z_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm) {
+int Z_INTERNAL PREFIX(dfltcc_was_inflate_used)(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_param_v0 *param = &GET_DFLTCC_STATE(state)->param;
 
     return !param->nt;
 }
 
-int Z_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm) {
+int Z_INTERNAL PREFIX(dfltcc_inflate_disable)(PREFIX3(streamp) strm) {
     struct inflate_state *state = (struct inflate_state *)strm->state;
     struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);
 
-    if (!dfltcc_can_inflate(strm))
+    if (!PREFIX(dfltcc_can_inflate)(strm))
         return 0;
-    if (dfltcc_was_inflate_used(strm))
+    if (PREFIX(dfltcc_was_inflate_used)(strm))
         /* DFLTCC has already decompressed some data. Since there is not
          * enough information to resume decompression in software, the call
          * must fail.
index fc8a000f7b9383af15aa7e3cee3b384e563fae7d..69158ef03205a9b42f3b0aa535b2f71843fbc66d 100644 (file)
@@ -3,28 +3,28 @@
 
 #include "dfltcc_common.h"
 
-int Z_INTERNAL dfltcc_can_inflate(PREFIX3(streamp) strm);
+int Z_INTERNAL PREFIX(dfltcc_can_inflate)(PREFIX3(streamp) strm);
 typedef enum {
     DFLTCC_INFLATE_CONTINUE,
     DFLTCC_INFLATE_BREAK,
     DFLTCC_INFLATE_SOFTWARE,
 } dfltcc_inflate_action;
-dfltcc_inflate_action Z_INTERNAL dfltcc_inflate(PREFIX3(streamp) strm, int flush, int *ret);
-int Z_INTERNAL dfltcc_was_inflate_used(PREFIX3(streamp) strm);
-int Z_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm);
+dfltcc_inflate_action Z_INTERNAL PREFIX(dfltcc_inflate)(PREFIX3(streamp) strm, int flush, int *ret);
+int Z_INTERNAL PREFIX(dfltcc_was_inflate_used)(PREFIX3(streamp) strm);
+int Z_INTERNAL PREFIX(dfltcc_inflate_disable)(PREFIX3(streamp) strm);
 
 #define INFLATE_RESET_KEEP_HOOK(strm) \
-    dfltcc_reset((strm), sizeof(struct inflate_state))
+    PREFIX(dfltcc_reset)((strm), sizeof(struct inflate_state))
 
 #define INFLATE_PRIME_HOOK(strm, bits, value) \
-    do { if (dfltcc_inflate_disable((strm))) return Z_STREAM_ERROR; } while (0)
+    do { if (PREFIX(dfltcc_inflate_disable)((strm))) return Z_STREAM_ERROR; } while (0)
 
 #define INFLATE_TYPEDO_HOOK(strm, flush) \
-    if (dfltcc_can_inflate((strm))) { \
+    if (PREFIX(dfltcc_can_inflate)((strm))) { \
         dfltcc_inflate_action action; \
 \
         RESTORE(); \
-        action = dfltcc_inflate((strm), (flush), &ret); \
+        action = PREFIX(dfltcc_inflate)((strm), (flush), &ret); \
         LOAD(); \
         if (action == DFLTCC_INFLATE_CONTINUE) \
             break; \
@@ -32,18 +32,18 @@ int Z_INTERNAL dfltcc_inflate_disable(PREFIX3(streamp) strm);
             goto inf_leave; \
     }
 
-#define INFLATE_NEED_CHECKSUM(strm) (!dfltcc_can_inflate((strm)))
+#define INFLATE_NEED_CHECKSUM(strm) (!PREFIX(dfltcc_can_inflate)((strm)))
 
-#define INFLATE_NEED_UPDATEWINDOW(strm) (!dfltcc_can_inflate((strm)))
+#define INFLATE_NEED_UPDATEWINDOW(strm) (!PREFIX(dfltcc_can_inflate)((strm)))
 
 #define INFLATE_MARK_HOOK(strm) \
     do { \
-        if (dfltcc_was_inflate_used((strm))) return -(1L << 16); \
+        if (PREFIX(dfltcc_was_inflate_used)((strm))) return -(1L << 16); \
     } while (0)
 
 #define INFLATE_SYNC_POINT_HOOK(strm) \
     do { \
-        if (dfltcc_was_inflate_used((strm))) return Z_STREAM_ERROR; \
+        if (PREFIX(dfltcc_was_inflate_used)((strm))) return Z_STREAM_ERROR; \
     } while (0)
 
 #endif
index 30bdde91e33c43f0e1d36fdfa73bb55d2a938aa9..0658e4bbeb2ebdc4f3366b8f0763f784d44933ae 100644 (file)
@@ -5,10 +5,10 @@
 #  include <sys/auxv.h>
 #endif
 
-Z_INTERNAL int s390_cpu_has_vx = 0;
+Z_INTERNAL int PREFIX(s390_cpu_has_vx) = 0;
 
-void Z_INTERNAL s390_check_features(void) {
+void Z_INTERNAL PREFIX(s390_check_features)(void) {
 #ifdef S390_FEATURES
-    s390_cpu_has_vx = getauxval(AT_HWCAP) & HWCAP_S390_VX;
+    PREFIX(s390_cpu_has_vx) = getauxval(AT_HWCAP) & HWCAP_S390_VX;
 #endif
 }
index 5ab9e92ee78b3a1be053ffd3e2fd96e7dfe54cf8..9e2608fa9e151edbe4b7930d3dbf9abb6080db7d 100644 (file)
@@ -1,8 +1,8 @@
 #ifndef S390_FEATURES_H_
 #define S390_FEATURES_H_
 
-extern int s390_cpu_has_vx;
+extern int PREFIX(s390_cpu_has_vx);
 
-void Z_INTERNAL s390_check_features(void);
+void Z_INTERNAL PREFIX(s390_check_features)(void);
 
 #endif
index 6ef5aa2c4b4839e89adc5c0de18addfe583ac934..b5e72576962d898fed8f1b67396ea641af7ad646 100644 (file)
@@ -18,7 +18,7 @@ Z_INTERNAL void cpu_check_features(void) {
 #elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
     power_check_features();
 #elif defined(S390_FEATURES)
-    s390_check_features();
+    PREFIX(s390_check_features)();
 #endif
     features_checked = 1;
 }
index 5607672178c9ff3fa50d3a484bd932bfc259a3e5..81e13a3c8eae4cc7695e7ab8c81c363daf688a95 100644 (file)
@@ -105,7 +105,7 @@ extern uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len)
 #elif defined(POWER8_VSX_CRC32)
 extern uint32_t crc32_power8(uint32_t crc, const unsigned char *buf, uint64_t len);
 #elif defined(S390_CRC32_VX)
-extern uint32_t s390_crc32_vx(uint32_t crc, const unsigned char *buf, uint64_t len);
+extern uint32_t PREFIX(s390_crc32_vx)(uint32_t crc, const unsigned char *buf, uint64_t len);
 #endif
 
 /* compare256 */
index 233a629c42b7e2cbe8578adc6fafc13bd3c5fa2e..cbf2b1cb4d36ca672663c12e19ffe9ed0d77a366 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -662,7 +662,7 @@ unsigned long Z_EXPORT PREFIX(deflateBound)(PREFIX3(stream) *strm, unsigned long
  * applications may wish to modify it to avoid allocating a large
  * strm->next_out buffer and copying into it. (See also read_buf()).
  */
-Z_INTERNAL void flush_pending(PREFIX3(stream) *strm) {
+Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm) {
     uint32_t len;
     deflate_state *s = strm->state;
 
@@ -715,7 +715,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
 
     /* Flush as much pending output as possible */
     if (s->pending != 0) {
-        flush_pending(strm);
+        PREFIX(flush_pending)(strm);
         if (strm->avail_out == 0) {
             /* Since avail_out is 0, deflate will be called again with
              * more output space, but possibly with both pending and
@@ -770,7 +770,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
         s->status = BUSY_STATE;
 
         /* Compression must start with an empty pending buffer */
-        flush_pending(strm);
+        PREFIX(flush_pending)(strm);
         if (s->pending != 0) {
             s->last_flush = -1;
             return Z_OK;
@@ -792,7 +792,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
             s->status = BUSY_STATE;
 
             /* Compression must start with an empty pending buffer */
-            flush_pending(strm);
+            PREFIX(flush_pending)(strm);
             if (s->pending != 0) {
                 s->last_flush = -1;
                 return Z_OK;
@@ -826,7 +826,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
                 s->pending = s->pending_buf_size;
                 HCRC_UPDATE(beg);
                 s->gzindex += copy;
-                flush_pending(strm);
+                PREFIX(flush_pending)(strm);
                 if (s->pending != 0) {
                     s->last_flush = -1;
                     return Z_OK;
@@ -849,7 +849,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
             do {
                 if (s->pending == s->pending_buf_size) {
                     HCRC_UPDATE(beg);
-                    flush_pending(strm);
+                    PREFIX(flush_pending)(strm);
                     if (s->pending != 0) {
                         s->last_flush = -1;
                         return Z_OK;
@@ -872,7 +872,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
             do {
                 if (s->pending == s->pending_buf_size) {
                     HCRC_UPDATE(beg);
-                    flush_pending(strm);
+                    PREFIX(flush_pending)(strm);
                     if (s->pending != 0) {
                         s->last_flush = -1;
                         return Z_OK;
@@ -889,7 +889,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
     if (s->status == HCRC_STATE) {
         if (s->gzhead->hcrc) {
             if (s->pending + 2 > s->pending_buf_size) {
-                flush_pending(strm);
+                PREFIX(flush_pending)(strm);
                 if (s->pending != 0) {
                     s->last_flush = -1;
                     return Z_OK;
@@ -901,7 +901,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
         s->status = BUSY_STATE;
 
         /* Compression must start with an empty pending buffer */
-        flush_pending(strm);
+        PREFIX(flush_pending)(strm);
         if (s->pending != 0) {
             s->last_flush = -1;
             return Z_OK;
@@ -953,7 +953,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
                     }
                 }
             }
-            flush_pending(strm);
+            PREFIX(flush_pending)(strm);
             if (strm->avail_out == 0) {
                 s->last_flush = -1; /* avoid BUF_ERROR at next call, see above */
                 return Z_OK;
@@ -975,7 +975,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
 #endif
     if (s->wrap == 1)
         put_uint32_msb(s, strm->adler);
-    flush_pending(strm);
+    PREFIX(flush_pending)(strm);
     /* If avail_out is zero, the application will call deflate again
      * to flush the rest.
      */
index 87108914eeb08aa4ed0fe1983f8d1420f7585e86..b5ae2f8e665157a75fe36e92e05c9aa9f3d25f18 100644 (file)
--- a/deflate.h
+++ b/deflate.h
@@ -381,8 +381,8 @@ void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_
 void Z_INTERNAL zng_tr_flush_bits(deflate_state *s);
 void Z_INTERNAL zng_tr_align(deflate_state *s);
 void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
-uint16_t Z_INTERNAL bi_reverse(unsigned code, int len);
-void Z_INTERNAL flush_pending(PREFIX3(streamp) strm);
+uint16_t Z_INTERNAL PREFIX(bi_reverse)(unsigned code, int len);
+void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm);
 #define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
 /* Mapping from a distance to a distance code. dist is the distance - 1 and
  * must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never
index da667a0f9d50d888d4f4e215582141c3cbc73f84..af24681a561e67c53b473cb7ca36497aaf42a60d 100644 (file)
@@ -47,7 +47,7 @@ static inline void check_match(deflate_state *s, Pos start, Pos match, int lengt
 #define check_match(s, start, match, length)
 #endif
 
-Z_INTERNAL void flush_pending(PREFIX3(stream) *strm);
+Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm);
 Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
 
 /* ===========================================================================
@@ -96,7 +96,7 @@ static inline int zng_tr_tally_dist(deflate_state *s, uint32_t dist, uint32_t le
                    (uint32_t)((int)s->strstart - s->block_start), \
                    (last)); \
     s->block_start = (int)s->strstart; \
-    flush_pending(s->strm); \
+    PREFIX(flush_pending)(s->strm); \
 }
 
 /* Same but force premature exit if necessary. */
index a3162675ed4653f796a8e48bfe2c508711232cc4..f7dfbe8aca2e804f128544e7071f39778868a08d 100644 (file)
@@ -37,7 +37,7 @@ extern const ct_data static_dtree[D_CODES];
         zng_tr_emit_end_block(s, static_ltree, last); \
         s->block_open = 0; \
         s->block_start = (int)s->strstart; \
-        flush_pending(s->strm); \
+        PREFIX(flush_pending)(s->strm); \
         if (s->strm->avail_out == 0) \
             return (last) ? finish_started : need_more; \
     } \
@@ -63,7 +63,7 @@ Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
 
     for (;;) {
         if (UNLIKELY(s->pending + ((BIT_BUF_SIZE + 7) >> 3) >= s->pending_buf_size)) {
-            flush_pending(s->strm);
+            PREFIX(flush_pending)(s->strm);
             if (s->strm->avail_out == 0) {
                 return (last && s->strm->avail_in == 0 && s->bi_valid == 0 && s->block_open == 0) ? finish_started : need_more;
             }
index 92e57fad805640b465e435dca45d43b655da12b4..a9bc92164c1c9f900bd2b3ce0cf7a33c1442c4cb 100644 (file)
@@ -73,7 +73,7 @@ Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush) {
         put_short(s, (uint16_t)~len);
 
         /* Write the stored block header bytes. */
-        flush_pending(s->strm);
+        PREFIX(flush_pending)(s->strm);
 
         /* Update debugging counts for the data about to be copied. */
         cmpr_bits_add(s, len << 3);
@@ -178,7 +178,7 @@ Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush) {
         last = flush == Z_FINISH && s->strm->avail_in == 0 && len == left ? 1 : 0;
         zng_tr_stored_block(s, (char *)s->window + s->block_start, len, last);
         s->block_start += (int)len;
-        flush_pending(s->strm);
+        PREFIX(flush_pending)(s->strm);
     }
 
     /* We've done all we can with the available input and output. */
index ffb0d3f4795a57cb1ce9ecfaebc0b695d0686869..68aef1d338e2059fa33fff8db6cbadd04c449f14 100644 (file)
@@ -371,8 +371,8 @@ Z_INTERNAL uint32_t crc32_stub(uint32_t crc, const unsigned char *buf, uint64_t
     if (power_cpu_has_arch_2_07)
         functable.crc32 = &crc32_power8;
 #elif defined(S390_CRC32_VX)
-    if (s390_cpu_has_vx)
-        functable.crc32 = &s390_crc32_vx;
+    if (PREFIX(s390_cpu_has_vx))
+        functable.crc32 = &PREFIX(s390_crc32_vx);
 #elif defined(X86_PCLMULQDQ_CRC)
     if (x86_cpu_has_pclmulqdq)
         functable.crc32 = &crc32_pclmulqdq;
index 291582d0579c7d43bd5a2505dd01cf27c4ecf3d1..86f02cc4bf85e904cce0ce7c2a07397d90ad8ec9 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -198,7 +198,7 @@ void Z_INTERNAL fixedtables(struct inflate_state *state) {
     state->distbits = 5;
 }
 
-int Z_INTERNAL inflate_ensure_window(struct inflate_state *state) {
+int Z_INTERNAL PREFIX(inflate_ensure_window)(struct inflate_state *state) {
     /* if it hasn't been done already, allocate space for the window */
     if (state->window == NULL) {
         unsigned wsize = 1U << state->wbits;
@@ -243,7 +243,7 @@ static int32_t updatewindow(PREFIX3(stream) *strm, const uint8_t *end, uint32_t
 
     state = (struct inflate_state *)strm->state;
 
-    if (inflate_ensure_window(state)) return 1;
+    if (PREFIX(inflate_ensure_window)(state)) return 1;
 
     /* copy state->wsize or less output bytes into the circular window */
     if (copy >= state->wsize) {
index 3f57e7840820486f126e47f9ddc170ae8240309f..ffa2d0bd8044606cf232782ed57a9dcc8ac86c7e 100644 (file)
--- a/inflate.h
+++ b/inflate.h
@@ -133,7 +133,7 @@ struct inflate_state {
     uint32_t chunksize;         /* size of memory copying chunk */
 };
 
-int Z_INTERNAL inflate_ensure_window(struct inflate_state *state);
+int Z_INTERNAL PREFIX(inflate_ensure_window)(struct inflate_state *state);
 void Z_INTERNAL fixedtables(struct inflate_state *state);
 
 #endif /* INFLATE_H_ */
index 5908116f1cc96d64d71219cccbc016016b337eae..06a11cfa0e27d8eb18911b20f4f4e7a5747cc147 100644 (file)
@@ -62,7 +62,7 @@ BENCHMARK_CRC32(acle, crc32_acle, arm_cpu_has_crc32);
 #elif defined(POWER8_VSX_CRC32)
 BENCHMARK_CRC32(power8, crc32_power8, power_cpu_has_arch_2_07);
 #elif defined(S390_CRC32_VX)
-BENCHMARK_CRC32(vx, s390_crc32_vx, s390_cpu_has_vx);
+BENCHMARK_CRC32(vx, PREFIX(s390_crc32_vx), PREFIX(s390_cpu_has_vx));
 #elif defined(X86_PCLMULQDQ_CRC)
 /* CRC32 fold does a memory copy while hashing */
 BENCHMARK_CRC32(pclmulqdq, crc32_pclmulqdq, x86_cpu_has_pclmulqdq);
index af0dd3b784697cccb6cf26b87081306949269ec8..f76f838adfe5bfcaa28f2a7d5d74175a283b82e2 100644 (file)
@@ -213,7 +213,7 @@ TEST_CRC32(acle, crc32_acle, arm_cpu_has_crc32)
 #elif defined(POWER8_VSX_CRC32)
 TEST_CRC32(power8, crc32_power8, power_cpu_has_arch_2_07)
 #elif defined(S390_CRC32_VX)
-TEST_CRC32(vx, s390_crc32_vx, s390_cpu_has_vx)
+TEST_CRC32(vx, PREFIX(s390_crc32_vx), PREFIX(s390_cpu_has_vx))
 #elif defined(X86_PCLMULQDQ_CRC)
 TEST_CRC32(pclmulqdq, crc32_pclmulqdq, x86_cpu_has_pclmulqdq)
 #endif
index 282bddc2e5d3f07c2f38c8da8490597ff26fe7a6..97688c7aae0ba64fe26a9748309a61ff5ce623a2 100644 (file)
@@ -90,7 +90,7 @@ static void tr_static_init(void) {
     /* The static distance tree is trivial: */
     for (n = 0; n < D_CODES; n++) {
         static_dtree[n].Len = 5;
-        static_dtree[n].Code = bi_reverse((unsigned)n, 5);
+        static_dtree[n].Code = PREFIX(bi_reverse)((unsigned)n, 5);
     }
 }
 
diff --git a/trees.c b/trees.c
index 5ff07636f424826a307011862be26b1a0ee3a36d..7bc70075b51f0838ff8ce53e07201dfa6c15734b 100644 (file)
--- a/trees.c
+++ b/trees.c
@@ -305,7 +305,7 @@ Z_INTERNAL void gen_codes(ct_data *tree, int max_code, uint16_t *bl_count) {
         if (len == 0)
             continue;
         /* Now reverse the bits */
-        tree[n].Code = bi_reverse(next_code[len]++, len);
+        tree[n].Code = PREFIX(bi_reverse)(next_code[len]++, len);
 
         Tracecv(tree != static_ltree, (stderr, "\nn %3d %c l %2d c %4x (%x) ",
              n, (isgraph(n & 0xff) ? n : ' '), len, tree[n].Code, next_code[len]-1));
@@ -808,7 +808,7 @@ static void bi_flush(deflate_state *s) {
 /* ===========================================================================
  * Reverse the first len bits of a code using bit manipulation
  */
-Z_INTERNAL uint16_t bi_reverse(unsigned code, int len) {
+Z_INTERNAL uint16_t PREFIX(bi_reverse)(unsigned code, int len) {
     /* code: the value to invert */
     /* len: its bit length */
     Assert(len >= 1 && len <= 15, "code length must be 1-15");