diff options
Diffstat (limited to 'kern/lock.h')
-rw-r--r-- | kern/lock.h | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/kern/lock.h b/kern/lock.h index 85f03a4..ea7a977 100644 --- a/kern/lock.h +++ b/kern/lock.h @@ -174,6 +174,9 @@ struct lock { /* boolean_t */ can_sleep:1, /* Can attempts to lock go to sleep? */ recursion_depth:12, /* Depth of recursion */ :0; +#if MACH_LDEBUG + struct thread *writer; +#endif /* MACH_LDEBUG */ decl_simple_lock_data(,interlock) /* Hardware interlock field. Last in the structure so that @@ -199,11 +202,25 @@ extern boolean_t lock_try_read_to_write(lock_t); #define lock_read_done(l) lock_done(l) #define lock_write_done(l) lock_done(l) +#if ! MACH_LDEBUG #define lock_taken(l) ((l)->want_write || (l)->read_count) - +#else /* MACH_LDEBUG */ +#define lock_taken(l) ((l)->writer == current_thread() \ + || (l)->read_count) +#endif /* MACH_LDEBUG */ extern void lock_set_recursive(lock_t); extern void lock_clear_recursive(lock_t); +/* Lock debugging support. */ +#if ! MACH_LDEBUG +#define have_read_lock(l) 1 +#define have_write_lock(l) 1 +#else /* MACH_LDEBUG */ +#define have_read_lock(l) ((l)->read_count > 0) +#define have_write_lock(l) ((l)->writer == current_thread()) +#endif /* MACH_LDEBUG */ +#define have_lock(l) (have_read_lock(l) || have_write_lock(l)) + void db_show_all_slocks(void); #endif /* _KERN_LOCK_H_ */ |