Skip to content

Commit

Permalink
Windows: use __declspec(thread) TLS implementation, it is MUCH faster… (
Browse files Browse the repository at this point in the history
nim-lang#21810)

* Windows: use __declspec(thread) TLS implementation, it is MUCH faster than _Thread_local [backport]

* Update lib/nimbase.h

* better fix
  • Loading branch information
Araq authored and capocasa committed May 15, 2023
1 parent 241f567 commit 97e3c0a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/nimbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 || \
Expand Down

0 comments on commit 97e3c0a

Please sign in to comment.