diff options
author | jhb <jhb@FreeBSD.org> | 2001-09-22 21:19:55 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2001-09-22 21:19:55 +0000 |
commit | 9426cdbe394ea7f3120f023fb356b022ba303fef (patch) | |
tree | ed2cebe192cb68127b459af5d58946dacac44eb8 /sys | |
parent | cba438d63ffdf61f735025d74c7c7f3ad5ca24bd (diff) | |
download | FreeBSD-src-9426cdbe394ea7f3120f023fb356b022ba303fef.zip FreeBSD-src-9426cdbe394ea7f3120f023fb356b022ba303fef.tar.gz |
Since we no longer inline any debugging code in the mutex operations, move
all the debugging code into the function versions of the mutex operations
in kern_mutex.c. This reduced the __mtx_* macros to simply wrappers of
the _{get,rel}_lock_* macros, so the __mtx_* macros were also abolished in
favor of just calling the _{get,rel}_lock_* macros. The tangled hairy mass
of macros calling macros is at least a bit more sane now.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_mutex.c | 28 | ||||
-rw-r--r-- | sys/kern/subr_turnstile.c | 28 | ||||
-rw-r--r-- | sys/sys/mutex.h | 48 |
3 files changed, 52 insertions, 52 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 97c6b49..bd4f6d1 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -229,28 +229,48 @@ void _mtx_lock_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_lock_flags(m, opts, file, line); + MPASS(curthread != NULL); + KASSERT((opts & MTX_NOSWITCH) == 0, + ("MTX_NOSWITCH used at %s:%d", file, line)); + _get_sleep_lock(m, curthread, opts, file, line); + LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); } void _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_unlock_flags(m, opts, file, line); + MPASS(curthread != NULL); + mtx_assert((m), MA_OWNED); + WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + _rel_sleep_lock(m, curthread, opts, file, line); } void _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_lock_spin_flags(m, opts, file, line); + MPASS(curthread != NULL); + _get_spin_lock(m, curthread, opts, file, line); + LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); } void _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_unlock_spin_flags(m, opts, file, line); + MPASS(curthread != NULL); + mtx_assert((m), MA_OWNED); + WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + _rel_spin_lock(m); } /* diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 97c6b49..bd4f6d1 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -229,28 +229,48 @@ void _mtx_lock_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_lock_flags(m, opts, file, line); + MPASS(curthread != NULL); + KASSERT((opts & MTX_NOSWITCH) == 0, + ("MTX_NOSWITCH used at %s:%d", file, line)); + _get_sleep_lock(m, curthread, opts, file, line); + LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); } void _mtx_unlock_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_unlock_flags(m, opts, file, line); + MPASS(curthread != NULL); + mtx_assert((m), MA_OWNED); + WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + _rel_sleep_lock(m, curthread, opts, file, line); } void _mtx_lock_spin_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_lock_spin_flags(m, opts, file, line); + MPASS(curthread != NULL); + _get_spin_lock(m, curthread, opts, file, line); + LOCK_LOG_LOCK("LOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + WITNESS_LOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); } void _mtx_unlock_spin_flags(struct mtx *m, int opts, const char *file, int line) { - __mtx_unlock_spin_flags(m, opts, file, line); + MPASS(curthread != NULL); + mtx_assert((m), MA_OWNED); + WITNESS_UNLOCK(&m->mtx_object, opts | LOP_EXCLUSIVE, file, line); + LOCK_LOG_LOCK("UNLOCK", &m->mtx_object, opts, m->mtx_recurse, file, + line); + _rel_spin_lock(m); } /* diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h index ade2a4c..36763c1 100644 --- a/sys/sys/mutex.h +++ b/sys/sys/mutex.h @@ -249,55 +249,15 @@ void _mtx_assert(struct mtx *m, int what, const char *file, int line); _mtx_unlock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE) #else #define mtx_lock_flags(m, opts) \ - __mtx_lock_flags((m), (opts), LOCK_FILE, LOCK_LINE) + _get_sleep_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) #define mtx_unlock_flags(m, opts) \ - __mtx_unlock_flags((m), (opts), LOCK_FILE, LOCK_LINE) + _rel_sleep_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) #define mtx_lock_spin_flags(m, opts) \ - __mtx_lock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE) + _get_spin_lock((m), curthread, (opts), LOCK_FILE, LOCK_LINE) #define mtx_unlock_spin_flags(m, opts) \ - __mtx_unlock_spin_flags((m), (opts), LOCK_FILE, LOCK_LINE) + _rel_spin_lock((m)) #endif -#define __mtx_lock_flags(m, opts, file, line) do { \ - MPASS(curthread != NULL); \ - KASSERT(((opts) & MTX_NOSWITCH) == 0, \ - ("MTX_NOSWITCH used at %s:%d", (file), (line))); \ - _get_sleep_lock((m), curthread, (opts), (file), (line)); \ - LOCK_LOG_LOCK("LOCK", &(m)->mtx_object, opts, m->mtx_recurse, \ - (file), (line)); \ - WITNESS_LOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, (file), \ - (line)); \ -} while (0) - -#define __mtx_lock_spin_flags(m, opts, file, line) do { \ - MPASS(curthread != NULL); \ - _get_spin_lock((m), curthread, (opts), (file), (line)); \ - LOCK_LOG_LOCK("LOCK", &(m)->mtx_object, opts, m->mtx_recurse, \ - (file), (line)); \ - WITNESS_LOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, (file), \ - (line)); \ -} while (0) - -#define __mtx_unlock_flags(m, opts, file, line) do { \ - MPASS(curthread != NULL); \ - mtx_assert((m), MA_OWNED); \ - WITNESS_UNLOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, \ - (file), (line)); \ - LOCK_LOG_LOCK("UNLOCK", &(m)->mtx_object, (opts), \ - (m)->mtx_recurse, (file), (line)); \ - _rel_sleep_lock((m), curthread, (opts), (file), (line)); \ -} while (0) - -#define __mtx_unlock_spin_flags(m, opts, file, line) do { \ - MPASS(curthread != NULL); \ - mtx_assert((m), MA_OWNED); \ - WITNESS_UNLOCK(&(m)->mtx_object, (opts) | LOP_EXCLUSIVE, \ - (file), (line)); \ - LOCK_LOG_LOCK("UNLOCK", &(m)->mtx_object, (opts), \ - (m)->mtx_recurse, (file), (line)); \ - _rel_spin_lock((m)); \ -} while (0) - #define mtx_trylock_flags(m, opts) \ _mtx_trylock((m), (opts), LOCK_FILE, LOCK_LINE) |