mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +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:
@@ -47,6 +47,7 @@
|
|||||||
|
|
||||||
#include <isc/atomic.h>
|
#include <isc/atomic.h>
|
||||||
#include <isc/hp.h>
|
#include <isc/hp.h>
|
||||||
|
#include <isc/once.h>
|
||||||
#include <isc/string.h>
|
#include <isc/string.h>
|
||||||
#include <isc/mem.h>
|
#include <isc/mem.h>
|
||||||
#include <isc/util.h>
|
#include <isc/util.h>
|
||||||
@@ -61,8 +62,7 @@
|
|||||||
|
|
||||||
#define TID_UNKNOWN -1
|
#define TID_UNKNOWN -1
|
||||||
|
|
||||||
static atomic_int_fast32_t tid_v_base;
|
static atomic_int_fast32_t tid_v_base = ATOMIC_VAR_INIT(0);
|
||||||
static bool tid_v_initialized;
|
|
||||||
|
|
||||||
#if defined(HAVE_TLS)
|
#if defined(HAVE_TLS)
|
||||||
#if defined(HAVE_THREAD_LOCAL)
|
#if defined(HAVE_THREAD_LOCAL)
|
||||||
@@ -94,10 +94,6 @@ struct isc_hp {
|
|||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
tid() {
|
tid() {
|
||||||
if (!tid_v_initialized) {
|
|
||||||
atomic_init(&tid_v_base, 0);
|
|
||||||
tid_v_initialized = true;
|
|
||||||
}
|
|
||||||
if (tid_v == TID_UNKNOWN) {
|
if (tid_v == TID_UNKNOWN) {
|
||||||
tid_v = atomic_fetch_add(&tid_v_base, 1);
|
tid_v = atomic_fetch_add(&tid_v_base, 1);
|
||||||
REQUIRE(tid_v < HP_MAX_THREADS);
|
REQUIRE(tid_v < HP_MAX_THREADS);
|
||||||
|
Reference in New Issue
Block a user