18 of_atomic_int_add(
volatile int *_Nonnull p,
int i)
20 return __sync_add_and_fetch(p, i);
23 static OF_INLINE int32_t
24 of_atomic_int32_add(
volatile int32_t *_Nonnull p, int32_t i)
26 return __sync_add_and_fetch(p, i);
29 static OF_INLINE
void *_Nullable
30 of_atomic_ptr_add(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
32 return __sync_add_and_fetch(p, (
void *)i);
36 of_atomic_int_sub(
volatile int *_Nonnull p,
int i)
38 return __sync_sub_and_fetch(p, i);
41 static OF_INLINE int32_t
42 of_atomic_int32_sub(
volatile int32_t *_Nonnull p, int32_t i)
44 return __sync_sub_and_fetch(p, i);
47 static OF_INLINE
void *_Nullable
48 of_atomic_ptr_sub(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
50 return __sync_sub_and_fetch(p, (
void *)i);
54 of_atomic_int_inc(
volatile int *_Nonnull p)
56 return __sync_add_and_fetch(p, 1);
59 static OF_INLINE int32_t
60 of_atomic_int32_inc(
volatile int32_t *_Nonnull p)
62 return __sync_add_and_fetch(p, 1);
66 of_atomic_int_dec(
volatile int *_Nonnull p)
68 return __sync_sub_and_fetch(p, 1);
71 static OF_INLINE int32_t
72 of_atomic_int32_dec(
volatile int32_t *_Nonnull p)
74 return __sync_sub_and_fetch(p, 1);
77 static OF_INLINE
unsigned int 78 of_atomic_int_or(
volatile unsigned int *_Nonnull p,
unsigned int i)
80 return __sync_or_and_fetch(p, i);
83 static OF_INLINE uint32_t
84 of_atomic_int32_or(
volatile uint32_t *_Nonnull p, uint32_t i)
86 return __sync_or_and_fetch(p, i);
89 static OF_INLINE
unsigned int 90 of_atomic_int_and(
volatile unsigned int *_Nonnull p,
unsigned int i)
92 return __sync_and_and_fetch(p, i);
95 static OF_INLINE uint32_t
96 of_atomic_int32_and(
volatile uint32_t *_Nonnull p, uint32_t i)
98 return __sync_and_and_fetch(p, i);
101 static OF_INLINE
unsigned int 102 of_atomic_int_xor(
volatile unsigned int *_Nonnull p,
unsigned int i)
104 return __sync_xor_and_fetch(p, i);
107 static OF_INLINE uint32_t
108 of_atomic_int32_xor(
volatile uint32_t *_Nonnull p, uint32_t i)
110 return __sync_xor_and_fetch(p, i);
113 static OF_INLINE
bool 114 of_atomic_int_cmpswap(
volatile int *_Nonnull p,
int o,
int n)
116 return __sync_bool_compare_and_swap(p, o, n);
119 static OF_INLINE
bool 120 of_atomic_int32_cmpswap(
volatile int32_t *_Nonnull p, int32_t o, int32_t n)
122 return __sync_bool_compare_and_swap(p, o, n);
125 static OF_INLINE
bool 126 of_atomic_ptr_cmpswap(
void *
volatile _Nullable *_Nonnull p,
127 void *_Nullable o,
void *_Nullable n)
129 return __sync_bool_compare_and_swap(p, o, n);
132 static OF_INLINE
void 133 of_memory_barrier(
void)
135 __sync_synchronize();
138 static OF_INLINE
void 139 of_memory_barrier_acquire(
void)
141 __sync_synchronize();
144 static OF_INLINE
void 145 of_memory_barrier_release(
void)
147 __sync_synchronize();