From: miod Date: Tue, 15 Jul 2014 16:28:11 +0000 (+0000) Subject: Implement rw_cas() with atomic_cas_ulong() now, instead of a dedicated X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=451daab513e16b7b562b827e09b3832e97f6af82;p=openbsd Implement rw_cas() with atomic_cas_ulong() now, instead of a dedicated routine. --- diff --git a/sys/arch/m88k/include/lock.h b/sys/arch/m88k/include/lock.h index 0ed61ca2860..2ad1c95d8bc 100644 --- a/sys/arch/m88k/include/lock.h +++ b/sys/arch/m88k/include/lock.h @@ -1,6 +1,6 @@ #ifndef _M88K_LOCK_H_ #define _M88K_LOCK_H_ -/* $OpenBSD: lock.h,v 1.9 2014/03/29 18:09:29 guenther Exp $ */ +/* $OpenBSD: lock.h,v 1.10 2014/07/15 16:28:11 miod Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat. @@ -75,8 +75,7 @@ __cpu_simple_unlock(__cpu_simple_lock_t *l) } #if defined(_KERNEL) && defined(MULTIPROCESSOR) -int rw_cas_m88k(volatile unsigned long *, unsigned long, unsigned long); -#define rw_cas rw_cas_m88k +#define rw_cas(p, o, n) (atomic_cas_ulong(p, o, n) != o) #endif #endif /* _M88K_LOCK_H_ */ diff --git a/sys/arch/m88k/m88k/m88k_machdep.c b/sys/arch/m88k/m88k/m88k_machdep.c index 81c9a715031..2114cdd6bfe 100644 --- a/sys/arch/m88k/m88k/m88k_machdep.c +++ b/sys/arch/m88k/m88k/m88k_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m88k_machdep.c,v 1.62 2014/06/09 16:22:47 miod Exp $ */ +/* $OpenBSD: m88k_machdep.c,v 1.63 2014/07/15 16:28:11 miod Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -576,32 +576,4 @@ cpu_emergency_disable() /* NOTREACHED */ } -/* - * Emulate a compare-and-swap instruction for rwlocks, by using a - * __cpu_simple_lock as a critical section. - * - * Since we are only competing against other processors for rwlocks, - * it is not necessary in this case to disable interrupts to prevent - * reentrancy on the same processor. - */ - -__cpu_simple_lock_t rw_cas_spinlock = __SIMPLELOCK_UNLOCKED; - -int -rw_cas_m88k(volatile unsigned long *p, unsigned long o, unsigned long n) -{ - int rc = 0; - - __cpu_simple_lock(&rw_cas_spinlock); - - if (*p != o) - rc = 1; - else - *p = n; - - __cpu_simple_unlock(&rw_cas_spinlock); - - return (rc); -} - #endif /* MULTIPROCESSOR */