2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-09-01 06:55:30 +00:00

Add and use ISC_THREAD_LOCAL macro

The new ISC_THREAD_LOCAL macro unifies usage of platform dependent
Thread Local Storage definition thread_local vs __thread vs
__declspec(thread) to a single macro.

The commit also unifies the required level of support for TLS as for
some parts of the code it was mandatory and for some parts of the code
it wasn't.
This commit is contained in:
Ondřej Surý
2019-12-02 11:42:50 +01:00
committed by Ondřej Surý
parent 96475e7eb4
commit 01731d4b1b
10 changed files with 35 additions and 111 deletions

View File

@@ -36,6 +36,7 @@
#include <isc/platform.h>
#include <isc/random.h>
#include <isc/result.h>
#include <isc/thread.h>
#include <isc/types.h>
#include <isc/util.h>
@@ -60,20 +61,7 @@
*/
#include "xoshiro128starstar.c"
#if defined(HAVE_TLS)
#if defined(HAVE_THREAD_LOCAL)
#include <threads.h>
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
#else
static isc_once_t isc_random_once = ISC_ONCE_INIT;
#endif
ISC_THREAD_LOCAL isc_once_t isc_random_once = ISC_ONCE_INIT;
static void
isc_random_initialize(void) {