summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2023-05-08 18:52:47 +0200
committerGitHub <noreply@github.com>2023-05-08 18:52:47 +0200
commitec3bca8fab723563bc9fb99ce9d5161652ce6945 (patch)
treef81a39d1a47c0dba97d453dd7b89b09f990d3788 /lib
parente45eb39ef7c194ee16a9fd3c2d08997f62c44375 (diff)
downloadNim-ec3bca8fab723563bc9fb99ce9d5161652ce6945.tar.gz
Windows: use __declspec(thread) TLS implementation, it is MUCH faster… (#21810)
* Windows: use __declspec(thread) TLS implementation, it is MUCH faster than _Thread_local [backport]

* Update lib/nimbase.h

* better fix
Diffstat (limited to 'lib')
-rw-r--r--lib/nimbase.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/nimbase.h b/lib/nimbase.h
index b9b2695c9..570b50b08 100644
--- a/lib/nimbase.h
+++ b/lib/nimbase.h
@@ -125,7 +125,13 @@ __AVR__
   NIM_THREADVAR declaration based on
   http://stackoverflow.com/questions/18298280/how-to-declare-a-variable-as-thread-local-portably
 */
-#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
+#if defined _WIN32
+#  if defined _MSC_VER || defined __DMC__ || defined __BORLANDC__
+#    define NIM_THREADVAR __declspec(thread)
+#  else
+#    define NIM_THREADVAR __thread
+#  endif
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
 #  define NIM_THREADVAR _Thread_local
 #elif defined _WIN32 && ( \
        defined _MSC_VER || \