diff --git a/sys/arch/sh3/include/mutex.h b/sys/arch/sh3/include/mutex.h index eddb6001fd2e..a683f051615b 100644 --- a/sys/arch/sh3/include/mutex.h +++ b/sys/arch/sh3/include/mutex.h @@ -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 */ diff --git a/sys/arch/sh3/include/rwlock.h b/sys/arch/sh3/include/rwlock.h index b9f73c86ba6d..e35298ade536 100644 --- a/sys/arch/sh3/include/rwlock.h +++ b/sys/arch/sh3/include/rwlock.h @@ -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 */ diff --git a/sys/arch/sh3/sh3/lock_stubs.S b/sys/arch/sh3/sh3/lock_stubs.S index e6c8d91307e5..00f3a430eecf 100644 --- a/sys/arch/sh3/sh3/lock_stubs.S +++ b/sys/arch/sh3/sh3/lock_stubs.S @@ -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)