summaryrefslogtreecommitdiff
path: root/sys/arch/sparc64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/sparc64')
-rw-r--r--sys/arch/sparc64/include/atomic.h17
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)