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
This commit is contained in:
Andreas Rumpf
2023-05-08 18:52:47 +02:00
committed by GitHub
parent e45eb39ef7
commit ec3bca8fab

View File

@@ -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 || \