Skip to content

Commit fe0a640

Browse files
phprusDead2
authored andcommitted
Explicitly indicate functions are conditionally dispatched
Signed-off-by: Vladislav Shchapov <[email protected]>
1 parent af494fc commit fe0a640

File tree

13 files changed

+45
-38
lines changed

13 files changed

+45
-38
lines changed

adler32.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,22 @@
99

1010
#ifdef ZLIB_COMPAT
1111
unsigned long Z_EXPORT PREFIX(adler32_z)(unsigned long adler, const unsigned char *buf, size_t len) {
12-
return (unsigned long)functable.adler32((uint32_t)adler, buf, len);
12+
return (unsigned long)FUNCTABLE_CALL(adler32)((uint32_t)adler, buf, len);
1313
}
1414
#else
1515
uint32_t Z_EXPORT PREFIX(adler32_z)(uint32_t adler, const unsigned char *buf, size_t len) {
16-
return functable.adler32(adler, buf, len);
16+
return FUNCTABLE_CALL(adler32)(adler, buf, len);
1717
}
1818
#endif
1919

2020
/* ========================================================================= */
2121
#ifdef ZLIB_COMPAT
2222
unsigned long Z_EXPORT PREFIX(adler32)(unsigned long adler, const unsigned char *buf, unsigned int len) {
23-
return (unsigned long)functable.adler32((uint32_t)adler, buf, len);
23+
return (unsigned long)FUNCTABLE_CALL(adler32)((uint32_t)adler, buf, len);
2424
}
2525
#else
2626
uint32_t Z_EXPORT PREFIX(adler32)(uint32_t adler, const unsigned char *buf, uint32_t len) {
27-
return functable.adler32(adler, buf, len);
27+
return FUNCTABLE_CALL(adler32)(adler, buf, len);
2828
}
2929
#endif
3030

arch/generic/adler32_fold_c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <limits.h>
1010

1111
Z_INTERNAL uint32_t adler32_fold_copy_c(uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len) {
12-
adler = functable.adler32(adler, src, len);
12+
adler = FUNCTABLE_CALL(adler32)(adler, src, len);
1313
memcpy(dst, src, len);
1414
return adler;
1515
}

arch/generic/crc32_fold_c.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Z_INTERNAL uint32_t crc32_fold_reset_c(crc32_fold *crc) {
1313
}
1414

1515
Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, size_t len) {
16-
crc->value = functable.crc32(crc->value, src, len);
16+
crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len);
1717
memcpy(dst, src, len);
1818
}
1919

@@ -23,7 +23,7 @@ Z_INTERNAL void crc32_fold_c(crc32_fold *crc, const uint8_t *src, size_t len, ui
2323
* same arguments for the versions that _do_ do a folding CRC but we don't want a copy. The
2424
* init_crc is an unused argument in this context */
2525
Z_UNUSED(init_crc);
26-
crc->value = functable.crc32(crc->value, src, len);
26+
crc->value = FUNCTABLE_CALL(crc32)(crc->value, src, len);
2727
}
2828

2929
Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc) {

crc32.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ const uint32_t * Z_EXPORT PREFIX(get_crc_table)(void) {
2121
unsigned long Z_EXPORT PREFIX(crc32_z)(unsigned long crc, const unsigned char *buf, size_t len) {
2222
if (buf == NULL) return 0;
2323

24-
return (unsigned long)functable.crc32((uint32_t)crc, buf, len);
24+
return (unsigned long)FUNCTABLE_CALL(crc32)((uint32_t)crc, buf, len);
2525
}
2626
#else
2727
uint32_t Z_EXPORT PREFIX(crc32_z)(uint32_t crc, const unsigned char *buf, size_t len) {
2828
if (buf == NULL) return 0;
2929

30-
return functable.crc32(crc, buf, len);
30+
return FUNCTABLE_CALL(crc32)(crc, buf, len);
3131
}
3232
#endif
3333

deflate.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ int32_t Z_EXPORT PREFIX(deflateSetDictionary)(PREFIX3(stream) *strm, const uint8
372372

373373
/* when using zlib wrappers, compute Adler-32 for provided dictionary */
374374
if (wrap == 1)
375-
strm->adler = functable.adler32(strm->adler, dictionary, dictLength);
375+
strm->adler = FUNCTABLE_CALL(adler32)(strm->adler, dictionary, dictLength);
376376
DEFLATE_SET_DICTIONARY_HOOK(strm, dictionary, dictLength); /* hook for IBM Z DFLTCC */
377377
s->wrap = 0; /* avoid computing Adler-32 in read_buf */
378378

@@ -459,7 +459,7 @@ int32_t Z_EXPORT PREFIX(deflateResetKeep)(PREFIX3(stream) *strm) {
459459

460460
#ifdef GZIP
461461
if (s->wrap == 2) {
462-
strm->adler = functable.crc32_fold_reset(&s->crc_fold);
462+
strm->adler = FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold);
463463
} else
464464
#endif
465465
strm->adler = ADLER32_INITIAL_VALUE;
@@ -565,7 +565,7 @@ int32_t Z_EXPORT PREFIX(deflateParams)(PREFIX3(stream) *strm, int32_t level, int
565565
if (s->level != level) {
566566
if (s->level == 0 && s->matches != 0) {
567567
if (s->matches == 1) {
568-
functable.slide_hash(s);
568+
FUNCTABLE_CALL(slide_hash)(s);
569569
} else {
570570
CLEAR_HASH(s);
571571
}
@@ -804,7 +804,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
804804
#ifdef GZIP
805805
if (s->status == GZIP_STATE) {
806806
/* gzip header */
807-
functable.crc32_fold_reset(&s->crc_fold);
807+
FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold);
808808
put_byte(s, 31);
809809
put_byte(s, 139);
810810
put_byte(s, 8);
@@ -921,7 +921,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
921921
}
922922
}
923923
put_short(s, (uint16_t)strm->adler);
924-
functable.crc32_fold_reset(&s->crc_fold);
924+
FUNCTABLE_CALL(crc32_fold_reset)(&s->crc_fold);
925925
}
926926
s->status = BUSY_STATE;
927927

@@ -992,7 +992,7 @@ int32_t Z_EXPORT PREFIX(deflate)(PREFIX3(stream) *strm, int32_t flush) {
992992
/* Write the trailer */
993993
#ifdef GZIP
994994
if (s->wrap == 2) {
995-
strm->adler = functable.crc32_fold_final(&s->crc_fold);
995+
strm->adler = FUNCTABLE_CALL(crc32_fold_final)(&s->crc_fold);
996996

997997
put_uint32(s, strm->adler);
998998
put_uint32(s, (uint32_t)strm->total_in);
@@ -1110,10 +1110,10 @@ Z_INTERNAL unsigned PREFIX(read_buf)(PREFIX3(stream) *strm, unsigned char *buf,
11101110
memcpy(buf, strm->next_in, len);
11111111
#ifdef GZIP
11121112
} else if (strm->state->wrap == 2) {
1113-
functable.crc32_fold_copy(&strm->state->crc_fold, buf, strm->next_in, len);
1113+
FUNCTABLE_CALL(crc32_fold_copy)(&strm->state->crc_fold, buf, strm->next_in, len);
11141114
#endif
11151115
} else if (strm->state->wrap == 1) {
1116-
strm->adler = functable.adler32_fold_copy(strm->adler, buf, strm->next_in, len);
1116+
strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len);
11171117
} else {
11181118
memcpy(buf, strm->next_in, len);
11191119
}
@@ -1206,7 +1206,7 @@ void Z_INTERNAL PREFIX(fill_window)(deflate_state *s) {
12061206
s->block_start -= (int)wsize;
12071207
if (s->insert > s->strstart)
12081208
s->insert = s->strstart;
1209-
functable.slide_hash(s);
1209+
FUNCTABLE_CALL(slide_hash)(s);
12101210
more += wsize;
12111211
}
12121212
if (s->strm->avail_in == 0)

deflate_fast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
5252
* of window index 0 (in particular we have to avoid a match
5353
* of the string with itself at the start of the input file).
5454
*/
55-
match_len = functable.longest_match(s, hash_head);
55+
match_len = FUNCTABLE_CALL(longest_match)(s, hash_head);
5656
/* longest_match() sets match_start */
5757
}
5858
}

deflate_medium.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
215215
* of window index 0 (in particular we have to avoid a match
216216
* of the string with itself at the start of the input file).
217217
*/
218-
current_match.match_length = (uint16_t)functable.longest_match(s, hash_head);
218+
current_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head);
219219
current_match.match_start = (uint16_t)s->match_start;
220220
if (UNLIKELY(current_match.match_length < WANT_MIN_MATCH))
221221
current_match.match_length = 1;
@@ -250,7 +250,7 @@ Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
250250
* of window index 0 (in particular we have to avoid a match
251251
* of the string with itself at the start of the input file).
252252
*/
253-
next_match.match_length = (uint16_t)functable.longest_match(s, hash_head);
253+
next_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head);
254254
next_match.match_start = (uint16_t)s->match_start;
255255
if (UNLIKELY(next_match.match_start >= next_match.strstart)) {
256256
/* this can happen due to some restarts */

deflate_quick.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
9494
const uint8_t *match_start = s->window + hash_head;
9595

9696
if (zng_memcmp_2(str_start, match_start) == 0) {
97-
match_len = functable.compare256(str_start+2, match_start+2) + 2;
97+
match_len = FUNCTABLE_CALL(compare256)(str_start+2, match_start+2) + 2;
9898

9999
if (match_len >= WANT_MIN_MATCH) {
100100
if (UNLIKELY(match_len > s->lookahead))

deflate_slow.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
2222
match_func longest_match;
2323

2424
if (s->max_chain_length <= 1024)
25-
longest_match = functable.longest_match;
25+
longest_match = FUNCTABLE_FPTR(longest_match);
2626
else
27-
longest_match = functable.longest_match_slow;
27+
longest_match = FUNCTABLE_FPTR(longest_match_slow);
2828

2929
/* Process the input block. */
3030
for (;;) {

functable.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@ struct functable_s {
2929

3030
Z_INTERNAL extern struct functable_s functable;
3131

32+
33+
/* Explicitly indicate functions are conditionally dispatched.
34+
*/
35+
#define FUNCTABLE_CALL(name) functable.name
36+
#define FUNCTABLE_FPTR(name) functable.name
37+
38+
3239
#endif

0 commit comments

Comments
 (0)