diff options
author | 2014-07-18 12:44:53 +0000 | |
---|---|---|
committer | 2014-07-18 12:44:53 +0000 | |
commit | 7be48f09aecba48d2fca1a7574333dc2f2ba4d02 (patch) | |
tree | 3aeb6c10c77f0cc9592aaccf429f23ae7b207615 | |
parent | Follow the recent addition of /usr/local/lib/pkgconfig and add (diff) | |
download | wireguard-openbsd-7be48f09aecba48d2fca1a7574333dc2f2ba4d02.tar.xz wireguard-openbsd-7be48f09aecba48d2fca1a7574333dc2f2ba4d02.zip |
atomic_swap_ptr is special.
for jmatthew@
-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) |