6#ifndef ZEPHYR_INCLUDE_ATOMIC_XTENSA_H_
7#define ZEPHYR_INCLUDE_ATOMIC_XTENSA_H_
28 __asm__
volatile(
"l32ai %0, %1, 0"
29 :
"=r"(ret) :
"r"(target) :
"memory");
54 __asm__
volatile(
"wsr %1, SCOMPARE1; s32c1i %0, %2, 0"
55 :
"+r"(newval),
"+r"(oldval) :
"r"(addr) :
"memory");
64 return oldval ==
xtensa_cas(target, oldval, newval);
81#define Z__GEN_ATOMXCHG(expr) ({ \
82 atomic_val_t res, cur; \
85 res = xtensa_cas(target, cur, (expr)); \
86 } while (res != cur); \
93 return Z__GEN_ATOMXCHG(value);
100 return Z__GEN_ATOMXCHG(cur + value);
107 return Z__GEN_ATOMXCHG(cur - value);
114 return Z__GEN_ATOMXCHG(cur + 1);
121 return Z__GEN_ATOMXCHG(cur - 1);
128 return Z__GEN_ATOMXCHG(cur | value);
135 return Z__GEN_ATOMXCHG(cur ^ value);
142 return Z__GEN_ATOMXCHG(cur & value);
149 return Z__GEN_ATOMXCHG(~(cur & value));
long atomic_t
Definition: atomic_types.h:15
atomic_t atomic_val_t
Definition: atomic_types.h:16
void * atomic_ptr_t
Definition: atomic_types.h:17
static ALWAYS_INLINE void * atomic_ptr_set(atomic_ptr_t *target, void *value)
Implementation of atomic_ptr_set.
Definition: atomic_xtensa.h:159
static ALWAYS_INLINE atomic_val_t atomic_inc(atomic_t *target)
Implementation of atomic_inc.
Definition: atomic_xtensa.h:112
static ALWAYS_INLINE atomic_val_t atomic_and(atomic_t *target, atomic_val_t value)
Implementation of atomic_and.
Definition: atomic_xtensa.h:139
static ALWAYS_INLINE atomic_val_t xtensa_cas(atomic_t *addr, atomic_val_t oldval, atomic_val_t newval)
Xtensa specific atomic compare-and-set (CAS).
Definition: atomic_xtensa.h:51
static ALWAYS_INLINE atomic_val_t atomic_sub(atomic_t *target, atomic_val_t value)
Implementation of atomic_sub.
Definition: atomic_xtensa.h:105
static ALWAYS_INLINE atomic_val_t atomic_set(atomic_t *target, atomic_val_t value)
Implementation of atomic_set.
Definition: atomic_xtensa.h:91
static ALWAYS_INLINE void * atomic_ptr_get(const atomic_ptr_t *target)
Implementation of atomic_ptr_get.
Definition: atomic_xtensa.h:153
static ALWAYS_INLINE bool atomic_cas(atomic_t *target, atomic_val_t oldval, atomic_val_t newval)
Implementation of atomic_cas.
Definition: atomic_xtensa.h:62
static ALWAYS_INLINE atomic_val_t atomic_get(const atomic_t *target)
Implementation of atomic_get.
Definition: atomic_xtensa.h:18
static ALWAYS_INLINE atomic_val_t atomic_add(atomic_t *target, atomic_val_t value)
Implementation of atomic_add.
Definition: atomic_xtensa.h:98
static ALWAYS_INLINE atomic_val_t atomic_clear(atomic_t *target)
Implementation of atomic_clear.
Definition: atomic_xtensa.h:165
static ALWAYS_INLINE atomic_val_t atomic_xor(atomic_t *target, atomic_val_t value)
Implementation of atomic_xor.
Definition: atomic_xtensa.h:132
static ALWAYS_INLINE atomic_val_t atomic_nand(atomic_t *target, atomic_val_t value)
Implementation of atomic_nand.
Definition: atomic_xtensa.h:146
static ALWAYS_INLINE bool atomic_ptr_cas(atomic_ptr_t *target, void *oldval, void *newval)
Implementation of atomic_ptr_cas.
Definition: atomic_xtensa.h:69
static ALWAYS_INLINE atomic_val_t atomic_or(atomic_t *target, atomic_val_t value)
Implementation of atomic_or.
Definition: atomic_xtensa.h:125
static ALWAYS_INLINE atomic_val_t atomic_dec(atomic_t *target)
Implementation of atomic_dec.
Definition: atomic_xtensa.h:119
static ALWAYS_INLINE void * atomic_ptr_clear(atomic_ptr_t *target)
Implementation of atomic_ptr_clear.
Definition: atomic_xtensa.h:171
#define ALWAYS_INLINE
Definition: common.h:129