]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Added ZLIB_REGISTER to disable register keyword for C++.
authorNathan Moinvaziri <nathan@nathanm.com>
Fri, 19 Jun 2020 04:09:30 +0000 (21:09 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Sun, 28 Jun 2020 21:01:17 +0000 (23:01 +0200)
Co-authored-by: pps83 <pps83@users.noreply.github.com>
arch/arm/crc32_acle.c
arch/arm/slide_neon.c
arch/s390/dfltcc_common.c
arch/s390/dfltcc_detail.h
crc32.c
match_tpl.h
trees.c
zutil.h

index 8c29577a5cc36bee3eb3c426116c2ae612cd595d..82731223088865c2db5b6f926e313396e405616f 100644 (file)
@@ -9,13 +9,12 @@
 #ifndef _MSC_VER
 #  include <arm_acle.h>
 #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)) {
index c37073450b08e26b0a21806f2288d3c8ecd0c1e6..b5b4fdf0a571dd7fe60fcc3d20eeca56b852d944 100644 (file)
@@ -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");
index 364825e3324a60d891a4fbdccc067782382bbd3f..bae40a2b59ce1f31a751a822170aa834530875ce 100644 (file)
@@ -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;
index 7c5c0945108789c843a1baecc52ebaad268e6fea..6b2905bc356dfd0d0d207837363eda36c2368ac2 100644 (file)
@@ -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 341fd6fb8c26e02c2e085034602609ecef6e17cb..fa61a0d0736930ec15db9a63882a871485b34e96 100644 (file)
--- 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;
index 4fca7fe7504a6157ad448d6dc5bd6f725b868634..fc1223fd3f0296db6573852dfc141ad3fade7ebb 100644 (file)
@@ -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 bf4df8151192973d260120e736b25fee16ffd278..cdf853eaf1cf964d1e926cd7d4398d26136c27d7 100644 (file)
--- 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 62b8e1752814e5a606a5f9965aa5e19c3268961b..74dd781dcfe31c96f383975e276d6d6ad62ae29d 100644 (file)
--- a/zutil.h
+++ b/zutil.h
 #  define ZLIB_INTERNAL
 #endif
 
+#ifndef __cplusplus
+#  define ZLIB_REGISTER register
+#else
+#  define ZLIB_REGISTER
+#endif
+
 #include <stddef.h>
 #include <string.h>
 #include <stdlib.h>