24 #ifndef OF_HAVE_ATOMIC_OPS 25 # error No atomic operations available! 28 #if !defined(OF_HAVE_THREADS) 30 OFAtomicIntAdd(
volatile int *_Nonnull p,
int i)
35 static OF_INLINE int32_t
36 OFAtomicInt32Add(
volatile int32_t *_Nonnull p, int32_t i)
41 static OF_INLINE
void *_Nullable
42 OFAtomicPointerAdd(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
44 return (*(
char *
volatile *)p += i);
48 OFAtomicIntSubtract(
volatile int *_Nonnull p,
int i)
53 static OF_INLINE int32_t
54 OFAtomicInt32Subtract(
volatile int32_t *_Nonnull p, int32_t i)
59 static OF_INLINE
void *_Nullable
60 OFAtomicPointerSubtract(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
62 return (*(
char *
volatile *)p -= i);
66 OFAtomicIntIncrease(
volatile int *_Nonnull p)
71 static OF_INLINE int32_t
72 OFAtomicInt32Increase(
volatile int32_t *_Nonnull p)
78 OFAtomicIntDecrease(
volatile int *_Nonnull p)
83 static OF_INLINE int32_t
84 OFAtomicInt32Decrease(
volatile int32_t *_Nonnull p)
89 static OF_INLINE
unsigned int 90 OFAtomicIntOr(
volatile unsigned int *_Nonnull p,
unsigned int i)
95 static OF_INLINE uint32_t
96 OFAtomicInt32Or(
volatile uint32_t *_Nonnull p, uint32_t i)
101 static OF_INLINE
unsigned int 102 OFAtomicIntAnd(
volatile unsigned int *_Nonnull p,
unsigned int i)
107 static OF_INLINE uint32_t
108 OFAtomicInt32And(
volatile uint32_t *_Nonnull p, uint32_t i)
113 static OF_INLINE
unsigned int 114 OFAtomicIntXor(
volatile unsigned int *_Nonnull p,
unsigned int i)
119 static OF_INLINE uint32_t
120 OFAtomicInt32Xor(
volatile uint32_t *_Nonnull p, uint32_t i)
125 static OF_INLINE
bool 126 OFAtomicIntCompareAndSwap(
volatile int *_Nonnull p,
int o,
int n)
136 static OF_INLINE
bool 137 OFAtomicInt32CompareAndSwap(
volatile int32_t *_Nonnull p, int32_t o, int32_t n)
147 static OF_INLINE
bool 148 OFAtomicPointerCompareAndSwap(
void *
volatile _Nullable *_Nonnull p,
149 void *_Nullable o,
void *_Nullable n)
159 static OF_INLINE
void 160 OFMemoryBarrier(
void)
165 static OF_INLINE
void 166 OFAcquireMemoryBarrier(
void)
171 static OF_INLINE
void 172 OFReleaseMemoryBarrier(
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!