18 of_atomic_int_add(
volatile int *_Nonnull p,
int i)
20 __asm__ __volatile__ (
24 "stwcx. %0, 0, %2\n\t" 34 static OF_INLINE int32_t
35 of_atomic_int32_add(
volatile int32_t *_Nonnull p, int32_t i)
37 __asm__ __volatile__ (
41 "stwcx. %0, 0, %2\n\t" 51 static OF_INLINE
void *_Nullable
52 of_atomic_ptr_add(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
54 __asm__ __volatile__ (
58 "stwcx. %0, 0, %2\n\t" 69 of_atomic_int_sub(
volatile int *_Nonnull p,
int i)
71 __asm__ __volatile__ (
75 "stwcx. %0, 0, %2\n\t" 85 static OF_INLINE int32_t
86 of_atomic_int32_sub(
volatile int32_t *_Nonnull p, int32_t i)
88 __asm__ __volatile__ (
92 "stwcx. %0, 0, %2\n\t" 102 static OF_INLINE
void *_Nullable
103 of_atomic_ptr_sub(
void *
volatile _Nullable *_Nonnull p, intptr_t i)
105 __asm__ __volatile__ (
107 "lwarx %0, 0, %2\n\t" 109 "stwcx. %0, 0, %2\n\t" 120 of_atomic_int_inc(
volatile int *_Nonnull p)
124 __asm__ __volatile__ (
126 "lwarx %0, 0, %1\n\t" 128 "stwcx. %0, 0, %1\n\t" 138 static OF_INLINE int32_t
139 of_atomic_int32_inc(
volatile int32_t *_Nonnull p)
143 __asm__ __volatile__ (
145 "lwarx %0, 0, %1\n\t" 147 "stwcx. %0, 0, %1\n\t" 158 of_atomic_int_dec(
volatile int *_Nonnull p)
162 __asm__ __volatile__ (
164 "lwarx %0, 0, %1\n\t" 166 "stwcx. %0, 0, %1\n\t" 176 static OF_INLINE int32_t
177 of_atomic_int32_dec(
volatile int32_t *_Nonnull p)
181 __asm__ __volatile__ (
183 "lwarx %0, 0, %1\n\t" 185 "stwcx. %0, 0, %1\n\t" 195 static OF_INLINE
unsigned int 196 of_atomic_int_or(
volatile unsigned int *_Nonnull p,
unsigned int i)
198 __asm__ __volatile__ (
200 "lwarx %0, 0, %2\n\t" 202 "stwcx. %0, 0, %2\n\t" 212 static OF_INLINE uint32_t
213 of_atomic_int32_or(
volatile uint32_t *_Nonnull p, uint32_t i)
215 __asm__ __volatile__ (
217 "lwarx %0, 0, %2\n\t" 219 "stwcx. %0, 0, %2\n\t" 229 static OF_INLINE
unsigned int 230 of_atomic_int_and(
volatile unsigned int *_Nonnull p,
unsigned int i)
232 __asm__ __volatile__ (
234 "lwarx %0, 0, %2\n\t" 236 "stwcx. %0, 0, %2\n\t" 246 static OF_INLINE uint32_t
247 of_atomic_int32_and(
volatile uint32_t *_Nonnull p, uint32_t i)
249 __asm__ __volatile__ (
251 "lwarx %0, 0, %2\n\t" 253 "stwcx. %0, 0, %2\n\t" 263 static OF_INLINE
unsigned int 264 of_atomic_int_xor(
volatile unsigned int *_Nonnull p,
unsigned int i)
266 __asm__ __volatile__ (
268 "lwarx %0, 0, %2\n\t" 270 "stwcx. %0, 0, %2\n\t" 280 static OF_INLINE uint32_t
281 of_atomic_int32_xor(
volatile uint32_t *_Nonnull p, uint32_t i)
283 __asm__ __volatile__ (
285 "lwarx %0, 0, %2\n\t" 287 "stwcx. %0, 0, %2\n\t" 297 static OF_INLINE
bool 298 of_atomic_int_cmpswap(
volatile int *_Nonnull p,
int o,
int n)
302 __asm__ __volatile__ (
304 "lwarx %0, 0, %3\n\t" 307 "stwcx. %2, 0, %3\n\t" 312 "stwcx. %0, 0, %3\n\t" 316 :
"r"(o),
"r"(n),
"r"(p)
323 static OF_INLINE
bool 324 of_atomic_int32_cmpswap(
volatile int32_t *_Nonnull p, int32_t o, int32_t n)
328 __asm__ __volatile__ (
330 "lwarx %0, 0, %3\n\t" 333 "stwcx. %2, 0, %3\n\t" 338 "stwcx. %0, 0, %3\n\t" 342 :
"r"(o),
"r"(n),
"r"(p)
349 static OF_INLINE
bool 350 of_atomic_ptr_cmpswap(
void *
volatile _Nullable *_Nonnull p,
351 void *_Nullable o,
void *_Nullable n)
355 __asm__ __volatile__ (
357 "lwarx %0, 0, %3\n\t" 360 "stwcx. %2, 0, %3\n\t" 365 "stwcx. %0, 0, %3\n\t" 369 :
"r"(o),
"r"(n),
"r"(p)
376 static OF_INLINE
void 377 of_memory_barrier(
void)
379 __asm__ __volatile__ (
380 ".long 0x7C2004AC /* lwsync */" :::
"memory" 384 static OF_INLINE
void 385 of_memory_barrier_acquire(
void)
387 __asm__ __volatile__ (
388 ".long 0x7C2004AC /* lwsync */" :::
"memory" 392 static OF_INLINE
void 393 of_memory_barrier_release(
void)
395 __asm__ __volatile__ (
396 ".long 0x7C2004AC /* lwsync */" :::
"memory"