From: Hans Kristian Rosbach Date: Sun, 13 Jun 2021 11:57:45 +0000 (+0200) Subject: Add support for Thread Local Storage to ensure consistency in functable. X-Git-Tag: 2.1.0-beta1~562 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=101653c0201a2f487ca7268dd23c5b62c9ad9c79;p=thirdparty%2Fzlib-ng.git Add support for Thread Local Storage to ensure consistency in functable. --- diff --git a/zbuild.h b/zbuild.h index 0712b54fd..e47acf536 100644 --- a/zbuild.h +++ b/zbuild.h @@ -15,6 +15,20 @@ # endif #endif +/* Determine compiler support for TLS */ +#ifndef Z_TLS +# if __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__ +# define Z_TLS _Thread_local +# elif defined(__GNUC__) || defined(__SUNPRO_C) +# define Z_TLS __thread +# elif defined(_WIN32) && (defined(_MSC_VER) || defined(__ICL)) +# define Z_TLS __declspec(thread) +# else +# warning Unable to detect Thread Local Storage support. +# define Z_TLS +# endif +#endif + /* This has to be first include that defines any types */ #if defined(_MSC_VER) # if defined(_WIN64) diff --git a/zutil.h b/zutil.h index fa08f2aa7..75f0c28ca 100644 --- a/zutil.h +++ b/zutil.h @@ -24,10 +24,6 @@ # define Z_REGISTER #endif -#ifndef Z_TLS -# define Z_TLS -#endif - #include #include #include