21 static _Thread_local
unsigned phase;
22 static atomic_uint cs[2];
23 atomic_uint *c = cs + (phase & 1U);
28 l = atomic_fetch_add_explicit(c, -1, memory_order_release) == 1;
30 r = atomic_load_explicit(c, memory_order_relaxed);
33 l = !atomic_fetch_add_explicit(c, 1, memory_order_release);
36 r = atomic_load_explicit(c, memory_order_relaxed);
37 }
while(r != thr_cnt);
40 phase = (phase + 1) & 3U;