Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/asm/atomic-long.h
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | |||||
atomic_long_dec(atomic_long_t *v) | atomic_long_dec(atomic_long_t *v) | ||||
{ | { | ||||
return atomic_fetchadd_long(&v->counter, -1) - 1; | return atomic_fetchadd_long(&v->counter, -1) - 1; | ||||
} | } | ||||
static inline long | static inline long | ||||
atomic_long_xchg(atomic_long_t *v, long val) | atomic_long_xchg(atomic_long_t *v, long val) | ||||
{ | { | ||||
#if defined(__i386__) || defined(__amd64__) || defined(__aarch64__) | |||||
return atomic_swap_long(&v->counter, val); | return atomic_swap_long(&v->counter, val); | ||||
#else | |||||
long ret = atomic_long_read(v); | |||||
while (!atomic_fcmpset_long(&v->counter, &ret, val)) | |||||
; | |||||
return (ret); | |||||
#endif | |||||
} | } | ||||
static inline long | static inline long | ||||
atomic_long_cmpxchg(atomic_long_t *v, long old, long new) | atomic_long_cmpxchg(atomic_long_t *v, long old, long new) | ||||
{ | { | ||||
long ret = old; | long ret = old; | ||||
for (;;) { | for (;;) { | ||||
Show All 30 Lines |