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
void *_Nullable
36 OFAtomicPointerAdd(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
38 return (*(
char *
volatile *)p += i);
42 OFAtomicIntSubtract(
volatile int *_Nonnull p,
int i)
47 static OF_INLINE
void *_Nullable
48 OFAtomicPointerSubtract(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
50 return (*(
char *
volatile *)p -= i);
54 OFAtomicIntIncrease(
volatile int *_Nonnull p)
60 OFAtomicIntDecrease(
volatile int *_Nonnull p)
65 static OF_INLINE
unsigned int 66 OFAtomicIntOr(
volatile unsigned int *_Nonnull p,
unsigned int i)
71 static OF_INLINE
unsigned int 72 OFAtomicIntAnd(
volatile unsigned int *_Nonnull p,
unsigned int i)
78 OFAtomicIntCompareAndSwap(
volatile int *_Nonnull p,
int o,
int n)
89 OFAtomicPointerCompareAndSwap(
void *
volatile _Nullable *_Nonnull p,
90 void *_Nullable o,
void *_Nullable n)
100 static OF_INLINE
void 101 OFMemoryBarrier(
void)
106 static OF_INLINE
void 107 OFAcquireMemoryBarrier(
void)
112 static OF_INLINE
void 113 OFReleaseMemoryBarrier(
void)
117 #elif (defined(OF_AMD64) || defined(OF_X86)) && defined(__GNUC__) 118 # import "platform/x86/OFAtomic.h" 119 #elif defined(OF_POWERPC) && defined(__GNUC__) && !defined(__APPLE_CC__) && \ 121 # import "platform/PowerPC/OFAtomic.h" 122 #elif defined(OF_HAVE_ATOMIC_BUILTINS) 123 # import "platform/GCC4.7/OFAtomic.h" 124 #elif defined(OF_HAVE_SYNC_BUILTINS) 125 # import "platform/GCC4/OFAtomic.h" 126 #elif defined(OF_HAVE_OSATOMIC) 127 # import "platform/macOS/OFAtomic.h" 129 # error No atomic operations available!