From: Nathan Moinvaziri Date: Sun, 23 Aug 2020 07:59:38 +0000 (-0700) Subject: Add optional support for thread local storage. (#733) X-Git-Tag: 1.9.9-b1~73 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a540c3f9638aadde613e1d14042d67b4a644b934;p=thirdparty%2Fzlib-ng.git Add optional support for thread local storage. (#733) --- diff --git a/functable.c b/functable.c index aa70046dd..730fd26b7 100644 --- a/functable.c +++ b/functable.c @@ -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, diff --git a/functable.h b/functable.h index 82b04c39b..694206168 100644 --- a/functable.h +++ b/functable.h @@ -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 diff --git a/zbuild.h b/zbuild.h index d45b1fee8..3bd4f4898 100644 --- 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 9ca36ed34..4fb2e2fd2 100644 --- a/zutil.h +++ b/zutil.h @@ -24,6 +24,10 @@ # define ZLIB_REGISTER #endif +#ifndef Z_TLS +# define Z_TLS +#endif + #include #include #include