- Change lock_cas from "compare and set" to "compare and swap".
- Add aliases for atomic_cas_ulong(), etc. Ok skrll@
This commit is contained in:
parent
901f9ae9f6
commit
ad40d74014
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: lock_stubs.S,v 1.9 2007/10/17 19:54:31 garbled Exp $ */
|
||||
/* $NetBSD: lock_stubs.S,v 1.10 2007/11/29 16:14:28 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -49,9 +49,9 @@
|
|||
#include "assym.h"
|
||||
|
||||
/*
|
||||
* int _lock_cas(uintptr_t *val, uintptr_t old, uintptr_t new);
|
||||
* uintptr_t _lock_cas(volatile uintptr_t *val, uintptr_t old, uintptr_t new);
|
||||
*
|
||||
* Perform an atomic compare-and-set operation.
|
||||
* Perform an atomic compare-and-swap operation.
|
||||
*
|
||||
* On single CPU systems, this can use a restartable sequence:
|
||||
* there we don't need the overhead of interlocking.
|
||||
|
@ -74,15 +74,24 @@ LEAF_ENTRY(_lock_cas)
|
|||
_lock_cas_ras_start:
|
||||
ldw 0(%arg0),%t1
|
||||
comb,<> %arg1, %t1, 1f
|
||||
ldi 0,%ret0
|
||||
copy %t1,%ret0
|
||||
_lock_cas_ras_end:
|
||||
stw %arg2,0(%arg0)
|
||||
ldi 1,%ret0
|
||||
copy %arg1,%ret0
|
||||
1:
|
||||
bv,n %r0(%rp)
|
||||
|
||||
EXIT(_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)
|
||||
|
||||
#ifndef LOCKDEBUG
|
||||
/*
|
||||
* void mutex_exit(kmutex_t *mtx);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rwlock.h,v 1.3 2007/11/21 10:19:07 yamt Exp $ */
|
||||
/* $NetBSD: rwlock.h,v 1.4 2007/11/29 16:14:28 ad Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
|
||||
|
@ -53,9 +53,10 @@ struct krwlock {
|
|||
#define RW_RECEIVE(rw) /* nothing */
|
||||
#define RW_GIVE(rw) /* nothing */
|
||||
|
||||
#define RW_CAS(p, o, n) _lock_cas((p), (o), (n))
|
||||
uintptr_t _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
|
||||
|
||||
int _lock_cas(volatile uintptr_t *, uintptr_t, uintptr_t);
|
||||
#define RW_CAS(p, o, n) \
|
||||
(_lock_cas((volatile uintptr_t *)(p), (o), (n)) == (o))
|
||||
|
||||
#endif /* __RWLOCK_PRIVATE */
|
||||
|
||||
|
|
Loading…
Reference in New Issue