24#ifndef OF_HAVE_ATOMIC_OPS
25# error No atomic operations available!
28#if !defined(OF_HAVE_THREADS)
30OFAtomicIntAdd(
volatile int *_Nonnull p,
int i)
35static OF_INLINE int32_t
36OFAtomicInt32Add(
volatile int32_t *_Nonnull p, int32_t i)
41static OF_INLINE
void *_Nullable
42OFAtomicPointerAdd(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
44 return (*(
char *
volatile *)p += i);
48OFAtomicIntSubtract(
volatile int *_Nonnull p,
int i)
53static OF_INLINE int32_t
54OFAtomicInt32Subtract(
volatile int32_t *_Nonnull p, int32_t i)
59static OF_INLINE
void *_Nullable
60OFAtomicPointerSubtract(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
62 return (*(
char *
volatile *)p -= i);
66OFAtomicIntIncrease(
volatile int *_Nonnull p)
71static OF_INLINE int32_t
72OFAtomicInt32Increase(
volatile int32_t *_Nonnull p)
78OFAtomicIntDecrease(
volatile int *_Nonnull p)
83static OF_INLINE int32_t
84OFAtomicInt32Decrease(
volatile int32_t *_Nonnull p)
89static OF_INLINE
unsigned int
90OFAtomicIntOr(
volatile unsigned int *_Nonnull p,
unsigned int i)
95static OF_INLINE uint32_t
96OFAtomicInt32Or(
volatile uint32_t *_Nonnull p, uint32_t i)
101static OF_INLINE
unsigned int
102OFAtomicIntAnd(
volatile unsigned int *_Nonnull p,
unsigned int i)
107static OF_INLINE uint32_t
108OFAtomicInt32And(
volatile uint32_t *_Nonnull p, uint32_t i)
113static OF_INLINE
unsigned int
114OFAtomicIntXor(
volatile unsigned int *_Nonnull p,
unsigned int i)
119static OF_INLINE uint32_t
120OFAtomicInt32Xor(
volatile uint32_t *_Nonnull p, uint32_t i)
126OFAtomicIntCompareAndSwap(
volatile int *_Nonnull p,
int o,
int n)
137OFAtomicInt32CompareAndSwap(
volatile int32_t *_Nonnull p, int32_t o, int32_t n)
148OFAtomicPointerCompareAndSwap(
void *
volatile _Nullable *_Nonnull p,
149 void *_Nullable o,
void *_Nullable n)
166OFAcquireMemoryBarrier(
void)
172OFReleaseMemoryBarrier(
void)
176#elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__)
177# import "platform/x86/OFAtomic.h"
178#elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \
180# import "platform/PowerPC/OFAtomic.h"
181#elif defined(OF_HAVE_ATOMIC_BUILTINS)
182# import "platform/GCC4.7/OFAtomic.h"
183#elif defined(OF_HAVE_SYNC_BUILTINS)
184# import "platform/GCC4/OFAtomic.h"
185#elif defined(OF_HAVE_OSATOMIC)
186# import "platform/macOS/OFAtomic.h"
188# error No atomic operations available!