diff options
author | pjd <pjd@FreeBSD.org> | 2011-11-16 21:51:17 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2011-11-16 21:51:17 +0000 |
commit | a3e664d830a8cf18b39de7e24de3b6945e09d802 (patch) | |
tree | 0f843eda4349e58b83edfddade168cfeeb527616 /sys/kern/kern_rwlock.c | |
parent | 8f7796960e5324d9006d05ab644c421a3428a863 (diff) | |
download | FreeBSD-src-a3e664d830a8cf18b39de7e24de3b6945e09d802.zip FreeBSD-src-a3e664d830a8cf18b39de7e24de3b6945e09d802.tar.gz |
Constify arguments for locking KPIs where possible.
This enables locking consumers to pass their own structures around as const and
be able to assert locks embedded into those structures.
Reviewed by: ed, kib, jhb
Diffstat (limited to 'sys/kern/kern_rwlock.c')
-rw-r--r-- | sys/kern/kern_rwlock.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c index 1037f34..a4d3e96 100644 --- a/sys/kern/kern_rwlock.c +++ b/sys/kern/kern_rwlock.c @@ -67,12 +67,12 @@ SYSCTL_INT(_debug_rwlock, OID_AUTO, loops, CTLFLAG_RW, &rowner_loops, 0, ""); #ifdef DDB #include <ddb/ddb.h> -static void db_show_rwlock(struct lock_object *lock); +static void db_show_rwlock(const struct lock_object *lock); #endif -static void assert_rw(struct lock_object *lock, int what); +static void assert_rw(const struct lock_object *lock, int what); static void lock_rw(struct lock_object *lock, int how); #ifdef KDTRACE_HOOKS -static int owner_rw(struct lock_object *lock, struct thread **owner); +static int owner_rw(const struct lock_object *lock, struct thread **owner); #endif static int unlock_rw(struct lock_object *lock); @@ -121,10 +121,10 @@ struct lock_class lock_class_rw = { #endif void -assert_rw(struct lock_object *lock, int what) +assert_rw(const struct lock_object *lock, int what) { - rw_assert((struct rwlock *)lock, what); + rw_assert((const struct rwlock *)lock, what); } void @@ -157,9 +157,9 @@ unlock_rw(struct lock_object *lock) #ifdef KDTRACE_HOOKS int -owner_rw(struct lock_object *lock, struct thread **owner) +owner_rw(const struct lock_object *lock, struct thread **owner) { - struct rwlock *rw = (struct rwlock *)lock; + const struct rwlock *rw = (const struct rwlock *)lock; uintptr_t x = rw->rw_lock; *owner = rw_wowner(rw); @@ -223,7 +223,7 @@ rw_sysinit_flags(void *arg) } int -rw_wowned(struct rwlock *rw) +rw_wowned(const struct rwlock *rw) { return (rw_wowner(rw) == curthread); @@ -1011,7 +1011,7 @@ out: * thread owns an rlock. */ void -_rw_assert(struct rwlock *rw, int what, const char *file, int line) +_rw_assert(const struct rwlock *rw, int what, const char *file, int line) { if (panicstr != NULL) @@ -1084,12 +1084,12 @@ _rw_assert(struct rwlock *rw, int what, const char *file, int line) #ifdef DDB void -db_show_rwlock(struct lock_object *lock) +db_show_rwlock(const struct lock_object *lock) { - struct rwlock *rw; + const struct rwlock *rw; struct thread *td; - rw = (struct rwlock *)lock; + rw = (const struct rwlock *)lock; db_printf(" state: "); if (rw->rw_lock == RW_UNLOCKED) |