Pending review by uwe@:
- Make _lock_cas() do "compare and swap", not "compare and set". - Add aliases for atomic_cas_ulong() and friends.
This commit is contained in:
parent
6f3a041727
commit
890e076b1a
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: mutex.h,v 1.7 2007/11/21 10:19:08 yamt Exp $ */
|
||||
/* $NetBSD: mutex.h,v 1.8 2007/11/29 17:33:09 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
|
||||
@ -80,9 +80,9 @@ struct kmutex {
|
||||
*/
|
||||
#define MUTEX_GIVE(mtx) /* nothing */
|
||||
|
||||
int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
|
||||
uintptr_t _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
|
||||
|
||||
#define MUTEX_CAS(p, o, n) _lock_cas((p), (o), (n))
|
||||
#define MUTEX_CAS(p, o, n) (_lock_cas((p), (o), (n)) == (o))
|
||||
|
||||
#endif /* __MUTEX_PRIVATE */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: rwlock.h,v 1.3 2007/11/21 10:19:08 yamt Exp $ */
|
||||
/* $NetBSD: rwlock.h,v 1.4 2007/11/29 17:33:09 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
|
||||
@ -50,9 +50,9 @@ struct krwlock {
|
||||
#define RW_RECEIVE(rw) /* nothing */
|
||||
#define RW_GIVE(rw) /* nothing */
|
||||
|
||||
#define RW_CAS(p, o, n) _lock_cas((p), (o), (n))
|
||||
#define RW_CAS(p, o, n) (_lock_cas((p), (o), (n)) == (o))
|
||||
|
||||
int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
|
||||
uintptr_t _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
|
||||
|
||||
#endif /* __RWLOCK_PRIVATE */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: lock_stubs.S,v 1.10 2007/10/17 19:57:08 garbled Exp $ */
|
||||
/* $NetBSD: lock_stubs.S,v 1.11 2007/11/29 17:33:09 ad Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Valeriy E. Ushakov
|
||||
@ -40,7 +40,7 @@
|
||||
|
||||
|
||||
/*
|
||||
* LINTSTUB: Func: int _lock_cas(volatile uintptr_t *ptr, uintptr_t old, uintptr_t new);
|
||||
* LINTSTUB: Func: uintptr_t _lock_cas(volatile uintptr_t *ptr, uintptr_t old, uintptr_t new);
|
||||
*
|
||||
* Atomic compare-and-swap for kernel use. SuperH machines are
|
||||
* uniprocessor, so we need to be atomic only w.r.t. interrupts.
|
||||
@ -54,15 +54,23 @@
|
||||
*/
|
||||
NENTRY(_lock_cas)
|
||||
ALTENTRY(_lock_cas_ras_start)
|
||||
mov.l @r4, r1
|
||||
cmp/eq r1, r5 ! T = (*ptr == old)
|
||||
mov.l @r4, r0
|
||||
cmp/eq r0, r5 ! T = (*ptr == old)
|
||||
bf 1f
|
||||
mov.l r6, @r4 ! *ptr = new
|
||||
ALTENTRY(_lock_cas_ras_end)
|
||||
1: rts
|
||||
movt r0 ! retval = T
|
||||
nop ! retval = *ptr at time of compare
|
||||
SET_ENTRY_SIZE(_lock_cas)
|
||||
|
||||
STRONG_ALIAS(_atomic_cas_ulong,_lock_cas)
|
||||
STRONG_ALIAS(atomic_cas_ulong,_lock_cas)
|
||||
STRONG_ALIAS(_atomic_cas_32,_lock_cas)
|
||||
STRONG_ALIAS(atomic_cas_32,_lock_cas)
|
||||
STRONG_ALIAS(_atomic_cas_uint,_lock_cas)
|
||||
STRONG_ALIAS(atomic_cas_uint,_lock_cas)
|
||||
STRONG_ALIAS(_atomic_cas_ptr,_lock_cas)
|
||||
STRONG_ALIAS(atomic_cas_ptr,_lock_cas)
|
||||
|
||||
#if !defined(LOCKDEBUG)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user