19#ifndef COMPAT_ATOMICS_WIN32_STDATOMIC_H
20#define COMPAT_ATOMICS_WIN32_STDATOMIC_H
26#define ATOMIC_FLAG_INIT 0
28#define ATOMIC_VAR_INIT(value) (value)
30#define atomic_init(obj, value) \
35#define kill_dependency(y) ((void)0)
37#define atomic_thread_fence(order) \
40#define atomic_signal_fence(order) \
43#define atomic_is_lock_free(obj) 0
82#define atomic_store(object, desired) \
84 *(object) = (desired); \
88#define atomic_store_explicit(object, desired, order) \
89 atomic_store(object, desired)
91#define atomic_load(object) \
92 (MemoryBarrier(), *(object))
94#define atomic_load_explicit(object, order) \
97#define atomic_exchange(object, desired) \
98 InterlockedExchangePointer((PVOID volatile *)object, (PVOID)desired)
100#define atomic_exchange_explicit(object, desired, order) \
101 atomic_exchange(object, desired)
106 intptr_t old = *expected;
107 *expected = (intptr_t)InterlockedCompareExchangePointer(
108 (PVOID *)
object, (PVOID)desired, (PVOID)old);
109 return *expected == old;
112#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
113 atomic_compare_exchange_strong(object, expected, desired)
115#define atomic_compare_exchange_weak(object, expected, desired) \
116 atomic_compare_exchange_strong(object, expected, desired)
118#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
119 atomic_compare_exchange_weak(object, expected, desired)
122#define atomic_fetch_add(object, operand) \
123 InterlockedExchangeAdd64(object, operand)
125#define atomic_fetch_sub(object, operand) \
126 InterlockedExchangeAdd64(object, -(operand))
128#define atomic_fetch_or(object, operand) \
129 InterlockedOr64(object, operand)
131#define atomic_fetch_xor(object, operand) \
132 InterlockedXor64(object, operand)
134#define atomic_fetch_and(object, operand) \
135 InterlockedAnd64(object, operand)
137#define atomic_fetch_add(object, operand) \
138 InterlockedExchangeAdd(object, operand)
140#define atomic_fetch_sub(object, operand) \
141 InterlockedExchangeAdd(object, -(operand))
143#define atomic_fetch_or(object, operand) \
144 InterlockedOr(object, operand)
146#define atomic_fetch_xor(object, operand) \
147 InterlockedXor(object, operand)
149#define atomic_fetch_and(object, operand) \
150 InterlockedAnd(object, operand)
153#define atomic_fetch_add_explicit(object, operand, order) \
154 atomic_fetch_add(object, operand)
156#define atomic_fetch_sub_explicit(object, operand, order) \
157 atomic_fetch_sub(object, operand)
159#define atomic_fetch_or_explicit(object, operand, order) \
160 atomic_fetch_or(object, operand)
162#define atomic_fetch_xor_explicit(object, operand, order) \
163 atomic_fetch_xor(object, operand)
165#define atomic_fetch_and_explicit(object, operand, order) \
166 atomic_fetch_and(object, operand)
168#define atomic_flag_test_and_set(object) \
169 atomic_exchange(object, 1)
171#define atomic_flag_test_and_set_explicit(object, order) \
172 atomic_flag_test_and_set(object)
174#define atomic_flag_clear(object) \
175 atomic_store(object, 0)
177#define atomic_flag_clear_explicit(object, order) \
178 atomic_flag_clear(object)
intptr_t atomic_uintmax_t
intptr_t atomic_ptrdiff_t
intptr_t atomic_uint_fast32_t
intptr_t atomic_uint_fast64_t
intptr_t atomic_uint_fast8_t
intptr_t atomic_uint_least32_t
intptr_t atomic_int_fast16_t
intptr_t atomic_int_fast32_t
intptr_t atomic_int_least8_t
intptr_t atomic_uint_least8_t
intptr_t atomic_int_least16_t
intptr_t atomic_int_least64_t
intptr_t atomic_uint_least64_t
intptr_t atomic_int_fast64_t
intptr_t atomic_int_fast8_t
intptr_t atomic_uint_least16_t
static int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected, intptr_t desired)
intptr_t atomic_uintptr_t
intptr_t atomic_int_least32_t
intptr_t atomic_uint_fast16_t