diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2014-07-18 12:44:54 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2014-07-18 12:44:54 +0000 |
commit | 740168aaef20521b202c47eeeafcb8ad66c570c4 (patch) | |
tree | 305d703547e6c90c3fdc1c2755868480376643ce /sys/arch/sparc64 | |
parent | 12f023d00141b0119577ee9411abf123101b5f78 (diff) |
atomic_swap_ptr is special.
for jmatthew@
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r-- | sys/arch/sparc64/include/atomic.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sys/arch/sparc64/include/atomic.h b/sys/arch/sparc64/include/atomic.h index bcf412ee6b3..2380dd35393 100644 --- a/sys/arch/sparc64/include/atomic.h +++ b/sys/arch/sparc64/include/atomic.h @@ -1,4 +1,4 @@ -/* $OpenBSD: atomic.h,v 1.12 2014/07/18 10:40:14 dlg Exp $ */ +/* $OpenBSD: atomic.h,v 1.13 2014/07/18 12:44:53 dlg Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> * @@ -71,9 +71,22 @@ _f(volatile _t *p, _t v) \ def_atomic_swap(_atomic_swap_uint, unsigned int, atomic_cas_uint) def_atomic_swap(_atomic_swap_ulong, unsigned long, atomic_cas_ulong) -def_atomic_swap(_atomic_swap_ptr, void *, atomic_cas_ptr) #undef def_atomic_swap +static inline void * +_atomic_swap_ptr(volatile void *p, void *v) +{ + void *e, *r; + + r = *(void **)p; + do { + e = r; + r = atomic_cas_ptr(p, e, v); + } while (r != e); + + return (r); +} + #define atomic_swap_uint(_p, _v) _atomic_swap_uint(_p, _v) #define atomic_swap_ulong(_p, _v) _atomic_swap_ulong(_p, _v) #define atomic_swap_ptr(_p, _v) _atomic_swap_ptr(_p, _v) |