Add atomic_swap_ptr()
authorBarret Rhoden <brho@cs.berkeley.edu>
Tue, 6 Mar 2018 19:12:13 +0000 (11:12 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 30 Apr 2018 18:31:44 +0000 (14:31 -0400)
Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/arch/riscv/atomic.h
kern/arch/x86/atomic.h

index e57815d..e8833ef 100644 (file)
@@ -100,6 +100,11 @@ static inline long atomic_swap(atomic_t *addr, long val)
        return (long)__sync_lock_test_and_set(addr, val); // yes, really
 }
 
+static inline void *atomic_swap_ptr(void **addr, void *val)
+{
+       return (void*)__sync_lock_test_and_set(addr, val);
+}
+
 static inline uint32_t atomic_swap_u32(uint32_t *addr, uint32_t val)
 {
        return __sync_lock_test_and_set(addr, val); // yes, really
index ca8ebfa..dd1a29c 100644 (file)
@@ -68,6 +68,11 @@ static inline long atomic_swap(atomic_t *addr, long val)
        return (long)__sync_lock_test_and_set(addr, val);
 }
 
+static inline void *atomic_swap_ptr(void **addr, void *val)
+{
+       return (void*)__sync_lock_test_and_set(addr, val);
+}
+
 static inline bool atomic_cas(atomic_t *addr, long exp_val, long new_val)
 {
        return __sync_bool_compare_and_swap(addr, exp_val, new_val);