P99

◆ P99_DECLARE_INIT_ONCE

#define P99_DECLARE_INIT_ONCE (   T,
  NAME,
  ARG 
)
Value:
\
struct NAME { \
p99_once_flag p00_once; \
T p00_val; \
}; \
P99_DECLARE_STRUCT(NAME); \
p99_inline \
void P99_PASTE3(p00_, NAME, _init_func)(T* ARG); \
p99_inline \
void P99_PASTE3(p00_, NAME, _init_once)(NAME* ARG) { \
if (P99_UNLIKELY(!ARG->p00_once.p00_done.p00_done)) \
do { \
P99_SPIN_EXCLUDE(&ARG->p00_once.p00_flg) { \
if (!ARG->p00_once.p00_done.p00_vdone) { \
P99_PASTE3(p00_, NAME, _init_func)(&ARG->p00_val); \
ARG->p00_once.p00_done.p00_vdone = true; \
} \
} \
} while (!ARG->p00_once.p00_done.p00_vdone); \
} \
p99_inline \
void P99_PASTE3(p00_, NAME, _init_func)(T* ARG)
Remarks
argument 0 should correspond to a type that is not a VLA.
argument 1 must be an identifier
argument 2 must be an identifier

Definition at line 75 of file p99_threads.h.

P99_PASTE3
#define P99_PASTE3(_1, _2, _3)
Definition: p99_paste.h:83
P99_UNLIKELY
#define P99_UNLIKELY(...)
Mark the conditional expression as being unlikely.
Definition: p99_compiler.h:994