#ifdef ZLIB_COMPAT
unsigned long Z_EXPORT PREFIX(adler32_z)(unsigned long adler, const unsigned char *buf, size_t len) {
- return (unsigned long)functable.adler32((uint32_t)adler, buf, len);
+ return (unsigned long)FUNCTABLE_CALL(adler32)((uint32_t)adler, buf, len);
}
#else
uint32_t Z_EXPORT PREFIX(adler32_z)(uint32_t adler, const unsigned char *buf, size_t len) {
- return functable.adler32(adler, buf, len);
+ return FUNCTABLE_CALL(adler32)(adler, buf, len);
}
#endif
/* ========================================================================= */
#ifdef ZLIB_COMPAT
unsigned long Z_EXPORT PREFIX(adler32)(unsigned long adler, const unsigned char *buf, unsigned int len) {
- return (unsigned long)functable.adler32((uint32_t)adler, buf, len);
+ return (unsigned long)FUNCTABLE_CALL(adler32)((uint32_t)adler, buf, len);
}
#else
uint32_t Z_EXPORT PREFIX(adler32)(uint32_t adler, const unsigned char *buf, uint32_t len) {
- return functable.adler32(adler, buf, len);
+ return FUNCTABLE_CALL(adler32)(adler, buf, len);
}
#endif
#include <limits.h>
Z_INTERNAL uint32_t adler32_fold_copy_c(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len) {
- adler = functable.adler32(adler, src, len);
+ adler = FUNCTABLE_CALL(adler32)(adler, src, len);
memcpy(dst, src, len);
return adler;
}
}
Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) {
- crc->value = functable.crc32(crc->value, src, len);
+ crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len);
memcpy(dst, src, len);
}
* same arguments for the versions that _do_ do a folding CRC but we don't want a copy. The
* init_crc is an unused argument in this context */
Z_UNUSED(init_crc);
- crc->value = functable.crc32(crc->value, src, len);
+ crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len);
}
Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc) {
unsigned long Z_EXPORT 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);
+ return (unsigned long)FUNCTABLE_CALL(crc32)((uint32_t)crc, buf, len);
}
#else
uint32_t Z_EXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) {
if (buf == NULL) return 0;
- return functable.crc32(crc, buf, len);
+ return FUNCTABLE_CALL(crc32)(crc, buf, len);
}
#endif
/* when using zlib wrappers, compute Adler-32 for provided dictionary */
if (wrap == 1)
- strm->adler = functable.adler32(strm->adler, dictionary, dictLength);
+ strm->adler = FUNCTABLE_CALL(adler32)(strm->adler, dictionary, dictLength);
DEFLATE_SET_DICTIONARY_HOOK(strm, dictionary, dictLength); /* hook for IBM Z DFLTCC */
s->wrap = 0; /* avoid computing Adler-32 in read_buf */
#ifdef GZIP
if (s->wrap == 2) {
- strm->adler = functable.crc32_fold_reset(&s->crc_fold);
+ strm->adler = FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold);
} else
#endif
strm->adler = ADLER32_INITIAL_VALUE;
if (s->level != level) {
if (s->level == 0 && s->matches != 0) {
if (s->matches == 1) {
- functable.slide_hash(s);
+ FUNCTABLE_CALL(slide_hash)(s);
} else {
CLEAR_HASH(s);
}
#ifdef GZIP
if (s->status == GZIP_STATE) {
/* gzip header */
- functable.crc32_fold_reset(&s->crc_fold);
+ FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold);
put_byte(s, 31);
put_byte(s, 139);
put_byte(s, 8);
}
}
put_short(s, (uint16_t)strm->adler);
- functable.crc32_fold_reset(&s->crc_fold);
+ FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold);
}
s->status = BUSY_STATE;
/* Write the trailer */
#ifdef GZIP
if (s->wrap == 2) {
- strm->adler = functable.crc32_fold_final(&s->crc_fold);
+ strm->adler = FUNCTABLE_CALL(crc32_fold_final)(&s->crc_fold);
put_uint32(s, strm->adler);
put_uint32(s, (uint32_t)strm->total_in);
memcpy(buf, strm->next_in, len);
#ifdef GZIP
} else if (strm->state->wrap == 2) {
- functable.crc32_fold_copy(&strm->state->crc_fold, buf, strm->next_in, len);
+ FUNCTABLE_CALL(crc32_fold_copy)(&strm->state->crc_fold, buf, strm->next_in, len);
#endif
} else if (strm->state->wrap == 1) {
- strm->adler = functable.adler32_fold_copy(strm->adler, buf, strm->next_in, len);
+ strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len);
} else {
memcpy(buf, strm->next_in, len);
}
s->block_start -= (int)wsize;
if (s->insert > s->strstart)
s->insert = s->strstart;
- functable.slide_hash(s);
+ FUNCTABLE_CALL(slide_hash)(s);
more += wsize;
}
if (s->strm->avail_in == 0)
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
- match_len = functable.longest_match(s, hash_head);
+ match_len = FUNCTABLE_CALL(longest_match)(s, hash_head);
/* longest_match() sets match_start */
}
}
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
- current_match.match_length = (uint16_t)functable.longest_match(s, hash_head);
+ current_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head);
current_match.match_start = (uint16_t)s->match_start;
if (UNLIKELY(current_match.match_length < WANT_MIN_MATCH))
current_match.match_length = 1;
* of window index 0 (in particular we have to avoid a match
* of the string with itself at the start of the input file).
*/
- next_match.match_length = (uint16_t)functable.longest_match(s, hash_head);
+ next_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head);
next_match.match_start = (uint16_t)s->match_start;
if (UNLIKELY(next_match.match_start >= next_match.strstart)) {
/* this can happen due to some restarts */
const uint8_t *match_start = s->window + hash_head;
if (zng_memcmp_2(str_start, match_start) == 0) {
- match_len = functable.compare256(str_start+2, match_start+2) + 2;
+ match_len = FUNCTABLE_CALL(compare256)(str_start+2, match_start+2) + 2;
if (match_len >= WANT_MIN_MATCH) {
if (UNLIKELY(match_len > s->lookahead))
match_func longest_match;
if (s->max_chain_length <= 1024)
- longest_match = functable.longest_match;
+ longest_match = FUNCTABLE_FPTR(longest_match);
else
- longest_match = functable.longest_match_slow;
+ longest_match = FUNCTABLE_FPTR(longest_match_slow);
/* Process the input block. */
for (;;) {
Z_INTERNAL extern struct functable_s functable;
+
+/* Explicitly indicate functions are conditionally dispatched.
+ */
+#define FUNCTABLE_CALL(name) functable.name
+#define FUNCTABLE_FPTR(name) functable.name
+
+
#endif
state->wnext = 0;
state->whave = 0;
state->sane = 1;
- state->chunksize = functable.chunksize();
+ state->chunksize = FUNCTABLE_CALL(chunksize)();
return Z_OK;
}
RESTORE();
if (state->whave < state->wsize)
state->whave = state->wsize - left;
- functable.inflate_fast(strm, state->wsize);
+ FUNCTABLE_CALL(inflate_fast)(strm, state->wsize);
LOAD();
break;
}
struct inflate_state *state = (struct inflate_state*)strm->state;
#ifdef GUNZIP
if (state->flags) {
- functable.crc32_fold_copy(&state->crc_fold, dst, src, copy);
+ FUNCTABLE_CALL(crc32_fold_copy)(&state->crc_fold, dst, src, copy);
} else
#endif
{
- strm->adler = state->check = functable.adler32_fold_copy(state->check, dst, src, copy);
+ strm->adler = state->check = FUNCTABLE_CALL(adler32_fold_copy)(state->check, dst, src, copy);
}
}
struct inflate_state *state = (struct inflate_state*)strm->state;
#ifdef GUNZIP
if (state->flags) {
- functable.crc32_fold(&state->crc_fold, src, len, 0);
+ FUNCTABLE_CALL(crc32_fold)(&state->crc_fold, src, len, 0);
} else
#endif
{
- strm->adler = state->check = functable.adler32(state->check, src, len);
+ strm->adler = state->check = FUNCTABLE_CALL(adler32)(state->check, src, len);
}
}
state->strm = strm;
state->window = NULL;
state->mode = HEAD; /* to pass state test in inflateReset2() */
- state->chunksize = functable.chunksize();
+ state->chunksize = FUNCTABLE_CALL(chunksize)();
ret = PREFIX(inflateReset2)(strm, windowBits);
if (ret != Z_OK) {
ZFREE_STATE(strm, state);
}
/* compute crc32 checksum if not in raw mode */
if ((state->wrap & 4) && state->flags)
- strm->adler = state->check = functable.crc32_fold_reset(&state->crc_fold);
+ strm->adler = state->check = FUNCTABLE_CALL(crc32_fold_reset)(&state->crc_fold);
state->mode = TYPE;
break;
#endif
/* use inflate_fast() if we have enough input and output */
if (have >= INFLATE_FAST_MIN_HAVE && left >= INFLATE_FAST_MIN_LEFT) {
RESTORE();
- functable.inflate_fast(strm, out);
+ FUNCTABLE_CALL(inflate_fast)(strm, out);
LOAD();
if (state->mode == TYPE)
state->back = -1;
} else {
copy = MIN(state->length, left);
- put = functable.chunkmemset_safe(put, state->offset, copy, left);
+ put = FUNCTABLE_CALL(chunkmemset_safe)(put, state->offset, copy, left);
}
left -= copy;
state->length -= copy;
}
#ifdef GUNZIP
if (state->flags)
- strm->adler = state->check = functable.crc32_fold_final(&state->crc_fold);
+ strm->adler = state->check = FUNCTABLE_CALL(crc32_fold_final)(&state->crc_fold);
#endif
}
out = left;
/* check for correct dictionary identifier */
if (state->mode == DICT) {
- dictid = functable.adler32(ADLER32_INITIAL_VALUE, dictionary, dictLength);
+ dictid = FUNCTABLE_CALL(adler32)(ADLER32_INITIAL_VALUE, dictionary, dictLength);
if (dictid != state->check)
return Z_DATA_ERROR;
}
/* check function to use adler32() for zlib or crc32() for gzip */
#ifdef GUNZIP
# define UPDATE(check, buf, len) \
- (state->flags ? PREFIX(crc32)(check, buf, len) : functable.adler32(check, buf, len))
+ (state->flags ? PREFIX(crc32)(check, buf, len) : FUNCTABLE_CALL(adler32)(check, buf, len))
#else
-# define UPDATE(check, buf, len) functable.adler32(check, buf, len)
+# define UPDATE(check, buf, len) FUNCTABLE_CALL(adler32)(check, buf, len)
#endif
/* check macros for header crc */