Go to the documentation of this file.
19 #ifndef COMPAT_ATOMICS_WIN32_STDATOMIC_H
20 #define COMPAT_ATOMICS_WIN32_STDATOMIC_H
22 #define WIN32_LEAN_AND_MEAN
27 #define ATOMIC_FLAG_INIT 0
29 #define ATOMIC_VAR_INIT(value) (value)
31 #define atomic_init(obj, value) \
36 #define kill_dependency(y) ((void)0)
38 #define atomic_thread_fence(order) \
41 #define atomic_signal_fence(order) \
44 #define atomic_is_lock_free(obj) 0
83 #define atomic_store(object, desired) \
85 *(object) = (desired); \
89 #define atomic_store_explicit(object, desired, order) \
90 atomic_store(object, desired)
92 #define atomic_load(object) \
93 (MemoryBarrier(), *(object))
95 #define atomic_load_explicit(object, order) \
98 #define atomic_exchange(object, desired) \
99 InterlockedExchangePointer((PVOID volatile *)object, (PVOID)desired)
101 #define atomic_exchange_explicit(object, desired, order) \
102 atomic_exchange(object, desired)
107 intptr_t old = *expected;
108 *expected = (intptr_t)InterlockedCompareExchangePointer(
109 (PVOID *)object, (PVOID)desired, (PVOID)old);
110 return *expected == old;
113 #define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \
114 atomic_compare_exchange_strong(object, expected, desired)
116 #define atomic_compare_exchange_weak(object, expected, desired) \
117 atomic_compare_exchange_strong(object, expected, desired)
119 #define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \
120 atomic_compare_exchange_weak(object, expected, desired)
123 #define atomic_fetch_add(object, operand) \
124 InterlockedExchangeAdd64(object, operand)
126 #define atomic_fetch_sub(object, operand) \
127 InterlockedExchangeAdd64(object, -(operand))
129 #define atomic_fetch_or(object, operand) \
130 InterlockedOr64(object, operand)
132 #define atomic_fetch_xor(object, operand) \
133 InterlockedXor64(object, operand)
135 #define atomic_fetch_and(object, operand) \
136 InterlockedAnd64(object, operand)
138 #define atomic_fetch_add(object, operand) \
139 InterlockedExchangeAdd(object, operand)
141 #define atomic_fetch_sub(object, operand) \
142 InterlockedExchangeAdd(object, -(operand))
144 #define atomic_fetch_or(object, operand) \
145 InterlockedOr(object, operand)
147 #define atomic_fetch_xor(object, operand) \
148 InterlockedXor(object, operand)
150 #define atomic_fetch_and(object, operand) \
151 InterlockedAnd(object, operand)
154 #define atomic_fetch_add_explicit(object, operand, order) \
155 atomic_fetch_add(object, operand)
157 #define atomic_fetch_sub_explicit(object, operand, order) \
158 atomic_fetch_sub(object, operand)
160 #define atomic_fetch_or_explicit(object, operand, order) \
161 atomic_fetch_or(object, operand)
163 #define atomic_fetch_xor_explicit(object, operand, order) \
164 atomic_fetch_xor(object, operand)
166 #define atomic_fetch_and_explicit(object, operand, order) \
167 atomic_fetch_and(object, operand)
169 #define atomic_flag_test_and_set(object) \
170 atomic_exchange(object, 1)
172 #define atomic_flag_test_and_set_explicit(object, order) \
173 atomic_flag_test_and_set(object)
175 #define atomic_flag_clear(object) \
176 atomic_store(object, 0)
178 #define atomic_flag_clear_explicit(object, order) \
179 atomic_flag_clear(object)
intptr_t atomic_ptrdiff_t
intptr_t atomic_uint_least8_t
intptr_t atomic_uint_fast8_t
intptr_t atomic_int_least8_t
intptr_t atomic_int_fast32_t
intptr_t atomic_int_fast16_t
intptr_t atomic_uintptr_t
intptr_t atomic_int_least32_t
intptr_t atomic_int_fast8_t
intptr_t atomic_uint_fast16_t
intptr_t atomic_int_least16_t
intptr_t atomic_uint_least16_t
intptr_t atomic_uint_fast32_t
intptr_t atomic_uint_least32_t
intptr_t atomic_int_least64_t
intptr_t atomic_int_fast64_t
static int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected, intptr_t desired)
intptr_t atomic_uint_fast64_t
intptr_t atomic_uintmax_t
intptr_t atomic_uint_least64_t