Mercurial > libjeffpc
changeset 763:2456b4bf6737
synch: move lock class and lock name into info
Signed-off-by: Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
author | Josef 'Jeff' Sipek <jeffpc@josefsipek.net> |
---|---|
date | Thu, 25 Jul 2019 13:02:07 -0400 |
parents | ea9254b258c6 |
children | ac06f315317e |
files | include/jeffpc/synch.h synch.c |
diffstat | 2 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/include/jeffpc/synch.h Thu Jul 25 13:21:14 2019 -0400 +++ b/include/jeffpc/synch.h Thu Jul 25 13:02:07 2019 -0400 @@ -56,15 +56,15 @@ struct lock_info { uintptr_t magic; unsigned int type; +#ifdef JEFFPC_LOCK_TRACKING + struct lock_class *lc; + const char *name; +#endif }; struct lock { struct lock_info info; pthread_mutex_t lock; -#ifdef JEFFPC_LOCK_TRACKING - struct lock_class *lc; - const char *name; -#endif }; struct rwlock {
--- a/synch.c Thu Jul 25 13:21:14 2019 -0400 +++ b/synch.c Thu Jul 25 13:02:07 2019 -0400 @@ -139,7 +139,7 @@ { cmn_err(CE_CRIT, "lockdep: %s (%p) <%c> at %s:%d", #ifdef JEFFPC_LOCK_TRACKING - lock->name, + lock->info.name, #else "<unknown>", #endif @@ -203,7 +203,7 @@ cmn_err(CE_CRIT, "lockdep: %s #%zd: %s (%p) <%c> acquired at %s:%d", (cur == highlight) ? "->" : " ", - i, lock->name, lock, + i, lock->info.name, lock, GENERATE_LOCK_MASK_ARGS(lock), cur->where.file, cur->where.line); } @@ -255,10 +255,11 @@ cmn_err(CE_CRIT, "lockdep: circular dependency detected"); cmn_err(CE_CRIT, "lockdep: thread is trying to acquire lock of " - "class %s (%p):", new->lc->name, new->lc); + "class %s (%p):", new->info.lc->name, new->info.lc); print_lock(new, where); cmn_err(CE_CRIT, "lockdep: but the thread is already holding of " - "class %s (%p):", last->lock->lc->name, last->lock->lc); + "class %s (%p):", last->lock->info.lc->name, + last->lock->info.lc); print_lock(last->lock, &last->where); cmn_err(CE_CRIT, "lockdep: which already depends on the new lock's " "class."); @@ -411,11 +412,11 @@ LOCK_DEP_GRAPH(); - ret = add_dependency(lock->lc, last->lock->lc); + ret = add_dependency(lock->info.lc, last->lock->info.lc); if (ret < 0) error_alloc(lock, where, "lock dependency count limit reached"); else if (ret > 0) - find_path(lock, where, last->lock->lc, lock->lc, last); + find_path(lock, where, last->lock->info.lc, lock->info.lc, last); UNLOCK_DEP_GRAPH(); @@ -478,8 +479,8 @@ l->info.type = SYNCH_TYPE_MUTEX; #ifdef JEFFPC_LOCK_TRACKING - l->lc = lc; - l->name = where->lockname; + l->info.lc = lc; + l->info.name = where->lockname; #endif } @@ -523,7 +524,7 @@ /* check for deadlocks & recursive locking */ for_each_held_lock(i, held) { - if ((held->lock == l) || (held->lock->lc == l->lc)) { + if ((held->lock == l) || (held->lock->info.lc == l->info.lc)) { error_lock(held, l, where); return; }