summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorpjd <pjd@FreeBSD.org>2011-11-16 21:51:17 +0000
committerpjd <pjd@FreeBSD.org>2011-11-16 21:51:17 +0000
commita3e664d830a8cf18b39de7e24de3b6945e09d802 (patch)
tree0f843eda4349e58b83edfddade168cfeeb527616 /sys/kern/kern_mutex.c
parent8f7796960e5324d9006d05ab644c421a3428a863 (diff)
downloadFreeBSD-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_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 041b480..7666116 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -85,14 +85,15 @@ __FBSDID("$FreeBSD$");
#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK))
-static void assert_mtx(struct lock_object *lock, int what);
+static void assert_mtx(const struct lock_object *lock, int what);
#ifdef DDB
-static void db_show_mtx(struct lock_object *lock);
+static void db_show_mtx(const struct lock_object *lock);
#endif
static void lock_mtx(struct lock_object *lock, int how);
static void lock_spin(struct lock_object *lock, int how);
#ifdef KDTRACE_HOOKS
-static int owner_mtx(struct lock_object *lock, struct thread **owner);
+static int owner_mtx(const struct lock_object *lock,
+ struct thread **owner);
#endif
static int unlock_mtx(struct lock_object *lock);
static int unlock_spin(struct lock_object *lock);
@@ -134,10 +135,10 @@ struct mtx blocked_lock;
struct mtx Giant;
void
-assert_mtx(struct lock_object *lock, int what)
+assert_mtx(const struct lock_object *lock, int what)
{
- mtx_assert((struct mtx *)lock, what);
+ mtx_assert((const struct mtx *)lock, what);
}
void
@@ -174,9 +175,9 @@ unlock_spin(struct lock_object *lock)
#ifdef KDTRACE_HOOKS
int
-owner_mtx(struct lock_object *lock, struct thread **owner)
+owner_mtx(const struct lock_object *lock, struct thread **owner)
{
- struct mtx *m = (struct mtx *)lock;
+ const struct mtx *m = (const struct mtx *)lock;
*owner = mtx_owner(m);
return (mtx_unowned(m) == 0);
@@ -693,7 +694,7 @@ _mtx_unlock_sleep(struct mtx *m, int opts, const char *file, int line)
*/
#ifdef INVARIANT_SUPPORT
void
-_mtx_assert(struct mtx *m, int what, const char *file, int line)
+_mtx_assert(const struct mtx *m, int what, const char *file, int line)
{
if (panicstr != NULL || dumping)
@@ -871,12 +872,12 @@ mutex_init(void)
#ifdef DDB
void
-db_show_mtx(struct lock_object *lock)
+db_show_mtx(const struct lock_object *lock)
{
struct thread *td;
- struct mtx *m;
+ const struct mtx *m;
- m = (struct mtx *)lock;
+ m = (const struct mtx *)lock;
db_printf(" flags: {");
if (LOCK_CLASS(lock) == &lock_class_mtx_spin)
OpenPOWER on IntegriCloud