diff options
-rw-r--r-- | sys/arch/hppa/include/vmparam.h | 5 | ||||
-rw-r--r-- | sys/arch/i386/i386/db_mp.c | 4 | ||||
-rw-r--r-- | sys/arch/i386/i386/kvm86.c | 4 | ||||
-rw-r--r-- | sys/kern/kern_sched.c | 3 | ||||
-rw-r--r-- | sys/scsi/scsiconf.c | 5 | ||||
-rw-r--r-- | sys/sys/lock.h | 41 | ||||
-rw-r--r-- | sys/sys/param.h | 3 | ||||
-rw-r--r-- | sys/sys/simplelock.h | 103 |
8 files changed, 51 insertions, 117 deletions
diff --git a/sys/arch/hppa/include/vmparam.h b/sys/arch/hppa/include/vmparam.h index 504549cf12a..ed5d164c3d6 100644 --- a/sys/arch/hppa/include/vmparam.h +++ b/sys/arch/hppa/include/vmparam.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmparam.h,v 1.35 2008/09/06 19:49:05 kettenis Exp $ */ +/* $OpenBSD: vmparam.h,v 1.36 2010/04/23 21:34:40 deraadt Exp $ */ /* * Copyright (c) 1988-1994, The University of Utah and @@ -94,6 +94,9 @@ #define VM_FREELIST_ARCH 1 #if defined(_KERNEL) && !defined(_LOCORE) + +#include <sys/lock.h> + #define __HAVE_VM_PAGE_MD struct pv_entry; struct vm_page_md { diff --git a/sys/arch/i386/i386/db_mp.c b/sys/arch/i386/i386/db_mp.c index e11001a99a0..778bdfbcf7d 100644 --- a/sys/arch/i386/i386/db_mp.c +++ b/sys/arch/i386/i386/db_mp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_mp.c,v 1.5 2007/11/16 16:16:06 deraadt Exp $ */ +/* $OpenBSD: db_mp.c,v 1.6 2010/04/23 21:34:40 deraadt Exp $ */ /* * Copyright (c) 2003, 2004 Andreas Gunnarsson <andreas@openbsd.org> @@ -17,7 +17,7 @@ */ #include <sys/types.h> -#include <sys/simplelock.h> +#include <sys/lock.h> #include <machine/db_machdep.h> #include <sys/mutex.h> diff --git a/sys/arch/i386/i386/kvm86.c b/sys/arch/i386/i386/kvm86.c index 4a42bc44b99..a89e80e3cae 100644 --- a/sys/arch/i386/i386/kvm86.c +++ b/sys/arch/i386/i386/kvm86.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kvm86.c,v 1.3 2007/02/20 21:15:01 tom Exp $ */ +/* $OpenBSD: kvm86.c,v 1.4 2010/04/23 21:34:40 deraadt Exp $ */ /* $NetBSD: kvm86.c,v 1.10 2005/12/26 19:23:59 perry Exp $ */ /* * Copyright (c) 2002 @@ -33,7 +33,7 @@ #include <sys/user.h> #include <sys/malloc.h> #include <sys/mutex.h> -#include <sys/simplelock.h> +#include <sys/lock.h> #include <uvm/uvm_extern.h> #include <uvm/uvm.h> #include <machine/pcb.h> diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index 1b58a16a367..ffb6285e065 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sched.c,v 1.18 2010/04/06 20:33:28 kettenis Exp $ */ +/* $OpenBSD: kern_sched.c,v 1.19 2010/04/23 21:34:38 deraadt Exp $ */ /* * Copyright (c) 2007, 2008 Artur Grabowski <art@openbsd.org> * @@ -24,7 +24,6 @@ #include <sys/resourcevar.h> #include <sys/signalvar.h> #include <sys/mutex.h> -#include <machine/atomic.h> #include <uvm/uvm_extern.h> diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 04e563d2a9c..a9e294c3eb7 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.156 2010/04/17 00:51:13 dlg Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.157 2010/04/23 21:34:40 deraadt Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -56,12 +56,11 @@ #include <sys/malloc.h> #include <sys/device.h> #include <sys/buf.h> +#include <sys/lock.h> #include <scsi/scsi_all.h> #include <scsi/scsiconf.h> -#include <machine/atomic.h> - #if NBIO > 0 #include <sys/ioctl.h> #include <sys/scsiio.h> diff --git a/sys/sys/lock.h b/sys/sys/lock.h index 38c92a543b7..881e9b93daa 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -1,4 +1,4 @@ -/* $OpenBSD: lock.h,v 1.19 2009/03/25 21:20:26 oga Exp $ */ +/* $OpenBSD: lock.h,v 1.20 2010/04/23 21:34:40 deraadt Exp $ */ /* * Copyright (c) 1995 @@ -38,7 +38,44 @@ #ifndef _LOCK_H_ #define _LOCK_H_ -#include <sys/simplelock.h> +#ifdef _KERNEL +#include <machine/lock.h> +#endif /* _KERNEL */ + +/* + * A simple spin lock. + * + * This structure only sets one bit of data, but is sized based on the + * minimum word size that can be operated on by the hardware test-and-set + * instruction. It is only needed for multiprocessors, as uniprocessors + * will always run to completion or a sleep. It is an error to hold one + * of these locks while a process is sleeping. + */ +struct simplelock { +#ifdef MULTIPROCESSOR + __cpu_simple_lock_t lock_data; +#else + int lock_data; +#endif +}; + +#ifdef _KERNEL + +#define SLOCK_LOCKED 1 +#define SLOCK_UNLOCKED 0 + +#define simple_lock(lkp) +#define simple_lock_try(lkp) (1) /* always succeeds */ +#define simple_unlock(lkp) +#define simple_lock_assert(lkp) + +static __inline void simple_lock_init(struct simplelock *lkp) +{ + + lkp->lock_data = SLOCK_UNLOCKED; +} + +#endif /* _KERNEL */ typedef struct simplelock simple_lock_data_t; typedef struct simplelock *simple_lock_t; diff --git a/sys/sys/param.h b/sys/sys/param.h index 0e8c6f8d132..d9167885f11 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -1,4 +1,4 @@ -/* $OpenBSD: param.h,v 1.86 2010/02/17 21:46:43 miod Exp $ */ +/* $OpenBSD: param.h,v 1.87 2010/04/23 21:34:40 deraadt Exp $ */ /* $NetBSD: param.h,v 1.23 1996/03/17 01:02:29 thorpej Exp $ */ /*- @@ -54,7 +54,6 @@ #ifndef _LOCORE #include <sys/types.h> -#include <sys/simplelock.h> #endif /* diff --git a/sys/sys/simplelock.h b/sys/sys/simplelock.h deleted file mode 100644 index fbd39ef4d4e..00000000000 --- a/sys/sys/simplelock.h +++ /dev/null @@ -1,103 +0,0 @@ -/* $OpenBSD: simplelock.h,v 1.11 2004/06/13 21:49:28 niklas Exp $ */ - -#ifndef _SIMPLELOCK_H_ -#define _SIMPLELOCK_H_ - -#ifdef MULTIPROCESSOR -#include <machine/lock.h> -#endif - -/* - * A simple spin lock. - * - * This structure only sets one bit of data, but is sized based on the - * minimum word size that can be operated on by the hardware test-and-set - * instruction. It is only needed for multiprocessors, as uniprocessors - * will always run to completion or a sleep. It is an error to hold one - * of these locks while a process is sleeping. - */ -struct simplelock { -#ifdef MULTIPROCESSOR - __cpu_simple_lock_t lock_data; -#else - int lock_data; -#endif -}; - -#ifdef _KERNEL - -/* - * We can't debug locks when we use them in real life. - */ -#if defined(MULTIPROCESSOR) && defined(LOCKDEBUG) -#undef LOCKDEBUG -#endif - -#if !defined(MULTIPROCESSOR) || 1 - -#define SLOCK_LOCKED 1 -#define SLOCK_UNLOCKED 0 - -#ifndef LOCKDEBUG - -#define simple_lock(lkp) -#define simple_lock_try(lkp) (1) /* always succeeds */ -#define simple_unlock(lkp) -#define simple_lock_assert(lkp) - -static __inline void simple_lock_init(struct simplelock *lkp) -{ - - lkp->lock_data = SLOCK_UNLOCKED; -} - -#else - -void _simple_unlock(__volatile struct simplelock *, const char *, int); -int _simple_lock_try(__volatile struct simplelock *, const char *, int); -void _simple_lock(__volatile struct simplelock *, const char *, int); -void _simple_lock_assert(__volatile struct simplelock *, int, const char *, int); - -void simple_lock_init(struct simplelock *); -#define simple_unlock(lkp) _simple_unlock(lkp, __FILE__, __LINE__) -#define simple_lock_try(lkp) _simple_lock_try(lkp, __FILE__, __LINE__) -#define simple_lock(lkp) _simple_lock(lkp, __FILE__, __LINE__) -#define simple_lock_assert(lkp, state) _simple_lock_assert(lkp, state, __FILE__, __LINE__) - -#endif /* !defined(LOCKDEBUG) */ - -#else /* MULTIPROCESSOR */ - -/* - * The simple-lock routines are the primitives out of which the lock - * package is built. The machine-dependent code must implement an - * atomic test_and_set operation that indivisibly sets the simple lock - * to non-zero and returns its old value. It also assumes that the - * setting of the lock to zero below is indivisible. Simple locks may - * only be used for exclusive locks. - */ - -static __inline void simple_lock_init(struct simplelock *lkp) -{ - __cpu_simple_lock_init(&lkp->lock_data); -} - -static __inline void simple_lock(__volatile struct simplelock *lkp) -{ - __cpu_simple_lock(&lkp->lock_data); -} - -static __inline int simple_lock_try(__volatile struct simplelock *lkp) -{ - return (__cpu_simple_lock_try(&lkp->lock_data)); -} - -static __inline void simple_unlock(__volatile struct simplelock *lkp) -{ - __cpu_simple_unlock(&lkp->lock_data); -} -#endif /* MULTIPROCESSOR */ - -#endif /* _KERNEL */ - -#endif /* !_SIMPLELOCK_H_ */ |