diff options
author | jhb <jhb@FreeBSD.org> | 2006-01-17 16:55:17 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2006-01-17 16:55:17 +0000 |
commit | c0cf4870f410060c24b4fada37aa68f397098325 (patch) | |
tree | 39ef317a70787cab889c6304585f543a64e07ebc /sys/sys/lock.h | |
parent | b12ec6b7ed4f791a27a5b65c12d5e1f21fa43ece (diff) | |
download | FreeBSD-src-c0cf4870f410060c24b4fada37aa68f397098325.zip FreeBSD-src-c0cf4870f410060c24b4fada37aa68f397098325.tar.gz |
Add a new file (kern/subr_lock.c) for holding code related to struct
lock_obj objects:
- Add new lock_init() and lock_destroy() functions to setup and teardown
lock_object objects including KTR logging and registering with WITNESS.
- Move all the handling of LO_INITIALIZED out of witness and the various
lock init functions into lock_init() and lock_destroy().
- Remove the constants for static indices into the lock_classes[] array
and change the code outside of subr_lock.c to use LOCK_CLASS to compare
against a known lock class.
- Move the 'show lock' ddb function and lock_classes[] array out of
kern_mutex.c over to subr_lock.c.
Diffstat (limited to 'sys/sys/lock.h')
-rw-r--r-- | sys/sys/lock.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/sys/lock.h b/sys/sys/lock.h index a6f9080..03b41e3 100644 --- a/sys/sys/lock.h +++ b/sys/sys/lock.h @@ -78,10 +78,7 @@ struct lock_class { #define LO_CLASSSHIFT 24 #define LO_CLASSINDEX(lock) ((((lock)->lo_flags) & LO_CLASSMASK) >> LO_CLASSSHIFT) #define LOCK_CLASS(lock) (lock_classes[LO_CLASSINDEX((lock))]) -#define LOCK_CLASS_SPIN_MUTEX 0 -#define LOCK_CLASS_SLEEP_MUTEX 1 -#define LOCK_CLASS_SX 2 -#define LOCK_CLASS_MAX LOCK_CLASS_SX +#define LOCK_CLASS_MAX (LO_CLASSMASK >> LO_CLASSSHIFT) #define LI_RECURSEMASK 0x0000ffff /* Recursion depth of lock instance. */ #define LI_EXCLUSIVE 0x00010000 /* Exclusive lock instance. */ @@ -199,6 +196,8 @@ struct lock_list_entry { #define LOCK_LOG_DESTROY(lo, flags) LOCK_LOG_INIT(lo, flags) +#define lock_initalized(lo) ((lo)->lo_flags & LO_INITIALIZED) + /* * Helpful macros for quickly coming up with assertions with informative * panic messages. @@ -215,6 +214,9 @@ extern struct lock_class lock_class_sx; extern struct lock_class *lock_classes[]; +void lock_init(struct lock_object *lock, struct lock_class *class, + const char *name, const char *type, int flags); +void lock_destroy(struct lock_object *lock); void spinlock_enter(void); void spinlock_exit(void); void witness_init(struct lock_object *); @@ -286,8 +288,8 @@ const char *witness_file(struct lock_object *); witness_line(lock) #else /* WITNESS */ -#define WITNESS_INIT(lock) ((lock)->lo_flags |= LO_INITIALIZED) -#define WITNESS_DESTROY(lock) ((lock)->lo_flags &= ~LO_INITIALIZED) +#define WITNESS_INIT(lock) +#define WITNESS_DESTROY(lock) #define WITNESS_DEFINEORDER(lock1, lock2) 0 #define WITNESS_CHECKORDER(lock, flags, file, line) #define WITNESS_LOCK(lock, flags, file, line) |