166 #if (defined(__STDC_VERSION__) && __STDC_VERSION__ > 201112L) \
167 || (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 408)) \
168 || (defined(__clang__) && (__clang_major__ * 100 + __clang_minor__ >= 307)) \
169 || defined(DOXYGEN_RUN)
174 #define _Atomic(T) std::atomic<T>
175 #define atomic_flag std::atomic_flag
176 #define atomic_int std::atomic_int
177 #define atomic_uint std::atomic_uint
178 #define atomic_size_t std::atomic_size_t
179 #define atomic_uintptr_t std::atomic_uintptr_t
181 #include <stdatomic.h>
185 #define SOL_ATOMIC_INIT ATOMIC_VAR_INIT
186 #define SOL_ATOMIC_FLAG_INIT ATOMIC_FLAG_INIT
189 #define SOL_ATOMIC_RELAXED memory_order_relaxed
190 #define SOL_ATOMIC_CONSUME memory_order_consume
191 #define SOL_ATOMIC_ACQUIRE memory_order_acquire
192 #define SOL_ATOMIC_RELEASE memory_order_release
193 #define SOL_ATOMIC_ACQ_REL memory_order_acq_rel
194 #define SOL_ATOMIC_SEQ_CST memory_order_seq_cst
204 #define sol_atomic_test_and_set atomic_flag_test_and_set_explicit
205 #define sol_atomic_clear atomic_flag_clear_explicit
206 #define sol_atomic_store atomic_store_explicit
207 #define sol_atomic_load atomic_load_explicit
208 #define sol_atomic_exchange atomic_exchange_explicit
209 #define sol_atomic_compare_exchange atomic_compare_exchange_strong_explicit
210 #define sol_atomic_fetch_add atomic_fetch_add_explicit
212 #elif (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ * 100 + __GNUC_MINOR__ > 406))
218 #define SOL_ATOMIC_INIT(x) (x)
219 #define SOL_ATOMIC_FLAG_INIT false
222 #define SOL_ATOMIC_RELAXED __ATOMIC_RELAXED
223 #define SOL_ATOMIC_CONSUME __ATOMIC_CONSUME
224 #define SOL_ATOMIC_ACQUIRE __ATOMIC_ACQUIRE
225 #define SOL_ATOMIC_RELEASE __ATOMIC_RELEASE
226 #define SOL_ATOMIC_ACQ_REL __ATOMIC_ACQ_REL
227 #define SOL_ATOMIC_SEQ_CST __ATOMIC_SEQ_CST
237 #define sol_atomic_test_and_set __atomic_test_and_set
238 #define sol_atomic_clear __atomic_clear
239 #define sol_atomic_store __atomic_store_n
240 #define sol_atomic_load __atomic_load_n
241 #define sol_atomic_exchange __atomic_exchange_n
242 #define sol_atomic_compare_exchange(object, expected, desired, mo_suc, mo_fail) \
243 __atomic_compare_exchange_n((object), (expected), (desired), 0, (mo_suc), (mo_fail))
244 #define sol_fetch_add __atomic_fetch_add
247 #error "Atomic API not supported on this platform, please contribute."
atomic_int sol_atomic_int
An atomic variable compatible with an int.
Definition: sol-atomic.h:198
atomic_flag sol_atomic_flag
An atomic variable that can contain only two states: set or unset.
Definition: sol-atomic.h:197
atomic_uintptr_t sol_atomic_uintptr_t
An atomic variable compatible with an uintptr_t.
Definition: sol-atomic.h:201
atomic_size_t sol_atomic_size_t
An atomic variable compatible with a size_t.
Definition: sol-atomic.h:200
atomic_uint sol_atomic_uint
An atomic variable compatible with an unsigned int.
Definition: sol-atomic.h:199