uint64_t prealign, aligned, remaining;
if (len < VX_MIN_LEN + VX_ALIGN_MASK)
- return crc32_braid(crc, buf, len);
+ return PREFIX(crc32_braid)(crc, buf, len);
if ((uintptr_t)buf & VX_ALIGN_MASK) {
prealign = VX_ALIGNMENT - ((uintptr_t)buf & VX_ALIGN_MASK);
len -= prealign;
- crc = crc32_braid(crc, buf, prealign);
+ crc = PREFIX(crc32_braid)(crc, buf, prealign);
buf += prealign;
}
aligned = len & ~VX_ALIGN_MASK;
crc = crc32_le_vgfm_16(crc ^ 0xffffffff, buf, (size_t)aligned) ^ 0xffffffff;
if (remaining)
- crc = crc32_braid(crc, buf + aligned, remaining);
+ crc = PREFIX(crc32_braid)(crc, buf + aligned, remaining);
return crc;
}
/* For lens < 64, crc32_braid method is faster. The CRC32 instruction for
* these short lengths might also prove to be effective */
if (len < 64)
- return crc32_braid(crc32, buf, len);
+ return PREFIX(crc32_braid)(crc32, buf, len);
crc32_fold ALIGNED_(16) crc_state;
crc32_fold_pclmulqdq_reset(&crc_state);
/* CRC32 */
typedef uint32_t (*crc32_func)(uint32_t crc32, const uint8_t *buf, uint64_t len);
-extern uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, uint64_t len);
+extern uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, uint64_t len);
#ifdef ARM_ACLE_CRC_HASH
extern uint32_t crc32_acle(uint32_t crc, const uint8_t *buf, uint64_t len);
#elif defined(POWER8_VSX_CRC32)
#endif /* W */
/* ========================================================================= */
-Z_INTERNAL uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, uint64_t len) {
+Z_INTERNAL uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, uint64_t len) {
Z_REGISTER uint32_t c;
/* Pre-condition the CRC */
/* CRC polynomial. */
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
-extern uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, uint64_t len);
+extern uint32_t PREFIX(crc32_braid)(uint32_t crc, const uint8_t *buf, uint64_t len);
#endif /* CRC32_BRAID_P_H_ */
strm->msg = NULL;
if (strm->zalloc == NULL) {
- strm->zalloc = zng_calloc;
+ strm->zalloc = PREFIX3(calloc);
strm->opaque = NULL;
}
if (strm->zfree == NULL)
- strm->zfree = zng_cfree;
+ strm->zfree = PREFIX3(cfree);
if (level == Z_DEFAULT_COMPRESSION)
level = 6;
next = strm->next_in;
strm->avail_in = dictLength;
strm->next_in = (z_const unsigned char *)dictionary;
- fill_window(s);
+ PREFIX(fill_window)(s);
while (s->lookahead >= STD_MIN_MATCH) {
str = s->strstart;
n = s->lookahead - (STD_MIN_MATCH - 1);
s->insert_string(s, str, n);
s->strstart = str + n;
s->lookahead = STD_MIN_MATCH - 1;
- fill_window(s);
+ PREFIX(fill_window)(s);
}
s->strstart += s->lookahead;
s->block_start = (int)s->strstart;
* allocating a large strm->next_in buffer and copying from it.
* (See also flush_pending()).
*/
-Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
+Z_INTERNAL unsigned PREFIX(read_buf)(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) {
uint32_t len = strm->avail_in;
len = MIN(len, size);
* option -- not supported here).
*/
-void Z_INTERNAL fill_window(deflate_state *s) {
+void Z_INTERNAL PREFIX(fill_window)(deflate_state *s) {
unsigned n;
unsigned int more; /* Amount of free space at the end of the window. */
unsigned int wsize = s->w_size;
*/
Assert(more >= 2, "more < 2");
- n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more);
+ n = PREFIX(read_buf)(s->strm, s->window + s->strstart + s->lookahead, more);
s->lookahead += n;
/* Initialize the hash value now that we have some input: */
memory checker errors from longest match routines */
-void Z_INTERNAL fill_window(deflate_state *s);
+void Z_INTERNAL PREFIX(fill_window)(deflate_state *s);
void Z_INTERNAL slide_hash_c(deflate_state *s);
/* in trees.c */
* string following the next match.
*/
if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
+ PREFIX(fill_window)(s);
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
for (;;) {
/* Make sure that we have a literal to write. */
if (s->lookahead == 0) {
- fill_window(s);
+ PREFIX(fill_window)(s);
if (s->lookahead == 0) {
if (flush == Z_NO_FLUSH)
return need_more;
* string following the next current_match.
*/
if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
+ PREFIX(fill_window)(s);
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
return need_more;
}
#endif
Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm);
-Z_INTERNAL unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
+Z_INTERNAL unsigned PREFIX(read_buf)(PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
/* ===========================================================================
* Save the match info and tally the frequency counts. Return true if
}
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD)) {
- fill_window(s);
+ PREFIX(fill_window)(s);
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
* for the longest run, plus one for the unrolled loop.
*/
if (s->lookahead <= STD_MAX_MATCH) {
- fill_window(s);
+ PREFIX(fill_window)(s);
if (s->lookahead <= STD_MAX_MATCH && flush == Z_NO_FLUSH)
return need_more;
if (s->lookahead == 0)
* string following the next match.
*/
if (s->lookahead < MIN_LOOKAHEAD) {
- fill_window(s);
+ PREFIX(fill_window)(s);
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
return need_more;
}
* the check value.
*/
if (len) {
- read_buf(s->strm, s->strm->next_out, len);
+ PREFIX(read_buf)(s->strm, s->strm->next_out, len);
s->strm->next_out += len;
s->strm->avail_out -= len;
s->strm->total_out += len;
have = MIN(have, s->strm->avail_in);
if (have) {
- read_buf(s->strm, s->window + s->strstart, have);
+ PREFIX(read_buf)(s->strm, s->window + s->strstart, have);
s->strstart += have;
s->insert += MIN(have, s->w_size - s->insert);
}
Assert(sizeof(uint64_t) >= sizeof(size_t),
"crc32_z takes size_t but internally we have a uint64_t len");
- functable.crc32 = &crc32_braid;
+ functable.crc32 = &PREFIX(crc32_braid);
cpu_check_features();
#ifdef ARM_ACLE_CRC_HASH
if (arm_cpu_has_crc32)
return Z_STREAM_ERROR;
strm->msg = NULL; /* in case we return an error */
if (strm->zalloc == NULL) {
- strm->zalloc = zng_calloc;
+ strm->zalloc = PREFIX3(calloc);
strm->opaque = NULL;
}
if (strm->zfree == NULL)
- strm->zfree = zng_cfree;
+ strm->zfree = PREFIX3(cfree);
state = ZALLOC_INFLATE_STATE(strm);
if (state == NULL)
return Z_MEM_ERROR;
state->mode = STORED;
break;
case 1: /* fixed block */
- fixedtables(state);
+ PREFIX(fixedtables)(state);
Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : ""));
state->mode = LEN; /* decode codes */
break;
return Z_STREAM_ERROR;
strm->msg = NULL; /* in case we return an error */
if (strm->zalloc == NULL) {
- strm->zalloc = zng_calloc;
+ strm->zalloc = PREFIX3(calloc);
strm->opaque = NULL;
}
if (strm->zfree == NULL)
- strm->zfree = zng_cfree;
+ strm->zfree = PREFIX3(cfree);
state = ZALLOC_INFLATE_STATE(strm);
if (state == NULL)
return Z_MEM_ERROR;
fixed code decoding. This returns fixed tables from inffixed_tbl.h.
*/
-void Z_INTERNAL fixedtables(struct inflate_state *state) {
+void Z_INTERNAL PREFIX(fixedtables)(struct inflate_state *state) {
state->lencode = lenfix;
state->lenbits = 9;
state->distcode = distfix;
state->mode = STORED;
break;
case 1: /* fixed block */
- fixedtables(state);
+ PREFIX(fixedtables)(state);
Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : ""));
state->mode = LEN_; /* decode codes */
if (flush == Z_TREES) {
};
int Z_INTERNAL PREFIX(inflate_ensure_window)(struct inflate_state *state);
-void Z_INTERNAL fixedtables(struct inflate_state *state);
+void Z_INTERNAL PREFIX(fixedtables)(struct inflate_state *state);
#endif /* INFLATE_H_ */
} \
BENCHMARK_REGISTER_F(crc32, name)->Range(1, MAX_RANDOM_INTS_SIZE);
-BENCHMARK_CRC32(braid, crc32_braid, 1);
+BENCHMARK_CRC32(braid, PREFIX(crc32_braid), 1);
#ifdef ARM_ACLE_CRC_HASH
BENCHMARK_CRC32(acle, crc32_acle, arm_cpu_has_crc32);
}
TEST(zalloc, aligned_64) {
- void *return_ptr = zng_alloc_aligned(zng_calloc_unaligned, 0, 1, 100, 64);
+ void *return_ptr = PREFIX3(alloc_aligned)(zng_calloc_unaligned, 0, 1, 100, 64);
ASSERT_TRUE(return_ptr != NULL);
EXPECT_EQ((intptr_t)return_ptr % 64, 0);
- zng_free_aligned(zng_cfree_unaligned, 0, return_ptr);
+ PREFIX3(free_aligned)(zng_cfree_unaligned, 0, return_ptr);
}
hash(GetParam(), func); \
}
-TEST_CRC32(braid, crc32_braid, 1)
+TEST_CRC32(braid, PREFIX(crc32_braid), 1)
#ifdef ARM_ACLE_CRC_HASH
TEST_CRC32(acle, crc32_acle, arm_cpu_has_crc32)
(z_const char *)""
};
-const char zlibng_string[] =
- " zlib-ng 2.1.0.devel forked from zlib";
-
#ifdef ZLIB_COMPAT
const char * Z_EXPORT zlibVersion(void) {
return ZLIB_VERSION;
}
-#endif
+#else
+const char zlibng_string[] =
+ " zlib-ng 2.1.0.devel forked from zlib";
const char * Z_EXPORT zlibng_version(void) {
return ZLIBNG_VERSION;
}
+#endif
unsigned long Z_EXPORT PREFIX(zlibCompileFlags)(void) {
unsigned long flags;
return ERR_MSG(err);
}
-void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size) {
+void Z_INTERNAL *PREFIX3(calloc)(void *opaque, unsigned items, unsigned size) {
Z_UNUSED(opaque);
return zng_alloc((size_t)items * (size_t)size);
}
-void Z_INTERNAL zng_cfree(void *opaque, void *ptr) {
+void Z_INTERNAL PREFIX3(cfree)(void *opaque, void *ptr) {
Z_UNUSED(opaque);
zng_free(ptr);
}
/* Since we support custom memory allocators, some which might not align memory as we expect,
* we have to ask for extra memory and return an aligned pointer. */
-void Z_INTERNAL *zng_alloc_aligned(zng_calloc_func zalloc, void *opaque, unsigned items, unsigned size, unsigned align) {
+void Z_INTERNAL *PREFIX3(alloc_aligned)(zng_calloc_func zalloc, void *opaque, unsigned items, unsigned size, unsigned align) {
uintptr_t return_ptr, original_ptr;
uint32_t alloc_size, align_diff;
void *ptr;
/* If no custom calloc function used then call zlib-ng's aligned calloc */
- if (zalloc == zng_calloc)
- return zng_calloc(opaque, items, size);
+ if (zalloc == PREFIX3(calloc))
+ return PREFIX3(calloc)(opaque, items, size);
/* Allocate enough memory for proper alignment and to store the original memory pointer */
alloc_size = sizeof(void *) + (items * size) + align;
return (void *)return_ptr;
}
-void Z_INTERNAL zng_free_aligned(zng_cfree_func zfree, void *opaque, void *ptr) {
+void Z_INTERNAL PREFIX3(free_aligned)(zng_cfree_func zfree, void *opaque, void *ptr) {
/* If no custom cfree function used then call zlib-ng's aligned cfree */
- if (zfree == zng_cfree) {
- zng_cfree(opaque, ptr);
+ if (zfree == PREFIX3(cfree)) {
+ PREFIX3(cfree)(opaque, ptr);
return;
}
if (!ptr)
/* memory allocation functions */
-void Z_INTERNAL *zng_calloc(void *opaque, unsigned items, unsigned size);
-void Z_INTERNAL zng_cfree(void *opaque, void *ptr);
+void Z_INTERNAL *PREFIX3(calloc)(void *opaque, unsigned items, unsigned size);
+void Z_INTERNAL PREFIX3(cfree)(void *opaque, void *ptr);
typedef void *zng_calloc_func(void *opaque, unsigned items, unsigned size);
typedef void zng_cfree_func(void *opaque, void *ptr);
-void Z_INTERNAL *zng_alloc_aligned(zng_calloc_func zalloc, void *opaque, unsigned items, unsigned size, unsigned align);
-void Z_INTERNAL zng_free_aligned(zng_cfree_func zfree, void *opaque, void *ptr);
+void Z_INTERNAL *PREFIX3(alloc_aligned)(zng_calloc_func zalloc, void *opaque, unsigned items, unsigned size, unsigned align);
+void Z_INTERNAL PREFIX3(free_aligned)(zng_cfree_func zfree, void *opaque, void *ptr);
-#define ZALLOC(strm, items, size) zng_alloc_aligned((strm)->zalloc, (strm)->opaque, (items), (size), 64)
-#define ZFREE(strm, addr) zng_free_aligned((strm)->zfree, (strm)->opaque, (void *)(addr))
+#define ZALLOC(strm, items, size) PREFIX3(alloc_aligned)((strm)->zalloc, (strm)->opaque, (items), (size), 64)
+#define ZFREE(strm, addr) PREFIX3(free_aligned)((strm)->zfree, (strm)->opaque, (void *)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}