2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Merge branch 'ondrej/use_ATOMIC_VAR_INIT_to_initialize_tid_base_in_isc_hp_API' into 'master'

Use ATOMIC_VAR_INIT to initialize tid_v_base to 0

See merge request isc-projects/bind9!2660
This commit is contained in:
Ondřej Surý 2019-11-28 11:30:37 +00:00
commit 1ca1dda266

View File

@ -47,6 +47,7 @@
#include <isc/atomic.h>
#include <isc/hp.h>
#include <isc/once.h>
#include <isc/string.h>
#include <isc/mem.h>
#include <isc/util.h>
@ -61,8 +62,7 @@
#define TID_UNKNOWN -1
static atomic_int_fast32_t tid_v_base;
static bool tid_v_initialized;
static atomic_int_fast32_t tid_v_base = ATOMIC_VAR_INIT(0);
#if defined(HAVE_TLS)
#if defined(HAVE_THREAD_LOCAL)
@ -94,10 +94,6 @@ struct isc_hp {
static inline int
tid() {
if (!tid_v_initialized) {
atomic_init(&tid_v_base, 0);
tid_v_initialized = true;
}
if (tid_v == TID_UNKNOWN) {
tid_v = atomic_fetch_add(&tid_v_base, 1);
REQUIRE(tid_v < HP_MAX_THREADS);