diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2015-02-11 03:56:01 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2015-02-11 03:56:01 +0000 |
commit | 580dd051eacfdde49ae9bc3214afc989f3c519b5 (patch) | |
tree | 90087e0738009f46e971bfe28d48a53ca3670bdd | |
parent | ec9cc08b88cd09654db5561b93a3ffbe8213d114 (diff) |
the only user of __cpu_cas is lock_machdep, so move it there.
machine/lock.h only provides SPINLOCK_SPIN_HOOK which is included
directly by the three files that use it.
-rw-r--r-- | sys/arch/alpha/alpha/lock_machdep.c | 43 | ||||
-rw-r--r-- | sys/arch/alpha/include/lock.h | 25 |
2 files changed, 33 insertions, 35 deletions
diff --git a/sys/arch/alpha/alpha/lock_machdep.c b/sys/arch/alpha/alpha/lock_machdep.c index 91be2bb6970..36cd7dab6ee 100644 --- a/sys/arch/alpha/alpha/lock_machdep.c +++ b/sys/arch/alpha/alpha/lock_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lock_machdep.c,v 1.2 2015/02/11 01:10:48 dlg Exp $ */ +/* $OpenBSD: lock_machdep.c,v 1.3 2015/02/11 03:56:00 dlg Exp $ */ /* * Copyright (c) 2007 Artur Grabowski <art@openbsd.org> @@ -18,31 +18,52 @@ #include <sys/param.h> -#include <sys/lock.h> #include <sys/systm.h> #include <machine/atomic.h> #include <machine/cpu.h> #include <machine/lock.h> -#include <ddb/db_output.h> - -void -__mp_lock_init(struct __mp_lock *lock) -{ - lock->mpl_cpu = NULL; - lock->mpl_count = 0; -} - #if defined(MP_LOCKDEBUG) #ifndef DDB #error "MP_LOCKDEBUG requires DDB" #endif +#include <ddb/db_output.h> /* CPU-dependent timing, needs this to be settable from ddb. */ extern int __mp_lock_spinout; #endif +static inline int +__cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) +{ + unsigned long t0, v0; + + __asm volatile( + "1: ldq_l %1, 0(%2) \n" /* v0 = *addr */ + " cmpeq %1, %3, %0 \n" /* t0 = v0 == old */ + " beq %0, 2f \n" + " mov %4, %0 \n" /* t0 = new */ + " stq_c %0, 0(%2) \n" /* *addr = new */ + " beq %0, 3f \n" + " mb \n" + "2: br 4f \n" + "3: br 1b \n" /* update failed */ + "4: \n" + : "=&r" (t0), "=&r" (v0) + : "r" (addr), "r" (old), "r" (new) + : "memory"); + + return (v0 != old); +} + +void +__mp_lock_init(struct __mp_lock *lock) +{ + lock->mpl_cpu = NULL; + lock->mpl_count = 0; +} + static inline void __mp_lock_spin(struct __mp_lock *mpl) { diff --git a/sys/arch/alpha/include/lock.h b/sys/arch/alpha/include/lock.h index e40761990d2..3ef8a5cb550 100644 --- a/sys/arch/alpha/include/lock.h +++ b/sys/arch/alpha/include/lock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lock.h,v 1.8 2015/02/11 00:14:11 dlg Exp $ */ +/* $OpenBSD: lock.h,v 1.9 2015/02/11 03:56:00 dlg Exp $ */ /* $NetBSD: lock.h,v 1.16 2001/12/17 23:34:57 thorpej Exp $ */ /*- @@ -61,27 +61,4 @@ do { \ } while (0) #endif /* MULTIPROCESSOR */ -static inline int -__cpu_cas(volatile unsigned long *addr, unsigned long old, unsigned long new) -{ - unsigned long t0, v0; - - __asm volatile( - "1: ldq_l %1, 0(%2) \n" /* v0 = *addr */ - " cmpeq %1, %3, %0 \n" /* t0 = v0 == old */ - " beq %0, 2f \n" - " mov %4, %0 \n" /* t0 = new */ - " stq_c %0, 0(%2) \n" /* *addr = new */ - " beq %0, 3f \n" - " mb \n" - "2: br 4f \n" - "3: br 1b \n" /* update failed */ - "4: \n" - : "=&r" (t0), "=&r" (v0) - : "r" (addr), "r" (old), "r" (new) - : "memory"); - - return (v0 != old); -} - #endif /* _MACHINE_LOCK_H_ */ |