From: Nathan Moinvaziri Date: Fri, 19 Jun 2020 04:09:30 +0000 (-0700) Subject: Added ZLIB_REGISTER to disable register keyword for C++. X-Git-Tag: 1.9.9-b1~168 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e1dbcc186a62620a1dd7b427846b7f34d51b229b;p=thirdparty%2Fzlib-ng.git Added ZLIB_REGISTER to disable register keyword for C++. Co-authored-by: pps83 --- diff --git a/arch/arm/crc32_acle.c b/arch/arm/crc32_acle.c index 8c29577a..82731223 100644 --- a/arch/arm/crc32_acle.c +++ b/arch/arm/crc32_acle.c @@ -9,13 +9,12 @@ #ifndef _MSC_VER # include #endif -#include "../../zbuild.h" #include "../../zutil.h" uint32_t crc32_acle(uint32_t crc, const unsigned char *buf, uint64_t len) { - register uint32_t c; - register const uint16_t *buf2; - register const uint32_t *buf4; + ZLIB_REGISTER uint32_t c; + ZLIB_REGISTER const uint16_t *buf2; + ZLIB_REGISTER const uint32_t *buf4; c = ~crc; if (len && ((ptrdiff_t)buf & 1)) { diff --git a/arch/arm/slide_neon.c b/arch/arm/slide_neon.c index c3707345..b5b4fdf0 100644 --- a/arch/arm/slide_neon.c +++ b/arch/arm/slide_neon.c @@ -19,8 +19,8 @@ /* SIMD version of hash_chain rebase */ static inline void slide_hash_chain(Pos *table, unsigned int entries, uint16_t window_size) { - register uint16x8_t v, *p; - register size_t n; + ZLIB_REGISTER uint16x8_t v, *p; + ZLIB_REGISTER size_t n; size_t size = entries*sizeof(table[0]); Assert((size % sizeof(uint16x8_t) * 8 == 0), "hash table size err"); diff --git a/arch/s390/dfltcc_common.c b/arch/s390/dfltcc_common.c index 364825e3..bae40a2b 100644 --- a/arch/s390/dfltcc_common.c +++ b/arch/s390/dfltcc_common.c @@ -14,7 +14,7 @@ */ static inline int is_dfltcc_enabled(void) { uint64_t facilities[(DFLTCC_FACILITY / 64) + 1]; - register uint8_t r0 __asm__("r0"); + ZLIB_REGISTER uint8_t r0 __asm__("r0"); memset(facilities, 0, sizeof(facilities)); r0 = sizeof(facilities) / sizeof(facilities[0]) - 1; diff --git a/arch/s390/dfltcc_detail.h b/arch/s390/dfltcc_detail.h index 7c5c0945..6b2905bc 100644 --- a/arch/s390/dfltcc_detail.h +++ b/arch/s390/dfltcc_detail.h @@ -51,12 +51,12 @@ static inline dfltcc_cc dfltcc(int fn, void *param, size_t t3 = len1 ? *len1 : 0; const unsigned char *t4 = op2 ? *op2 : NULL; size_t t5 = len2 ? *len2 : 0; - register int r0 __asm__("r0") = fn; - register void *r1 __asm__("r1") = param; - register unsigned char *r2 __asm__("r2") = t2; - register size_t r3 __asm__("r3") = t3; - register const unsigned char *r4 __asm__("r4") = t4; - register size_t r5 __asm__("r5") = t5; + ZLIB_REGISTER int r0 __asm__("r0") = fn; + ZLIB_REGISTER void *r1 __asm__("r1") = param; + ZLIB_REGISTER unsigned char *r2 __asm__("r2") = t2; + ZLIB_REGISTER size_t r3 __asm__("r3") = t3; + ZLIB_REGISTER const unsigned char *r4 __asm__("r4") = t4; + ZLIB_REGISTER size_t r5 __asm__("r5") = t5; int cc; __asm__ volatile( diff --git a/crc32.c b/crc32.c index 341fd6fb..fa61a0d0 100644 --- a/crc32.c +++ b/crc32.c @@ -92,8 +92,8 @@ uint32_t ZEXPORT PREFIX(crc32)(uint32_t crc, const unsigned char *buf, uint32_t /* ========================================================================= */ ZLIB_INTERNAL uint32_t crc32_little(uint32_t crc, const unsigned char *buf, uint64_t len) { - register uint32_t c; - register const uint32_t *buf4; + ZLIB_REGISTER uint32_t c; + ZLIB_REGISTER const uint32_t *buf4; c = crc; c = ~c; @@ -134,8 +134,8 @@ ZLIB_INTERNAL uint32_t crc32_little(uint32_t crc, const unsigned char *buf, uint /* ========================================================================= */ ZLIB_INTERNAL uint32_t crc32_big(uint32_t crc, const unsigned char *buf, uint64_t len) { - register uint32_t c; - register const uint32_t *buf4; + ZLIB_REGISTER uint32_t c; + ZLIB_REGISTER const uint32_t *buf4; c = ZSWAP32(crc); c = ~c; diff --git a/match_tpl.h b/match_tpl.h index 4fca7fe7..fc1223fd 100644 --- a/match_tpl.h +++ b/match_tpl.h @@ -32,12 +32,12 @@ typedef uint8_t bestcmp_t; int32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { unsigned int strstart = s->strstart; const unsigned wmask = s->w_mask; - unsigned char *window = s->window; - unsigned char *scan = window + strstart; + ZLIB_REGISTER unsigned char *window = s->window; + ZLIB_REGISTER unsigned char *scan = window + strstart; const Pos *prev = s->prev; unsigned chain_length; Pos limit; - unsigned int len, best_len, nice_match; + unsigned int best_len, nice_match; bestcmp_t scan_end, scan_start; /* @@ -73,7 +73,8 @@ int32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); do { - unsigned char *match; + ZLIB_REGISTER unsigned char *match; + ZLIB_REGISTER unsigned int len; int cont; if (cur_match >= strstart) break; diff --git a/trees.c b/trees.c index bf4df815..cdf853ea 100644 --- a/trees.c +++ b/trees.c @@ -814,7 +814,7 @@ static void bi_flush(deflate_state *s) { ZLIB_INTERNAL unsigned bi_reverse(unsigned code, int len) { /* code: the value to invert */ /* len: its bit length */ - register unsigned res = 0; + ZLIB_REGISTER unsigned res = 0; do { res |= code & 1; code >>= 1, res <<= 1; diff --git a/zutil.h b/zutil.h index 62b8e175..74dd781d 100644 --- a/zutil.h +++ b/zutil.h @@ -18,6 +18,12 @@ # define ZLIB_INTERNAL #endif +#ifndef __cplusplus +# define ZLIB_REGISTER register +#else +# define ZLIB_REGISTER +#endif + #include #include #include