Remove the mtx_t, witness_t, and witness_blessed_t types. Instead, just

use struct mtx, struct witness, and struct witness_blessed.

Requested by:	bde
This commit is contained in:
John Baldwin 2000-09-14 20:15:16 +00:00
parent 6f451c99b3
commit 606f8eb27a
18 changed files with 311 additions and 316 deletions

View File

@ -153,8 +153,8 @@ struct bootinfo_kernel bootinfo;
struct cpuhead cpuhead;
mtx_t sched_lock;
mtx_t Giant;
struct mtx sched_lock;
struct mtx Giant;
struct user *proc0paddr;

View File

@ -45,7 +45,7 @@
#include <machine/mutex.h>
/* All mutexes in system (used for debug/panic) */
mtx_t all_mtx = { MTX_UNOWNED, 0, 0, "All mutexes queue head",
struct mtx all_mtx = { MTX_UNOWNED, 0, 0, "All mutexes queue head",
TAILQ_HEAD_INITIALIZER(all_mtx.mtx_blocked),
{ NULL, NULL }, &all_mtx, &all_mtx
#ifdef SMP_DEBUG
@ -90,7 +90,7 @@ static void
propagate_priority(struct proc *p)
{
int pri = p->p_priority;
mtx_t *m = p->p_blocked;
struct mtx *m = p->p_blocked;
for (;;) {
struct proc *p1;
@ -170,7 +170,7 @@ propagate_priority(struct proc *p)
}
void
mtx_enter_hard(mtx_t *m, int type, int ipl)
mtx_enter_hard(struct mtx *m, int type, int ipl)
{
struct proc *p = CURPROC;
@ -327,10 +327,10 @@ mtx_enter_hard(mtx_t *m, int type, int ipl)
}
void
mtx_exit_hard(mtx_t *m, int type)
mtx_exit_hard(struct mtx *m, int type)
{
struct proc *p, *p1;
mtx_t *m1;
struct mtx *m1;
int pri;
switch (type) {
@ -428,12 +428,12 @@ mtx_exit_hard(mtx_t *m, int type)
#ifdef SMP_DEBUG
int mtx_validate __P((mtx_t *, int));
int mtx_validate __P((struct mtx *, int));
int
mtx_validate(mtx_t *m, int when)
mtx_validate(struct mtx *m, int when)
{
mtx_t *mp;
struct mtx *mp;
int i;
int retval = 0;
@ -486,7 +486,7 @@ mtx_validate(mtx_t *m, int when)
#endif
void
mtx_init(mtx_t *m, char *t, int flag)
mtx_init(struct mtx *m, char *t, int flag)
{
CTR2(KTR_LOCK, "mtx_init 0x%p (%s)", m, t);
@ -511,7 +511,7 @@ mtx_init(mtx_t *m, char *t, int flag)
}
void
mtx_destroy(mtx_t *m)
mtx_destroy(struct mtx *m)
{
CTR2(KTR_LOCK, "mtx_destroy 0x%p (%s)", m, m->mtx_description);

View File

@ -99,8 +99,6 @@ struct mtx {
#endif /* SMP_DEBUG */
};
typedef struct mtx mtx_t;
/*
* Filler for structs which need to remain the same size
* whether or not SMP_DEBUG is turned on.
@ -120,19 +118,19 @@ typedef struct mtxf {
#define CURTHD ((u_int64_t)CURPROC) /* Current thread ID */
/* Prototypes */
void mtx_init(mtx_t *m, char *description, int flag);
void mtx_enter_hard(mtx_t *, int type, int ipl);
void mtx_exit_hard(mtx_t *, int type);
void mtx_destroy(mtx_t *m);
void mtx_init(struct mtx *m, char *description, int flag);
void mtx_enter_hard(struct mtx *, int type, int ipl);
void mtx_exit_hard(struct mtx *, int type);
void mtx_destroy(struct mtx *m);
/*
* Wrap the following functions with cpp macros so that filenames and line
* numbers are embedded in the code correctly.
*/
#if (defined(KLD_MODULE) || defined(_KERN_MUTEX_C_))
void _mtx_enter(mtx_t *mtxp, int type, const char *file, int line);
int _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_enter(struct mtx *mtxp, int type, const char *file, int line);
int _mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line);
void _mtx_exit(struct mtx *mtxp, int type, const char *file, int line);
#endif
#define mtx_enter(mtxp, type) \
@ -145,8 +143,8 @@ void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
_mtx_exit((mtxp), (type), __FILE__, __LINE__)
/* Global locks */
extern mtx_t sched_lock;
extern mtx_t Giant;
extern struct mtx sched_lock;
extern struct mtx Giant;
/*
* Used to replace return with an exit Giant and return.
@ -267,16 +265,16 @@ do { \
witness_restore(m, __CONCAT(n, __wf), __CONCAT(n, __wl)); \
} while (0)
void witness_init(mtx_t *, int flag);
void witness_destroy(mtx_t *);
void witness_enter(mtx_t *, int, const char *, int);
void witness_try_enter(mtx_t *, int, const char *, int);
void witness_exit(mtx_t *, int, const char *, int);
void witness_init(struct mtx *, int flag);
void witness_destroy(struct mtx *);
void witness_enter(struct mtx *, int, const char *, int);
void witness_try_enter(struct mtx *, int, const char *, int);
void witness_exit(struct mtx *, int, const char *, int);
void witness_display(void(*)(const char *fmt, ...));
void witness_list(struct proc *);
int witness_sleep(int, mtx_t *, const char *, int);
void witness_save(mtx_t *, const char **, int *);
void witness_restore(mtx_t *, const char *, int);
int witness_sleep(int, struct mtx *, const char *, int);
void witness_save(struct mtx *, const char **, int *);
void witness_restore(struct mtx *, const char *, int);
#else /* WITNESS */
#define WITNESS_ENTER(m, t, f, l)
#define WITNESS_EXIT(m, t, f, l)
@ -424,9 +422,9 @@ extern char STR_mtx_try_enter_fmt[];
* Note: since type is usually a constant much of this code is optimized out
*/
_MTX_INLINE void
_mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *mpp = mtxp;
struct mtx *mpp = mtxp;
/* bits only valid on mtx_exit() */
MPASS2(((type) & (MTX_NORECURSE | MTX_NOSWITCH)) == 0,
@ -480,9 +478,9 @@ _mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
* XXX DOES NOT HANDLE RECURSION
*/
_MTX_INLINE int
_mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
int rval;
rval = atomic_cmpset_64(&mpp->mtx_lock, MTX_UNOWNED, CURTHD);
@ -502,9 +500,9 @@ _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
* Release lock m
*/
_MTX_INLINE void
_mtx_exit(mtx_t *mtxp, int type, const char *file, int line)
_mtx_exit(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
MPASS2(mtx_owned(mpp), STR_mtx_owned);
WITNESS_EXIT(mpp, type, file, line);

View File

@ -253,8 +253,8 @@ static struct trapframe proc0_tf;
struct cpuhead cpuhead;
mtx_t sched_lock;
mtx_t Giant;
struct mtx sched_lock;
struct mtx Giant;
#define offsetof(type, member) ((size_t)(&((type *)0)->member))

View File

@ -98,8 +98,6 @@ struct mtx {
#endif /* SMP_DEBUG */
};
typedef struct mtx mtx_t;
/*
* Filler for structs which need to remain the same size
* whether or not SMP_DEBUG is turned on.
@ -119,19 +117,19 @@ typedef struct mtxf {
#define CURTHD ((u_int)CURPROC) /* Current thread ID */
/* Prototypes */
void mtx_init(mtx_t *m, char *description, int flag);
void mtx_enter_hard(mtx_t *, int type, int flags);
void mtx_exit_hard(mtx_t *, int type);
void mtx_destroy(mtx_t *m);
void mtx_init(struct mtx *m, char *description, int flag);
void mtx_enter_hard(struct mtx *, int type, int flags);
void mtx_exit_hard(struct mtx *, int type);
void mtx_destroy(struct mtx *m);
/*
* Wrap the following functions with cpp macros so that filenames and line
* numbers are embedded in the code correctly.
*/
#if (defined(KLD_MODULE) || defined(_KERN_MUTEX_C_))
void _mtx_enter(mtx_t *mtxp, int type, const char *file, int line);
int _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_enter(struct mtx *mtxp, int type, const char *file, int line);
int _mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line);
void _mtx_exit(struct mtx *mtxp, int type, const char *file, int line);
#endif
#define mtx_enter(mtxp, type) \
@ -144,8 +142,8 @@ void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
_mtx_exit((mtxp), (type), __FILE__, __LINE__)
/* Global locks */
extern mtx_t sched_lock;
extern mtx_t Giant;
extern struct mtx sched_lock;
extern struct mtx Giant;
/*
* Used to replace return with an exit Giant and return.
@ -264,16 +262,16 @@ do { \
witness_restore(m, __CONCAT(n, __wf), __CONCAT(n, __wl)); \
} while (0)
void witness_init(mtx_t *, int flag);
void witness_destroy(mtx_t *);
void witness_enter(mtx_t *, int, const char *, int);
void witness_try_enter(mtx_t *, int, const char *, int);
void witness_exit(mtx_t *, int, const char *, int);
void witness_init(struct mtx *, int flag);
void witness_destroy(struct mtx *);
void witness_enter(struct mtx *, int, const char *, int);
void witness_try_enter(struct mtx *, int, const char *, int);
void witness_exit(struct mtx *, int, const char *, int);
void witness_display(void(*)(const char *fmt, ...));
void witness_list(struct proc *);
int witness_sleep(int, mtx_t *, const char *, int);
void witness_save(mtx_t *, const char **, int *);
void witness_restore(mtx_t *, const char *, int);
int witness_sleep(int, struct mtx *, const char *, int);
void witness_save(struct mtx *, const char **, int *);
void witness_restore(struct mtx *, const char *, int);
#else /* WITNESS */
#define WITNESS_ENTER(m, t, f, l)
#define WITNESS_EXIT(m, t, f, l)
@ -602,9 +600,9 @@ extern char STR_mtx_try_enter_fmt[];
* Note: since type is usually a constant much of this code is optimized out.
*/
_MTX_INLINE void
_mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *mpp = mtxp;
struct mtx *mpp = mtxp;
/* bits only valid on mtx_exit() */
MPASS2(((type) & (MTX_NORECURSE | MTX_NOSWITCH)) == 0,
@ -666,9 +664,9 @@ _mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
* XXX DOES NOT HANDLE RECURSION
*/
_MTX_INLINE int
_mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
int rval;
rval = atomic_cmpset_int(&mpp->mtx_lock, MTX_UNOWNED, CURTHD);
@ -690,9 +688,9 @@ _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
* Release lock m.
*/
_MTX_INLINE void
_mtx_exit(mtx_t *mtxp, int type, const char *file, int line)
_mtx_exit(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
MPASS2(mtx_owned(mpp), STR_mtx_owned);
WITNESS_EXIT(mpp, type, file, line);

View File

@ -79,10 +79,10 @@ struct harvest {
};
/* The reseed thread mutex */
static mtx_t random_reseed_mtx;
static struct mtx random_reseed_mtx;
/* The entropy harvest mutex */
static mtx_t random_harvest_mtx;
static struct mtx random_harvest_mtx;
/* <0 until the kthread starts, 0 for running */
static int random_kthread_status = -1;

View File

@ -79,10 +79,10 @@ struct harvest {
};
/* The reseed thread mutex */
static mtx_t random_reseed_mtx;
static struct mtx random_reseed_mtx;
/* The entropy harvest mutex */
static mtx_t random_harvest_mtx;
static struct mtx random_harvest_mtx;
/* <0 until the kthread starts, 0 for running */
static int random_kthread_status = -1;

View File

@ -253,8 +253,8 @@ static struct trapframe proc0_tf;
struct cpuhead cpuhead;
mtx_t sched_lock;
mtx_t Giant;
struct mtx sched_lock;
struct mtx Giant;
#define offsetof(type, member) ((size_t)(&((type *)0)->member))

View File

@ -45,7 +45,7 @@
#include <machine/mutex.h>
/* All mutexes in system (used for debug/panic) */
mtx_t all_mtx = { MTX_UNOWNED, 0, 0, "All mutexes queue head",
struct mtx all_mtx = { MTX_UNOWNED, 0, 0, "All mutexes queue head",
TAILQ_HEAD_INITIALIZER(all_mtx.mtx_blocked),
{ NULL, NULL }, &all_mtx, &all_mtx
#ifdef SMP_DEBUG
@ -90,7 +90,7 @@ static void
propagate_priority(struct proc *p)
{
int pri = p->p_priority;
mtx_t *m = p->p_blocked;
struct mtx *m = p->p_blocked;
for (;;) {
struct proc *p1;
@ -182,7 +182,7 @@ propagate_priority(struct proc *p)
}
void
mtx_enter_hard(mtx_t *m, int type, int flags)
mtx_enter_hard(struct mtx *m, int type, int flags)
{
struct proc *p = CURPROC;
@ -335,10 +335,10 @@ mtx_enter_hard(mtx_t *m, int type, int flags)
}
void
mtx_exit_hard(mtx_t *m, int type)
mtx_exit_hard(struct mtx *m, int type)
{
struct proc *p, *p1;
mtx_t *m1;
struct mtx *m1;
int pri;
switch (type) {
@ -434,12 +434,12 @@ mtx_exit_hard(mtx_t *m, int type)
#ifdef SMP_DEBUG
int mtx_validate __P((mtx_t *, int));
int mtx_validate __P((struct mtx *, int));
int
mtx_validate(mtx_t *m, int when)
mtx_validate(struct mtx *m, int when)
{
mtx_t *mp;
struct mtx *mp;
int i;
int retval = 0;
@ -492,7 +492,7 @@ mtx_validate(mtx_t *m, int when)
#endif
void
mtx_init(mtx_t *m, char *t, int flag)
mtx_init(struct mtx *m, char *t, int flag)
{
CTR2(KTR_LOCK, "mtx_init 0x%p (%s)", m, t);
@ -517,7 +517,7 @@ mtx_init(mtx_t *m, char *t, int flag)
}
void
mtx_destroy(mtx_t *m)
mtx_destroy(struct mtx *m)
{
CTR2(KTR_LOCK, "mtx_destroy 0x%p (%s)", m, m->mtx_description);

View File

@ -98,8 +98,6 @@ struct mtx {
#endif /* SMP_DEBUG */
};
typedef struct mtx mtx_t;
/*
* Filler for structs which need to remain the same size
* whether or not SMP_DEBUG is turned on.
@ -119,19 +117,19 @@ typedef struct mtxf {
#define CURTHD ((u_int)CURPROC) /* Current thread ID */
/* Prototypes */
void mtx_init(mtx_t *m, char *description, int flag);
void mtx_enter_hard(mtx_t *, int type, int flags);
void mtx_exit_hard(mtx_t *, int type);
void mtx_destroy(mtx_t *m);
void mtx_init(struct mtx *m, char *description, int flag);
void mtx_enter_hard(struct mtx *, int type, int flags);
void mtx_exit_hard(struct mtx *, int type);
void mtx_destroy(struct mtx *m);
/*
* Wrap the following functions with cpp macros so that filenames and line
* numbers are embedded in the code correctly.
*/
#if (defined(KLD_MODULE) || defined(_KERN_MUTEX_C_))
void _mtx_enter(mtx_t *mtxp, int type, const char *file, int line);
int _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_enter(struct mtx *mtxp, int type, const char *file, int line);
int _mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line);
void _mtx_exit(struct mtx *mtxp, int type, const char *file, int line);
#endif
#define mtx_enter(mtxp, type) \
@ -144,8 +142,8 @@ void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
_mtx_exit((mtxp), (type), __FILE__, __LINE__)
/* Global locks */
extern mtx_t sched_lock;
extern mtx_t Giant;
extern struct mtx sched_lock;
extern struct mtx Giant;
/*
* Used to replace return with an exit Giant and return.
@ -264,16 +262,16 @@ do { \
witness_restore(m, __CONCAT(n, __wf), __CONCAT(n, __wl)); \
} while (0)
void witness_init(mtx_t *, int flag);
void witness_destroy(mtx_t *);
void witness_enter(mtx_t *, int, const char *, int);
void witness_try_enter(mtx_t *, int, const char *, int);
void witness_exit(mtx_t *, int, const char *, int);
void witness_init(struct mtx *, int flag);
void witness_destroy(struct mtx *);
void witness_enter(struct mtx *, int, const char *, int);
void witness_try_enter(struct mtx *, int, const char *, int);
void witness_exit(struct mtx *, int, const char *, int);
void witness_display(void(*)(const char *fmt, ...));
void witness_list(struct proc *);
int witness_sleep(int, mtx_t *, const char *, int);
void witness_save(mtx_t *, const char **, int *);
void witness_restore(mtx_t *, const char *, int);
int witness_sleep(int, struct mtx *, const char *, int);
void witness_save(struct mtx *, const char **, int *);
void witness_restore(struct mtx *, const char *, int);
#else /* WITNESS */
#define WITNESS_ENTER(m, t, f, l)
#define WITNESS_EXIT(m, t, f, l)
@ -602,9 +600,9 @@ extern char STR_mtx_try_enter_fmt[];
* Note: since type is usually a constant much of this code is optimized out.
*/
_MTX_INLINE void
_mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *mpp = mtxp;
struct mtx *mpp = mtxp;
/* bits only valid on mtx_exit() */
MPASS2(((type) & (MTX_NORECURSE | MTX_NOSWITCH)) == 0,
@ -666,9 +664,9 @@ _mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
* XXX DOES NOT HANDLE RECURSION
*/
_MTX_INLINE int
_mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
int rval;
rval = atomic_cmpset_int(&mpp->mtx_lock, MTX_UNOWNED, CURTHD);
@ -690,9 +688,9 @@ _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
* Release lock m.
*/
_MTX_INLINE void
_mtx_exit(mtx_t *mtxp, int type, const char *file, int line)
_mtx_exit(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
MPASS2(mtx_owned(mpp), STR_mtx_owned);
WITNESS_EXIT(mpp, type, file, line);

View File

@ -75,7 +75,7 @@ static struct kmemusage *kmemusage;
static char *kmembase;
static char *kmemlimit;
mtx_t malloc_mtx;
struct mtx malloc_mtx;
u_int vm_kmem_size;

View File

@ -78,7 +78,7 @@ extern int witness_spin_check;
int witness_watch;
typedef struct witness {
struct witness {
struct witness *w_next;
char *w_description;
const char *w_file;
@ -92,12 +92,12 @@ typedef struct witness {
u_char w_spin:1; /* this is a spin mutex */
u_int w_level;
struct witness *w_children[WITNESS_NCHILDREN];
} witness_t;
};
typedef struct witness_blessed {
struct witness_blessed {
char *b_lock1;
char *b_lock2;
} witness_blessed_t;
};
#ifdef KDEBUG
/*
@ -118,27 +118,27 @@ int witness_kdebug = WITNESS_KDEBUG;
int witness_skipspin = WITNESS_SKIPSPIN;
static mtx_t w_mtx;
static witness_t *w_free;
static witness_t *w_all;
static int w_inited;
static int witness_dead; /* fatal error, probably no memory */
static struct mtx w_mtx;
static struct witness *w_free;
static struct witness *w_all;
static int w_inited;
static int witness_dead; /* fatal error, probably no memory */
static witness_t w_data[WITNESS_COUNT];
static struct witness w_data[WITNESS_COUNT];
static witness_t *enroll __P((char *description, int flag));
static int itismychild __P((witness_t *parent, witness_t *child));
static void removechild __P((witness_t *parent, witness_t *child));
static int isitmychild __P((witness_t *parent, witness_t *child));
static int isitmydescendant __P((witness_t *parent, witness_t *child));
static int dup_ok __P((witness_t *));
static int blessed __P((witness_t *, witness_t *));
static struct witness *enroll __P((char *description, int flag));
static int itismychild __P((struct witness *parent, struct witness *child));
static void removechild __P((struct witness *parent, struct witness *child));
static int isitmychild __P((struct witness *parent, struct witness *child));
static int isitmydescendant __P((struct witness *parent, struct witness *child));
static int dup_ok __P((struct witness *));
static int blessed __P((struct witness *, struct witness *));
static void witness_displaydescendants
__P((void(*)(const char *fmt, ...), witness_t *));
static void witness_leveldescendents __P((witness_t *parent, int level));
__P((void(*)(const char *fmt, ...), struct witness *));
static void witness_leveldescendents __P((struct witness *parent, int level));
static void witness_levelall __P((void));
static witness_t * witness_get __P((void));
static void witness_free __P((witness_t *m));
static struct witness * witness_get __P((void));
static void witness_free __P((struct witness *m));
static char *ignore_list[] = {
@ -198,20 +198,20 @@ static char *sleep_list[] = {
* Pairs of locks which have been blessed
* Don't complain about order problems with blessed locks
*/
static witness_blessed_t blessed_list[] = {
static struct witness_blessed blessed_list[] = {
};
static int blessed_count = sizeof (blessed_list) / sizeof (witness_blessed_t);
static int blessed_count = sizeof(blessed_list) / sizeof(struct witness_blessed);
void
witness_init(mtx_t *m, int flag)
witness_init(struct mtx *m, int flag)
{
m->mtx_witness = enroll(m->mtx_description, flag);
}
void
witness_destroy(mtx_t *m)
witness_destroy(struct mtx *m)
{
mtx_t *m1;
struct mtx *m1;
struct proc *p;
p = CURPROC;
for ((m1 = LIST_FIRST(&p->p_heldmtx)); m1 != NULL;
@ -226,10 +226,10 @@ witness_destroy(mtx_t *m)
}
void
witness_enter(mtx_t *m, int flags, const char *file, int line)
witness_enter(struct mtx *m, int flags, const char *file, int line)
{
witness_t *w, *w1;
mtx_t *m1;
struct witness *w, *w1;
struct mtx *m1;
struct proc *p;
int i;
#ifdef KDEBUG
@ -360,9 +360,9 @@ out:
}
void
witness_exit(mtx_t *m, int flags, const char *file, int line)
witness_exit(struct mtx *m, int flags, const char *file, int line)
{
witness_t *w;
struct witness *w;
w = m->mtx_witness;
@ -392,10 +392,10 @@ witness_exit(mtx_t *m, int flags, const char *file, int line)
}
void
witness_try_enter(mtx_t *m, int flags, const char *file, int line)
witness_try_enter(struct mtx *m, int flags, const char *file, int line)
{
struct proc *p;
witness_t *w = m->mtx_witness;
struct witness *w = m->mtx_witness;
if (flags & MTX_SPIN) {
if (!w->w_spin)
@ -429,7 +429,7 @@ witness_try_enter(mtx_t *m, int flags, const char *file, int line)
void
witness_display(void(*prnt)(const char *fmt, ...))
{
witness_t *w, *w1;
struct witness *w, *w1;
witness_levelall();
@ -456,9 +456,9 @@ witness_display(void(*prnt)(const char *fmt, ...))
}
int
witness_sleep(int check_only, mtx_t *mtx, const char *file, int line)
witness_sleep(int check_only, struct mtx *mtx, const char *file, int line)
{
mtx_t *m;
struct mtx *m;
struct proc *p;
char **sleep;
int n = 0;
@ -485,11 +485,11 @@ witness_sleep(int check_only, mtx_t *mtx, const char *file, int line)
return (n);
}
static witness_t *
static struct witness *
enroll(char *description, int flag)
{
int i;
witness_t *w, *w1;
struct witness *w, *w1;
char **ignore;
char **order;
@ -549,7 +549,7 @@ enroll(char *description, int flag)
}
static int
itismychild(witness_t *parent, witness_t *child)
itismychild(struct witness *parent, struct witness *child)
{
static int recursed;
@ -589,9 +589,9 @@ itismychild(witness_t *parent, witness_t *child)
}
static void
removechild(witness_t *parent, witness_t *child)
removechild(struct witness *parent, struct witness *child)
{
witness_t *w, *w1;
struct witness *w, *w1;
int i;
for (w = parent; w != NULL; w = w->w_morechildren)
@ -617,9 +617,9 @@ found:
}
static int
isitmychild(witness_t *parent, witness_t *child)
isitmychild(struct witness *parent, struct witness *child)
{
witness_t *w;
struct witness *w;
int i;
for (w = parent; w != NULL; w = w->w_morechildren) {
@ -632,9 +632,9 @@ isitmychild(witness_t *parent, witness_t *child)
}
static int
isitmydescendant(witness_t *parent, witness_t *child)
isitmydescendant(struct witness *parent, struct witness *child)
{
witness_t *w;
struct witness *w;
int i;
int j;
@ -655,7 +655,7 @@ isitmydescendant(witness_t *parent, witness_t *child)
void
witness_levelall (void)
{
witness_t *w, *w1;
struct witness *w, *w1;
for (w = w_all; w; w = w->w_next)
if (!w->w_spin)
@ -674,10 +674,10 @@ witness_levelall (void)
}
static void
witness_leveldescendents(witness_t *parent, int level)
witness_leveldescendents(struct witness *parent, int level)
{
int i;
witness_t *w;
struct witness *w;
if (parent->w_level < level)
parent->w_level = level;
@ -688,9 +688,10 @@ witness_leveldescendents(witness_t *parent, int level)
}
static void
witness_displaydescendants(void(*prnt)(const char *fmt, ...), witness_t *parent)
witness_displaydescendants(void(*prnt)(const char *fmt, ...),
struct witness *parent)
{
witness_t *w;
struct witness *w;
int i;
int level = parent->w_level;
@ -714,7 +715,7 @@ witness_displaydescendants(void(*prnt)(const char *fmt, ...), witness_t *parent)
}
static int
dup_ok(witness_t *w)
dup_ok(struct witness *w)
{
char **dup;
@ -725,10 +726,10 @@ dup_ok(witness_t *w)
}
static int
blessed(witness_t *w1, witness_t *w2)
blessed(struct witness *w1, struct witness *w2)
{
int i;
witness_blessed_t *b;
struct witness_blessed *b;
for (i = 0; i < blessed_count; i++) {
b = &blessed_list[i];
@ -744,10 +745,10 @@ blessed(witness_t *w1, witness_t *w2)
return (0);
}
static witness_t *
static struct witness *
witness_get()
{
witness_t *w;
struct witness *w;
if ((w = w_free) == NULL) {
witness_dead = 1;
@ -756,12 +757,12 @@ witness_get()
return (NULL);
}
w_free = w->w_next;
bzero(w, sizeof (*w));
bzero(w, sizeof(*w));
return (w);
}
static void
witness_free(witness_t *w)
witness_free(struct witness *w)
{
w->w_next = w_free;
w_free = w;
@ -770,7 +771,7 @@ witness_free(witness_t *w)
void
witness_list(struct proc *p)
{
mtx_t *m;
struct mtx *m;
for ((m = LIST_FIRST(&p->p_heldmtx)); m != NULL;
m = LIST_NEXT(m, mtx_held)) {
@ -781,14 +782,14 @@ witness_list(struct proc *p)
}
void
witness_save(mtx_t *m, const char **filep, int *linep)
witness_save(struct mtx *m, const char **filep, int *linep)
{
*filep = m->mtx_witness->w_file;
*linep = m->mtx_witness->w_line;
}
void
witness_restore(mtx_t *m, const char *file, int line)
witness_restore(struct mtx *m, const char *file, int line)
{
m->mtx_witness->w_file = file;
m->mtx_witness->w_line = line;

View File

@ -416,7 +416,7 @@ sleepinit(void)
int
msleep(ident, mtx, priority, wmesg, timo)
void *ident;
mtx_t *mtx;
struct mtx *mtx;
int priority, timo;
const char *wmesg;
{

View File

@ -78,7 +78,7 @@ extern int witness_spin_check;
int witness_watch;
typedef struct witness {
struct witness {
struct witness *w_next;
char *w_description;
const char *w_file;
@ -92,12 +92,12 @@ typedef struct witness {
u_char w_spin:1; /* this is a spin mutex */
u_int w_level;
struct witness *w_children[WITNESS_NCHILDREN];
} witness_t;
};
typedef struct witness_blessed {
struct witness_blessed {
char *b_lock1;
char *b_lock2;
} witness_blessed_t;
};
#ifdef KDEBUG
/*
@ -118,27 +118,27 @@ int witness_kdebug = WITNESS_KDEBUG;
int witness_skipspin = WITNESS_SKIPSPIN;
static mtx_t w_mtx;
static witness_t *w_free;
static witness_t *w_all;
static int w_inited;
static int witness_dead; /* fatal error, probably no memory */
static struct mtx w_mtx;
static struct witness *w_free;
static struct witness *w_all;
static int w_inited;
static int witness_dead; /* fatal error, probably no memory */
static witness_t w_data[WITNESS_COUNT];
static struct witness w_data[WITNESS_COUNT];
static witness_t *enroll __P((char *description, int flag));
static int itismychild __P((witness_t *parent, witness_t *child));
static void removechild __P((witness_t *parent, witness_t *child));
static int isitmychild __P((witness_t *parent, witness_t *child));
static int isitmydescendant __P((witness_t *parent, witness_t *child));
static int dup_ok __P((witness_t *));
static int blessed __P((witness_t *, witness_t *));
static struct witness *enroll __P((char *description, int flag));
static int itismychild __P((struct witness *parent, struct witness *child));
static void removechild __P((struct witness *parent, struct witness *child));
static int isitmychild __P((struct witness *parent, struct witness *child));
static int isitmydescendant __P((struct witness *parent, struct witness *child));
static int dup_ok __P((struct witness *));
static int blessed __P((struct witness *, struct witness *));
static void witness_displaydescendants
__P((void(*)(const char *fmt, ...), witness_t *));
static void witness_leveldescendents __P((witness_t *parent, int level));
__P((void(*)(const char *fmt, ...), struct witness *));
static void witness_leveldescendents __P((struct witness *parent, int level));
static void witness_levelall __P((void));
static witness_t * witness_get __P((void));
static void witness_free __P((witness_t *m));
static struct witness * witness_get __P((void));
static void witness_free __P((struct witness *m));
static char *ignore_list[] = {
@ -198,20 +198,20 @@ static char *sleep_list[] = {
* Pairs of locks which have been blessed
* Don't complain about order problems with blessed locks
*/
static witness_blessed_t blessed_list[] = {
static struct witness_blessed blessed_list[] = {
};
static int blessed_count = sizeof (blessed_list) / sizeof (witness_blessed_t);
static int blessed_count = sizeof(blessed_list) / sizeof(struct witness_blessed);
void
witness_init(mtx_t *m, int flag)
witness_init(struct mtx *m, int flag)
{
m->mtx_witness = enroll(m->mtx_description, flag);
}
void
witness_destroy(mtx_t *m)
witness_destroy(struct mtx *m)
{
mtx_t *m1;
struct mtx *m1;
struct proc *p;
p = CURPROC;
for ((m1 = LIST_FIRST(&p->p_heldmtx)); m1 != NULL;
@ -226,10 +226,10 @@ witness_destroy(mtx_t *m)
}
void
witness_enter(mtx_t *m, int flags, const char *file, int line)
witness_enter(struct mtx *m, int flags, const char *file, int line)
{
witness_t *w, *w1;
mtx_t *m1;
struct witness *w, *w1;
struct mtx *m1;
struct proc *p;
int i;
#ifdef KDEBUG
@ -360,9 +360,9 @@ out:
}
void
witness_exit(mtx_t *m, int flags, const char *file, int line)
witness_exit(struct mtx *m, int flags, const char *file, int line)
{
witness_t *w;
struct witness *w;
w = m->mtx_witness;
@ -392,10 +392,10 @@ witness_exit(mtx_t *m, int flags, const char *file, int line)
}
void
witness_try_enter(mtx_t *m, int flags, const char *file, int line)
witness_try_enter(struct mtx *m, int flags, const char *file, int line)
{
struct proc *p;
witness_t *w = m->mtx_witness;
struct witness *w = m->mtx_witness;
if (flags & MTX_SPIN) {
if (!w->w_spin)
@ -429,7 +429,7 @@ witness_try_enter(mtx_t *m, int flags, const char *file, int line)
void
witness_display(void(*prnt)(const char *fmt, ...))
{
witness_t *w, *w1;
struct witness *w, *w1;
witness_levelall();
@ -456,9 +456,9 @@ witness_display(void(*prnt)(const char *fmt, ...))
}
int
witness_sleep(int check_only, mtx_t *mtx, const char *file, int line)
witness_sleep(int check_only, struct mtx *mtx, const char *file, int line)
{
mtx_t *m;
struct mtx *m;
struct proc *p;
char **sleep;
int n = 0;
@ -485,11 +485,11 @@ witness_sleep(int check_only, mtx_t *mtx, const char *file, int line)
return (n);
}
static witness_t *
static struct witness *
enroll(char *description, int flag)
{
int i;
witness_t *w, *w1;
struct witness *w, *w1;
char **ignore;
char **order;
@ -549,7 +549,7 @@ enroll(char *description, int flag)
}
static int
itismychild(witness_t *parent, witness_t *child)
itismychild(struct witness *parent, struct witness *child)
{
static int recursed;
@ -589,9 +589,9 @@ itismychild(witness_t *parent, witness_t *child)
}
static void
removechild(witness_t *parent, witness_t *child)
removechild(struct witness *parent, struct witness *child)
{
witness_t *w, *w1;
struct witness *w, *w1;
int i;
for (w = parent; w != NULL; w = w->w_morechildren)
@ -617,9 +617,9 @@ found:
}
static int
isitmychild(witness_t *parent, witness_t *child)
isitmychild(struct witness *parent, struct witness *child)
{
witness_t *w;
struct witness *w;
int i;
for (w = parent; w != NULL; w = w->w_morechildren) {
@ -632,9 +632,9 @@ isitmychild(witness_t *parent, witness_t *child)
}
static int
isitmydescendant(witness_t *parent, witness_t *child)
isitmydescendant(struct witness *parent, struct witness *child)
{
witness_t *w;
struct witness *w;
int i;
int j;
@ -655,7 +655,7 @@ isitmydescendant(witness_t *parent, witness_t *child)
void
witness_levelall (void)
{
witness_t *w, *w1;
struct witness *w, *w1;
for (w = w_all; w; w = w->w_next)
if (!w->w_spin)
@ -674,10 +674,10 @@ witness_levelall (void)
}
static void
witness_leveldescendents(witness_t *parent, int level)
witness_leveldescendents(struct witness *parent, int level)
{
int i;
witness_t *w;
struct witness *w;
if (parent->w_level < level)
parent->w_level = level;
@ -688,9 +688,10 @@ witness_leveldescendents(witness_t *parent, int level)
}
static void
witness_displaydescendants(void(*prnt)(const char *fmt, ...), witness_t *parent)
witness_displaydescendants(void(*prnt)(const char *fmt, ...),
struct witness *parent)
{
witness_t *w;
struct witness *w;
int i;
int level = parent->w_level;
@ -714,7 +715,7 @@ witness_displaydescendants(void(*prnt)(const char *fmt, ...), witness_t *parent)
}
static int
dup_ok(witness_t *w)
dup_ok(struct witness *w)
{
char **dup;
@ -725,10 +726,10 @@ dup_ok(witness_t *w)
}
static int
blessed(witness_t *w1, witness_t *w2)
blessed(struct witness *w1, struct witness *w2)
{
int i;
witness_blessed_t *b;
struct witness_blessed *b;
for (i = 0; i < blessed_count; i++) {
b = &blessed_list[i];
@ -744,10 +745,10 @@ blessed(witness_t *w1, witness_t *w2)
return (0);
}
static witness_t *
static struct witness *
witness_get()
{
witness_t *w;
struct witness *w;
if ((w = w_free) == NULL) {
witness_dead = 1;
@ -756,12 +757,12 @@ witness_get()
return (NULL);
}
w_free = w->w_next;
bzero(w, sizeof (*w));
bzero(w, sizeof(*w));
return (w);
}
static void
witness_free(witness_t *w)
witness_free(struct witness *w)
{
w->w_next = w_free;
w_free = w;
@ -770,7 +771,7 @@ witness_free(witness_t *w)
void
witness_list(struct proc *p)
{
mtx_t *m;
struct mtx *m;
for ((m = LIST_FIRST(&p->p_heldmtx)); m != NULL;
m = LIST_NEXT(m, mtx_held)) {
@ -781,14 +782,14 @@ witness_list(struct proc *p)
}
void
witness_save(mtx_t *m, const char **filep, int *linep)
witness_save(struct mtx *m, const char **filep, int *linep)
{
*filep = m->mtx_witness->w_file;
*linep = m->mtx_witness->w_line;
}
void
witness_restore(mtx_t *m, const char *file, int line)
witness_restore(struct mtx *m, const char *file, int line)
{
m->mtx_witness->w_file = file;
m->mtx_witness->w_line = line;

View File

@ -78,7 +78,7 @@ extern int witness_spin_check;
int witness_watch;
typedef struct witness {
struct witness {
struct witness *w_next;
char *w_description;
const char *w_file;
@ -92,12 +92,12 @@ typedef struct witness {
u_char w_spin:1; /* this is a spin mutex */
u_int w_level;
struct witness *w_children[WITNESS_NCHILDREN];
} witness_t;
};
typedef struct witness_blessed {
struct witness_blessed {
char *b_lock1;
char *b_lock2;
} witness_blessed_t;
};
#ifdef KDEBUG
/*
@ -118,27 +118,27 @@ int witness_kdebug = WITNESS_KDEBUG;
int witness_skipspin = WITNESS_SKIPSPIN;
static mtx_t w_mtx;
static witness_t *w_free;
static witness_t *w_all;
static int w_inited;
static int witness_dead; /* fatal error, probably no memory */
static struct mtx w_mtx;
static struct witness *w_free;
static struct witness *w_all;
static int w_inited;
static int witness_dead; /* fatal error, probably no memory */
static witness_t w_data[WITNESS_COUNT];
static struct witness w_data[WITNESS_COUNT];
static witness_t *enroll __P((char *description, int flag));
static int itismychild __P((witness_t *parent, witness_t *child));
static void removechild __P((witness_t *parent, witness_t *child));
static int isitmychild __P((witness_t *parent, witness_t *child));
static int isitmydescendant __P((witness_t *parent, witness_t *child));
static int dup_ok __P((witness_t *));
static int blessed __P((witness_t *, witness_t *));
static struct witness *enroll __P((char *description, int flag));
static int itismychild __P((struct witness *parent, struct witness *child));
static void removechild __P((struct witness *parent, struct witness *child));
static int isitmychild __P((struct witness *parent, struct witness *child));
static int isitmydescendant __P((struct witness *parent, struct witness *child));
static int dup_ok __P((struct witness *));
static int blessed __P((struct witness *, struct witness *));
static void witness_displaydescendants
__P((void(*)(const char *fmt, ...), witness_t *));
static void witness_leveldescendents __P((witness_t *parent, int level));
__P((void(*)(const char *fmt, ...), struct witness *));
static void witness_leveldescendents __P((struct witness *parent, int level));
static void witness_levelall __P((void));
static witness_t * witness_get __P((void));
static void witness_free __P((witness_t *m));
static struct witness * witness_get __P((void));
static void witness_free __P((struct witness *m));
static char *ignore_list[] = {
@ -198,20 +198,20 @@ static char *sleep_list[] = {
* Pairs of locks which have been blessed
* Don't complain about order problems with blessed locks
*/
static witness_blessed_t blessed_list[] = {
static struct witness_blessed blessed_list[] = {
};
static int blessed_count = sizeof (blessed_list) / sizeof (witness_blessed_t);
static int blessed_count = sizeof(blessed_list) / sizeof(struct witness_blessed);
void
witness_init(mtx_t *m, int flag)
witness_init(struct mtx *m, int flag)
{
m->mtx_witness = enroll(m->mtx_description, flag);
}
void
witness_destroy(mtx_t *m)
witness_destroy(struct mtx *m)
{
mtx_t *m1;
struct mtx *m1;
struct proc *p;
p = CURPROC;
for ((m1 = LIST_FIRST(&p->p_heldmtx)); m1 != NULL;
@ -226,10 +226,10 @@ witness_destroy(mtx_t *m)
}
void
witness_enter(mtx_t *m, int flags, const char *file, int line)
witness_enter(struct mtx *m, int flags, const char *file, int line)
{
witness_t *w, *w1;
mtx_t *m1;
struct witness *w, *w1;
struct mtx *m1;
struct proc *p;
int i;
#ifdef KDEBUG
@ -360,9 +360,9 @@ out:
}
void
witness_exit(mtx_t *m, int flags, const char *file, int line)
witness_exit(struct mtx *m, int flags, const char *file, int line)
{
witness_t *w;
struct witness *w;
w = m->mtx_witness;
@ -392,10 +392,10 @@ witness_exit(mtx_t *m, int flags, const char *file, int line)
}
void
witness_try_enter(mtx_t *m, int flags, const char *file, int line)
witness_try_enter(struct mtx *m, int flags, const char *file, int line)
{
struct proc *p;
witness_t *w = m->mtx_witness;
struct witness *w = m->mtx_witness;
if (flags & MTX_SPIN) {
if (!w->w_spin)
@ -429,7 +429,7 @@ witness_try_enter(mtx_t *m, int flags, const char *file, int line)
void
witness_display(void(*prnt)(const char *fmt, ...))
{
witness_t *w, *w1;
struct witness *w, *w1;
witness_levelall();
@ -456,9 +456,9 @@ witness_display(void(*prnt)(const char *fmt, ...))
}
int
witness_sleep(int check_only, mtx_t *mtx, const char *file, int line)
witness_sleep(int check_only, struct mtx *mtx, const char *file, int line)
{
mtx_t *m;
struct mtx *m;
struct proc *p;
char **sleep;
int n = 0;
@ -485,11 +485,11 @@ witness_sleep(int check_only, mtx_t *mtx, const char *file, int line)
return (n);
}
static witness_t *
static struct witness *
enroll(char *description, int flag)
{
int i;
witness_t *w, *w1;
struct witness *w, *w1;
char **ignore;
char **order;
@ -549,7 +549,7 @@ enroll(char *description, int flag)
}
static int
itismychild(witness_t *parent, witness_t *child)
itismychild(struct witness *parent, struct witness *child)
{
static int recursed;
@ -589,9 +589,9 @@ itismychild(witness_t *parent, witness_t *child)
}
static void
removechild(witness_t *parent, witness_t *child)
removechild(struct witness *parent, struct witness *child)
{
witness_t *w, *w1;
struct witness *w, *w1;
int i;
for (w = parent; w != NULL; w = w->w_morechildren)
@ -617,9 +617,9 @@ found:
}
static int
isitmychild(witness_t *parent, witness_t *child)
isitmychild(struct witness *parent, struct witness *child)
{
witness_t *w;
struct witness *w;
int i;
for (w = parent; w != NULL; w = w->w_morechildren) {
@ -632,9 +632,9 @@ isitmychild(witness_t *parent, witness_t *child)
}
static int
isitmydescendant(witness_t *parent, witness_t *child)
isitmydescendant(struct witness *parent, struct witness *child)
{
witness_t *w;
struct witness *w;
int i;
int j;
@ -655,7 +655,7 @@ isitmydescendant(witness_t *parent, witness_t *child)
void
witness_levelall (void)
{
witness_t *w, *w1;
struct witness *w, *w1;
for (w = w_all; w; w = w->w_next)
if (!w->w_spin)
@ -674,10 +674,10 @@ witness_levelall (void)
}
static void
witness_leveldescendents(witness_t *parent, int level)
witness_leveldescendents(struct witness *parent, int level)
{
int i;
witness_t *w;
struct witness *w;
if (parent->w_level < level)
parent->w_level = level;
@ -688,9 +688,10 @@ witness_leveldescendents(witness_t *parent, int level)
}
static void
witness_displaydescendants(void(*prnt)(const char *fmt, ...), witness_t *parent)
witness_displaydescendants(void(*prnt)(const char *fmt, ...),
struct witness *parent)
{
witness_t *w;
struct witness *w;
int i;
int level = parent->w_level;
@ -714,7 +715,7 @@ witness_displaydescendants(void(*prnt)(const char *fmt, ...), witness_t *parent)
}
static int
dup_ok(witness_t *w)
dup_ok(struct witness *w)
{
char **dup;
@ -725,10 +726,10 @@ dup_ok(witness_t *w)
}
static int
blessed(witness_t *w1, witness_t *w2)
blessed(struct witness *w1, struct witness *w2)
{
int i;
witness_blessed_t *b;
struct witness_blessed *b;
for (i = 0; i < blessed_count; i++) {
b = &blessed_list[i];
@ -744,10 +745,10 @@ blessed(witness_t *w1, witness_t *w2)
return (0);
}
static witness_t *
static struct witness *
witness_get()
{
witness_t *w;
struct witness *w;
if ((w = w_free) == NULL) {
witness_dead = 1;
@ -756,12 +757,12 @@ witness_get()
return (NULL);
}
w_free = w->w_next;
bzero(w, sizeof (*w));
bzero(w, sizeof(*w));
return (w);
}
static void
witness_free(witness_t *w)
witness_free(struct witness *w)
{
w->w_next = w_free;
w_free = w;
@ -770,7 +771,7 @@ witness_free(witness_t *w)
void
witness_list(struct proc *p)
{
mtx_t *m;
struct mtx *m;
for ((m = LIST_FIRST(&p->p_heldmtx)); m != NULL;
m = LIST_NEXT(m, mtx_held)) {
@ -781,14 +782,14 @@ witness_list(struct proc *p)
}
void
witness_save(mtx_t *m, const char **filep, int *linep)
witness_save(struct mtx *m, const char **filep, int *linep)
{
*filep = m->mtx_witness->w_file;
*linep = m->mtx_witness->w_line;
}
void
witness_restore(mtx_t *m, const char *file, int line)
witness_restore(struct mtx *m, const char *file, int line)
{
m->mtx_witness->w_file = file;
m->mtx_witness->w_line = line;

View File

@ -267,8 +267,8 @@ static struct trapframe proc0_tf;
struct cpuhead cpuhead;
mtx_t sched_lock;
mtx_t Giant;
struct mtx sched_lock;
struct mtx Giant;
#define offsetof(type, member) ((size_t)(&((type *)0)->member))

View File

@ -267,8 +267,8 @@ static struct trapframe proc0_tf;
struct cpuhead cpuhead;
mtx_t sched_lock;
mtx_t Giant;
struct mtx sched_lock;
struct mtx Giant;
#define offsetof(type, member) ((size_t)(&((type *)0)->member))

View File

@ -99,8 +99,6 @@ struct mtx {
#endif /* SMP_DEBUG */
};
typedef struct mtx mtx_t;
/*
* Filler for structs which need to remain the same size
* whether or not SMP_DEBUG is turned on.
@ -120,19 +118,19 @@ typedef struct mtxf {
#define CURTHD ((u_int64_t)CURPROC) /* Current thread ID */
/* Prototypes */
void mtx_init(mtx_t *m, char *description, int flag);
void mtx_enter_hard(mtx_t *, int type, int ipl);
void mtx_exit_hard(mtx_t *, int type);
void mtx_destroy(mtx_t *m);
void mtx_init(struct mtx *m, char *description, int flag);
void mtx_enter_hard(struct mtx *, int type, int ipl);
void mtx_exit_hard(struct mtx *, int type);
void mtx_destroy(struct mtx *m);
/*
* Wrap the following functions with cpp macros so that filenames and line
* numbers are embedded in the code correctly.
*/
#if (defined(KLD_MODULE) || defined(_KERN_MUTEX_C_))
void _mtx_enter(mtx_t *mtxp, int type, const char *file, int line);
int _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
void _mtx_enter(struct mtx *mtxp, int type, const char *file, int line);
int _mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line);
void _mtx_exit(struct mtx *mtxp, int type, const char *file, int line);
#endif
#define mtx_enter(mtxp, type) \
@ -145,8 +143,8 @@ void _mtx_exit(mtx_t *mtxp, int type, const char *file, int line);
_mtx_exit((mtxp), (type), __FILE__, __LINE__)
/* Global locks */
extern mtx_t sched_lock;
extern mtx_t Giant;
extern struct mtx sched_lock;
extern struct mtx Giant;
/*
* Used to replace return with an exit Giant and return.
@ -267,16 +265,16 @@ do { \
witness_restore(m, __CONCAT(n, __wf), __CONCAT(n, __wl)); \
} while (0)
void witness_init(mtx_t *, int flag);
void witness_destroy(mtx_t *);
void witness_enter(mtx_t *, int, const char *, int);
void witness_try_enter(mtx_t *, int, const char *, int);
void witness_exit(mtx_t *, int, const char *, int);
void witness_init(struct mtx *, int flag);
void witness_destroy(struct mtx *);
void witness_enter(struct mtx *, int, const char *, int);
void witness_try_enter(struct mtx *, int, const char *, int);
void witness_exit(struct mtx *, int, const char *, int);
void witness_display(void(*)(const char *fmt, ...));
void witness_list(struct proc *);
int witness_sleep(int, mtx_t *, const char *, int);
void witness_save(mtx_t *, const char **, int *);
void witness_restore(mtx_t *, const char *, int);
int witness_sleep(int, struct mtx *, const char *, int);
void witness_save(struct mtx *, const char **, int *);
void witness_restore(struct mtx *, const char *, int);
#else /* WITNESS */
#define WITNESS_ENTER(m, t, f, l)
#define WITNESS_EXIT(m, t, f, l)
@ -424,9 +422,9 @@ extern char STR_mtx_try_enter_fmt[];
* Note: since type is usually a constant much of this code is optimized out
*/
_MTX_INLINE void
_mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *mpp = mtxp;
struct mtx *mpp = mtxp;
/* bits only valid on mtx_exit() */
MPASS2(((type) & (MTX_NORECURSE | MTX_NOSWITCH)) == 0,
@ -480,9 +478,9 @@ _mtx_enter(mtx_t *mtxp, int type, const char *file, int line)
* XXX DOES NOT HANDLE RECURSION
*/
_MTX_INLINE int
_mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
_mtx_try_enter(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
int rval;
rval = atomic_cmpset_64(&mpp->mtx_lock, MTX_UNOWNED, CURTHD);
@ -502,9 +500,9 @@ _mtx_try_enter(mtx_t *mtxp, int type, const char *file, int line)
* Release lock m
*/
_MTX_INLINE void
_mtx_exit(mtx_t *mtxp, int type, const char *file, int line)
_mtx_exit(struct mtx *mtxp, int type, const char *file, int line)
{
mtx_t *const mpp = mtxp;
struct mtx *const mpp = mtxp;
MPASS2(mtx_owned(mpp), STR_mtx_owned);
WITNESS_EXIT(mpp, type, file, line);