summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sx.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_sx.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_sx.c')
-rw-r--r--sys/kern/kern_sx.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index 1e4430a..9230beb 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -105,13 +105,13 @@ CTASSERT((SX_NOADAPTIVE & LO_CLASSFLAGS) == SX_NOADAPTIVE);
#define sx_recurse lock_object.lo_data
#define sx_recursed(sx) ((sx)->sx_recurse != 0)
-static void assert_sx(struct lock_object *lock, int what);
+static void assert_sx(const struct lock_object *lock, int what);
#ifdef DDB
-static void db_show_sx(struct lock_object *lock);
+static void db_show_sx(const struct lock_object *lock);
#endif
static void lock_sx(struct lock_object *lock, int how);
#ifdef KDTRACE_HOOKS
-static int owner_sx(struct lock_object *lock, struct thread **owner);
+static int owner_sx(const struct lock_object *lock, struct thread **owner);
#endif
static int unlock_sx(struct lock_object *lock);
@@ -142,10 +142,10 @@ SYSCTL_UINT(_debug_sx, OID_AUTO, loops, CTLFLAG_RW, &asx_loops, 0, "");
#endif
void
-assert_sx(struct lock_object *lock, int what)
+assert_sx(const struct lock_object *lock, int what)
{
- sx_assert((struct sx *)lock, what);
+ sx_assert((const struct sx *)lock, what);
}
void
@@ -178,9 +178,9 @@ unlock_sx(struct lock_object *lock)
#ifdef KDTRACE_HOOKS
int
-owner_sx(struct lock_object *lock, struct thread **owner)
+owner_sx(const struct lock_object *lock, struct thread **owner)
{
- struct sx *sx = (struct sx *)lock;
+ const struct sx *sx = (const struct sx *)lock;
uintptr_t x = sx->sx_lock;
*owner = (struct thread *)SX_OWNER(x);
@@ -1005,7 +1005,7 @@ _sx_sunlock_hard(struct sx *sx, const char *file, int line)
* thread owns an slock.
*/
void
-_sx_assert(struct sx *sx, int what, const char *file, int line)
+_sx_assert(const struct sx *sx, int what, const char *file, int line)
{
#ifndef WITNESS
int slocked = 0;
@@ -1088,12 +1088,12 @@ _sx_assert(struct sx *sx, int what, const char *file, int line)
#ifdef DDB
static void
-db_show_sx(struct lock_object *lock)
+db_show_sx(const struct lock_object *lock)
{
struct thread *td;
- struct sx *sx;
+ const struct sx *sx;
- sx = (struct sx *)lock;
+ sx = (const struct sx *)lock;
db_printf(" state: ");
if (sx->sx_lock == SX_LOCK_UNLOCKED)
OpenPOWER on IntegriCloud