22#if defined(WIN32_LEAN_AND_MEAN)
25#define WIN32_LEAN_AND_MEAN
27#undef WIN32_LEAN_AND_MEAN
47#define as_load_ptr(_target) (*(void volatile**)(_target))
50#define as_load_uint64(_target) (*(uint64_t volatile*)(_target))
53#define as_load_int64(_target) (*(int64_t volatile*)(_target))
56#define as_load_uint32(_target) (*(uint32_t volatile*)(_target))
59#define as_load_int32(_target) (*(int32_t volatile*)(_target))
62#define as_load_uint16(_target) (*(uint16_t volatile*)(_target))
65#define as_load_int16(_target) (*(int16_t volatile*)(_target))
68#define as_load_uint8(_target) (*(uint8_t volatile*)(_target))
71#define as_load_int8(_target) (*(int8_t volatile*)(_target))
76#define as_load_ptr_acq(_target) (*(void volatile**)(_target))
79#define as_load_uint64_acq(_target) (*(uint64_t volatile*)(_target))
82#define as_load_int64_acq(_target) (*(int64_t volatile*)(_target))
85#define as_load_uint32_acq(_target) (*(uint32_t volatile*)(_target))
88#define as_load_int32_acq(_target) (*(int32_t volatile*)(_target))
91#define as_load_uint16_acq(_target) (*(uint16_t volatile*)(_target))
94#define as_load_int16_acq(_target) (*(int16_t volatile*)(_target))
97#define as_load_uint8_acq(_target) (*(uint8_t volatile*)(_target))
100#define as_load_int8_acq(_target) (*(int8_t volatile*)(_target))
107#define as_store_ptr(_target, _value) *(void volatile**)(_target) = _value
110#define as_store_uint64(_target, _value) *(uint64_t volatile*)(_target) = _value
113#define as_store_int64(_target, _value) *(int64_t volatile*)(_target) = _value
116#define as_store_uint32(_target, _value) *(uint32_t volatile*)(_target) = _value
119#define as_store_int32(_target, _value) *(int32_t volatile*)(_target) = _value
122#define as_store_uint16(_target, _value) *(uint16_t volatile*)(_target) = _value
125#define as_store_int16(_target, _value) *(int16_t volatile*)(_target) = _value
128#define as_store_uint8(_target, _value) *(uint8_t volatile*)(_target) = _value
131#define as_store_int8(_target, _value) *(int8_t volatile*)(_target) = _value
136#define as_store_ptr_rls(_target, _value) *(void volatile**)(_target) = _value
139#define as_store_uint64_rls(_target, _value) *(uint64_t volatile*)(_target) = _value
142#define as_store_int64_rls(_target, _value) *(int64_t volatile*)(_target) = _value
145#define as_store_uint32_rls(_target, _value) *(uint32_t volatile*)(_target) = _value
148#define as_store_int32_rls(_target, _value) *(int32_t volatile*)(_target) = _value
151#define as_store_uint16_rls(_target, _value) *(uint16_t volatile*)(_target) = _value
154#define as_store_int16_rls(_target, _value) *(int16_t volatile*)(_target) = _value
157#define as_store_uint8_rls(_target, _value) *(uint8_t volatile*)(_target) = _value
160#define as_store_int8_rls(_target, _value) *(int8_t volatile*)(_target) = _value
167#define as_faa_uint64(_target, _value) (uint64_t)InterlockedExchangeAdd64((LONGLONG volatile*)(_target), _value)
170#define as_faa_int64(_target, _value) InterlockedExchangeAdd64((LONGLONG volatile*)(_target), _value)
173#define as_faa_uint32(_target, _value) (uint32_t)InterlockedExchangeAdd((LONG volatile*)(_target), _value)
176#define as_faa_int32(_target, _value) InterlockedExchangeAdd((LONG volatile*)(_target), _value)
187#define as_aaf_uint64(_target, _value) (uint64_t)InterlockedAdd64((LONGLONG volatile*)(_target), _value)
190#define as_aaf_int64(_target, _value) InterlockedAdd64((LONGLONG volatile*)(_target), _value)
193#define as_aaf_uint32(_target, _value) (uint32_t)InterlockedAdd((LONG volatile*)(_target), _value)
196#define as_aaf_int32(_target, _value) InterlockedAdd((LONG volatile*)(_target), _value)
201#define as_aaf_uint64_rls(_target, _value) (uint64_t)InterlockedAdd64((LONGLONG volatile*)(_target), _value)
204#define as_aaf_int64_rls(_target, _value) InterlockedAdd64((LONGLONG volatile*)(_target), _value)
207#define as_aaf_uint32_rls(_target, _value) (uint32_t)InterlockedAdd((LONG volatile*)(_target), _value)
210#define as_aaf_int32_rls(_target, _value) InterlockedAdd((LONG volatile*)(_target), _value)
223#define as_add_uint64(_target, _value) InterlockedExchangeAdd64((LONGLONG volatile*)(_target), _value)
226#define as_add_int64(_target, _value) InterlockedExchangeAdd64((LONGLONG volatile*)(_target), _value)
229#define as_add_uint32(_target, _value) InterlockedExchangeAdd((LONG volatile*)(_target), _value)
232#define as_add_int32(_target, _value) InterlockedExchangeAdd((LONG volatile*)(_target), _value)
243#define as_incr_uint64(_target) InterlockedIncrement64((LONGLONG volatile*)(_target))
246#define as_incr_int64(_target) InterlockedIncrement64((LONGLONG volatile*)(_target))
249#define as_incr_uint32(_target) InterlockedIncrement((LONG volatile*)(_target))
252#define as_incr_int32(_target) InterlockedIncrement((LONG volatile*)(_target))
255#define as_incr_uint16(_target) InterlockedIncrement16((short volatile*)(_target))
258#define as_incr_int16(_target) InterlockedIncrement16((short volatile*)(_target))
263#define as_incr_uint64_rls(_target) InterlockedIncrement64((LONGLONG volatile*)(_target))
266#define as_incr_int64_rls(_target) InterlockedIncrement64((LONGLONG volatile*)(_target))
269#define as_incr_uint32_rls(_target) InterlockedIncrement((LONG volatile*)(_target))
272#define as_incr_int32_rls(_target) InterlockedIncrement((LONG volatile*)(_target))
275#define as_incr_uint16_rls(_target) InterlockedIncrement16((short volatile*)(_target))
278#define as_incr_int16_rls(_target) InterlockedIncrement16((short volatile*)(_target))
285#define as_decr_uint64(_target) InterlockedDecrement64((LONGLONG volatile*)(_target))
288#define as_decr_int64(_target) InterlockedDecrement64((LONGLONG volatile*)(_target))
291#define as_decr_uint32(_target) InterlockedDecrement((LONG volatile*)(_target))
294#define as_decr_int32(_target) InterlockedDecrement((LONG volatile*)(_target))
297#define as_decr_uint16(_target) InterlockedDecrement16((short volatile*)(_target))
300#define as_decr_int16(_target) InterlockedDecrement16((short volatile*)(_target))
305#define as_decr_uint64_rls(_target) InterlockedDecrement64((LONGLONG volatile*)(_target))
308#define as_decr_int64_rls(_target) InterlockedDecrement64((LONGLONG volatile*)(_target))
311#define as_decr_uint32_rls(_target) InterlockedDecrement((LONG volatile*)(_target))
314#define as_decr_int32_rls(_target) InterlockedDecrement((LONG volatile*)(_target))
317#define as_decr_uint16_rls(_target) InterlockedDecrement16((short volatile*)(_target))
320#define as_decr_int16_rls(_target) InterlockedDecrement16((short volatile*)(_target))
327#define as_fas_uint64(_target, _value) (uint64_t)InterlockedExchange64((LONGLONG volatile*)(_target), (LONGLONG)(_value))
330#define as_fas_int64(_target, _value) InterlockedExchange64((LONGLONG volatile*)(_target), (LONGLONG)(_value))
333#define as_fas_uint32(_target, _value) (uint32_t)InterlockedExchange((LONG volatile*)(_target), (LONG)(_value))
336#define as_fas_int32(_target, _value) InterlockedExchange((LONG volatile*)(_target), (LONG)(_value))
339#define as_fas_uint16(_target, _value) (uint16_t)InterlockedExchange16((short volatile*)(_target), (LONG)(_value))
342#define as_fas_int16(_target, _value) InterlockedExchange16((short volatile*)(_target), (LONG)(_value))
349#define as_cas_uint64(_target, _old_value, _new_value) (InterlockedCompareExchange64((LONGLONG volatile*)(_target), (LONGLONG)(_new_value), (LONGLONG)(_old_value)) == (LONGLONG)(_old_value))
352#define as_cas_int64(_target, _old_value, _new_value) (InterlockedCompareExchange64((LONGLONG volatile*)(_target), (LONGLONG)(_new_value), (LONGLONG)(_old_value)) == (LONGLONG)(_old_value))
355#define as_cas_uint32(_target, _old_value, _new_value) (InterlockedCompareExchange((LONG volatile*)(_target), (LONG)(_new_value), (LONG)(_old_value)) == (LONG)(_old_value))
358#define as_cas_int32(_target, _old_value, _new_value) (InterlockedCompareExchange((LONG volatile*)(_target), (LONG)(_new_value), (LONG)(_old_value)) == (LONG)(_old_value))
361#define as_cas_uint16(_target, _old_value, _new_value) (InterlockedCompareExchange16((short volatile*)(_target), (short)(_new_value), (short)(_old_value)) == (short)(_old_value))
364#define as_cas_int16(_target, _old_value, _new_value) (InterlockedCompareExchange16((short volatile*)(_target), (short)(_new_value), (short)(_old_value)) == (short)(_old_value))
367#define as_cas_uint8(_target, _old_value, _new_value) (_InterlockedCompareExchange8((char volatile*)(_target), (char)(_new_value), (char)(_old_value)) == (char)(_old_value))
370#define as_cas_int8(_target, _old_value, _new_value) (_InterlockedCompareExchange8((char volatile*)(_target), (char)(_new_value), (char)(_old_value)) == (char)(_old_value))
381#define as_fence_acq MemoryBarrier
384#define as_fence_rls MemoryBarrier
387#define as_fence_rlx MemoryBarrier
390#define as_fence_seq MemoryBarrier
398#define AS_SPINLOCK_INIT { 0 }
399#define as_spinlock_init(_s) *(_s) = 0
400#define as_spinlock_destroy(_s) ((void)_s)
426#define AS_SWLOCK_INIT { 0 }
427#define as_swlock_init(_s) (_s) = 0
428#define as_swlock_destroy(_s) ((void)_s)
430#define AS_SWLOCK_WRITER_BIT (1 << 31)
431#define AS_SWLOCK_LATCH_BIT (1 << 30)
432#define AS_SWLOCK_WRITER_MASK (AS_SWLOCK_LATCH_BIT | AS_SWLOCK_WRITER_BIT)
433#define AS_SWLOCK_READER_MASK (UINT32_MAX ^ AS_SWLOCK_WRITER_MASK)
497 prior = InterlockedCompareExchange64((LONGLONG
volatile*)target, x, cur);
522 prior = InterlockedCompareExchange((LONG
volatile*)target, x, cur);
#define AS_SWLOCK_READER_MASK
static void as_swlock_read_lock(as_swlock *lock)
#define as_faa_uint32(_target, _value)
static void as_spinlock_unlock(as_spinlock *lock)
#define AS_SWLOCK_WRITER_BIT
#define as_fas_uint32(_target, _value)
static void as_spinlock_lock(as_spinlock *lock)
#define as_load_uint64(_target)
static bool as_setmax_uint64(uint64_t *target, uint64_t x)
#define as_decr_uint32(_target)
static bool as_setmax_uint32(uint32_t *target, uint32_t x)
static void as_swlock_read_unlock(as_swlock *lock)
static void as_swlock_write_unlock(as_swlock *lock)
#define as_load_uint32(_target)
#define as_store_uint32(_target, _value)
static void as_swlock_write_lock(as_swlock *lock)
#define AS_SWLOCK_WRITER_MASK