]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add optional support for thread local storage. (#733)
authorNathan Moinvaziri <nathan@nathanm.com>
Sun, 23 Aug 2020 07:59:38 +0000 (00:59 -0700)
committerGitHub <noreply@github.com>
Sun, 23 Aug 2020 07:59:38 +0000 (09:59 +0200)
functable.c
functable.h
zbuild.h
zutil.h

index aa70046dd14af0874410a933b009db3eec4645d1..730fd26b79336c4e794b4db649d7d68eed5251ae 100644 (file)
@@ -126,7 +126,7 @@ extern int32_t longest_match_unaligned_avx2(deflate_state *const s, Pos cur_matc
 #endif
 #endif
 
-ZLIB_INTERNAL __thread struct functable_s functable;
+ZLIB_INTERNAL Z_TLS struct functable_s functable;
 
 ZLIB_INTERNAL void cpu_check_features(void)
 {
@@ -416,7 +416,7 @@ ZLIB_INTERNAL int32_t longest_match_stub(deflate_state *const s, Pos cur_match)
 }
 
 /* functable init */
-ZLIB_INTERNAL __thread struct functable_s functable = {
+ZLIB_INTERNAL Z_TLS struct functable_s functable = {
     insert_string_stub,
     quick_insert_string_stub,
     adler32_stub,
index 82b04c39befc44da7c13ed497151e190ccc4fcab..694206168507ffc724c89faf2c371c879ab4eb08 100644 (file)
@@ -24,6 +24,6 @@ struct functable_s {
     uint8_t* (* chunkmemset_safe)   (uint8_t *out, unsigned dist, unsigned len, unsigned left);
 };
 
-ZLIB_INTERNAL extern __thread struct functable_s functable;
+ZLIB_INTERNAL extern Z_TLS struct functable_s functable;
 
 #endif
index d45b1fee8609d1c273d1b0beea28939971022859..3bd4f4898df0408e1c45bfc47dbff3c464da84e0 100644 (file)
--- a/zbuild.h
+++ b/zbuild.h
@@ -8,7 +8,6 @@
 #  else
     typedef long ssize_t;
 #  endif
-#  define __thread __declspec(thread)
 #endif
 
 #if defined(ZLIB_COMPAT)
diff --git a/zutil.h b/zutil.h
index 9ca36ed34f7a8a75024140b830f9dbc4bfe401e7..4fb2e2fd21b56ecdd0ba73bcda1862df6bbf86a2 100644 (file)
--- a/zutil.h
+++ b/zutil.h
 #  define ZLIB_REGISTER
 #endif
 
+#ifndef Z_TLS
+#  define Z_TLS
+#endif
+
 #include <stddef.h>
 #include <string.h>
 #include <stdlib.h>