From: dlg Date: Fri, 18 Jul 2014 12:44:53 +0000 (+0000) Subject: atomic_swap_ptr is special. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7be48f09aecba48d2fca1a7574333dc2f2ba4d02;p=openbsd atomic_swap_ptr is special. for jmatthew@ --- 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 * @@ -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)