From 7ab228cf7187b2eb76e197f6be4cb686f3e39820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Sat, 25 Aug 2018 13:29:27 +0200 Subject: [PATCH] Use __declspec( thread ) for thread local storage when compiling with Visual Studio 2015 and higher --- lib/isc/random.c | 2 ++ lib/isc/win32/include/isc/platform.h.in | 5 +++++ lib/isc/xoshiro128starstar.c | 2 ++ 3 files changed, 9 insertions(+) diff --git a/lib/isc/random.c b/lib/isc/random.c index 9cf635a37f..3f49cb512f 100644 --- a/lib/isc/random.c +++ b/lib/isc/random.c @@ -67,6 +67,8 @@ static thread_local isc_once_t isc_random_once = ISC_ONCE_INIT; #elif defined(HAVE___THREAD) static __thread isc_once_t isc_random_once = ISC_ONCE_INIT; +#elif defined(HAVE___DECLSPEC_THREAD) +static __declspec( thread ) isc_once_t isc_random_once = ISC_ONCE_INIT; #else #error "Unknown method for defining a TLS variable!" #endif diff --git a/lib/isc/win32/include/isc/platform.h.in b/lib/isc/win32/include/isc/platform.h.in index 7f2bdbfb6b..691ac00122 100644 --- a/lib/isc/win32/include/isc/platform.h.in +++ b/lib/isc/win32/include/isc/platform.h.in @@ -16,6 +16,11 @@ ***** Platform-dependent defines. *****/ +#if _MSC_VER > 1400 +#define HAVE_TLS 1 +#define HAVE___DECLSPEC_THREAD 1 +#endif + /* * Some compatibility cludges */ diff --git a/lib/isc/xoshiro128starstar.c b/lib/isc/xoshiro128starstar.c index bc08e6740f..fb71a24419 100644 --- a/lib/isc/xoshiro128starstar.c +++ b/lib/isc/xoshiro128starstar.c @@ -42,6 +42,8 @@ static thread_local uint32_t seed[4]; #elif defined(HAVE___THREAD) static __thread uint32_t seed[4]; +#elif defined(HAVE___DECLSPEC_THREAD) +static __declspec( thread ) uint32_t seed[4]; #else #error "Unknown method for defining a TLS variable!" #endif