17 of_atomic_int_add(
volatile int *_Nonnull p,
int i)
19 return __sync_add_and_fetch(p, i);
22 static OF_INLINE int32_t
23 of_atomic_int32_add(
volatile int32_t *_Nonnull p, int32_t i)
25 return __sync_add_and_fetch(p, i);
28 static OF_INLINE
void *_Nullable
29 of_atomic_ptr_add(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
31 return __sync_add_and_fetch(p, (
void *)i);
35 of_atomic_int_sub(
volatile int *_Nonnull p,
int i)
37 return __sync_sub_and_fetch(p, i);
40 static OF_INLINE int32_t
41 of_atomic_int32_sub(
volatile int32_t *_Nonnull p, int32_t i)
43 return __sync_sub_and_fetch(p, i);
46 static OF_INLINE
void *_Nullable
47 of_atomic_ptr_sub(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
49 return __sync_sub_and_fetch(p, (
void *)i);
53 of_atomic_int_inc(
volatile int *_Nonnull p)
55 return __sync_add_and_fetch(p, 1);
58 static OF_INLINE int32_t
59 of_atomic_int32_inc(
volatile int32_t *_Nonnull p)
61 return __sync_add_and_fetch(p, 1);
65 of_atomic_int_dec(
volatile int *_Nonnull p)
67 return __sync_sub_and_fetch(p, 1);
70 static OF_INLINE int32_t
71 of_atomic_int32_dec(
volatile int32_t *_Nonnull p)
73 return __sync_sub_and_fetch(p, 1);
76 static OF_INLINE
unsigned int
77 of_atomic_int_or(
volatile unsigned int *_Nonnull p,
unsigned int i)
79 return __sync_or_and_fetch(p, i);
82 static OF_INLINE uint32_t
83 of_atomic_int32_or(
volatile uint32_t *_Nonnull p, uint32_t i)
85 return __sync_or_and_fetch(p, i);
88 static OF_INLINE
unsigned int
89 of_atomic_int_and(
volatile unsigned int *_Nonnull p,
unsigned int i)
91 return __sync_and_and_fetch(p, i);
94 static OF_INLINE uint32_t
95 of_atomic_int32_and(
volatile uint32_t *_Nonnull p, uint32_t i)
97 return __sync_and_and_fetch(p, i);
100 static OF_INLINE
unsigned int
101 of_atomic_int_xor(
volatile unsigned int *_Nonnull p,
unsigned int i)
103 return __sync_xor_and_fetch(p, i);
106 static OF_INLINE uint32_t
107 of_atomic_int32_xor(
volatile uint32_t *_Nonnull p, uint32_t i)
109 return __sync_xor_and_fetch(p, i);
112 static OF_INLINE
bool
113 of_atomic_int_cmpswap(
volatile int *_Nonnull p,
int o,
int n)
115 return __sync_bool_compare_and_swap(p, o, n);
118 static OF_INLINE
bool
119 of_atomic_int32_cmpswap(
volatile int32_t *_Nonnull p, int32_t o, int32_t n)
121 return __sync_bool_compare_and_swap(p, o, n);
124 static OF_INLINE
bool
125 of_atomic_ptr_cmpswap(
void *
volatile _Nullable *_Nonnull p,
126 void *_Nullable o,
void *_Nullable n)
128 return __sync_bool_compare_and_swap(p, o, n);
131 static OF_INLINE
void
132 of_memory_barrier(
void)
134 __sync_synchronize();
137 static OF_INLINE
void
138 of_memory_barrier_acquire(
void)
140 __sync_synchronize();
143 static OF_INLINE
void
144 of_memory_barrier_release(
void)
146 __sync_synchronize();