From ec3bca8fab723563bc9fb99ce9d5161652ce6945 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 8 May 2023 18:52:47 +0200 Subject: [PATCH] =?UTF-8?q?Windows:=20use=20=5F=5Fdeclspec(thread)=20TLS?= =?UTF-8?q?=20implementation,=20it=20is=20MUCH=20faster=E2=80=A6=20(#21810?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Windows: use __declspec(thread) TLS implementation, it is MUCH faster than _Thread_local [backport] * Update lib/nimbase.h * better fix --- lib/nimbase.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/nimbase.h b/lib/nimbase.h index b9b2695c9a..570b50b081 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 || \