]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Add support for Thread Local Storage to ensure consistency in functable.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Sun, 13 Jun 2021 11:57:45 +0000 (13:57 +0200)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 18 Jun 2021 07:24:35 +0000 (09:24 +0200)
zbuild.h
zutil.h

index 0712b54fd62bb4e4001ba96e59466e10033edd32..e47acf5368f35974d2c127d4db2efe5651e53c74 100644 (file)
--- a/zbuild.h
+++ b/zbuild.h
 #  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 fa08f2aa782a57fef80d9319b1aef0440bd0e7b3..75f0c28ca4e93e8bacca7d8d29d7cd162ef7c139 100644 (file)
--- a/zutil.h
+++ b/zutil.h
 #  define Z_REGISTER
 #endif
 
-#ifndef Z_TLS
-#  define Z_TLS
-#endif
-
 #include <stddef.h>
 #include <string.h>
 #include <stdlib.h>