diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 19:40:21 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-10-01 19:40:21 +0000 |
commit | 6ea9a3f2a60f92f0b43afad80adcc17a21b07fc7 (patch) | |
tree | d227b27c13b160f8ba3b6aa1822ab2f20585e1ca /include/asterisk/lock.h | |
parent | 9783d00623fe5e6e66b13c5c48e82416e98b9b2b (diff) |
Merged revisions 84206 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r84206 | russell | 2007-10-01 14:34:12 -0500 (Mon, 01 Oct 2007) | 2 lines
Show rwlocks in the "core show locks" output. Before, it only showed mutexes.
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@84207 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/lock.h')
-rw-r--r-- | include/asterisk/lock.h | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 686f36685..cbd8f3a55 100644 --- a/include/asterisk/lock.h +++ b/include/asterisk/lock.h @@ -702,6 +702,84 @@ static inline int ast_rwlock_destroy(ast_rwlock_t *prwlock) return pthread_rwlock_destroy(prwlock); } +#ifdef DEBUG_THREADS +#define ast_rwlock_unlock(a) \ + _ast_rwlock_unlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +static inline int _ast_rwlock_unlock(ast_rwlock_t *lock, const char *name, + const char *file, int line, const char *func) +{ + int res; + res = pthread_rwlock_unlock(lock); + ast_remove_lock_info(lock); + return res; +} + +#define ast_rwlock_rdlock(a) \ + _ast_rwlock_rdlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +static inline int _ast_rwlock_rdlock(ast_rwlock_t *lock, const char *name, + const char *file, int line, const char *func) +{ + int res; + ast_store_lock_info(file, line, func, name, lock); + res = pthread_rwlock_rdlock(lock); + if (!res) + ast_mark_lock_acquired(); + else + ast_remove_lock_info(lock); + return res; +} + +#define ast_rwlock_wrlock(a) \ + _ast_rwlock_wrlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +static inline int _ast_rwlock_wrlock(ast_rwlock_t *lock, const char *name, + const char *file, int line, const char *func) +{ + int res; + ast_store_lock_info(file, line, func, name, lock); + res = pthread_rwlock_wrlock(lock); + if (!res) + ast_mark_lock_acquired(); + else + ast_remove_lock_info(lock); + return res; +} + +#define ast_rwlock_tryrdlock(a) \ + _ast_rwlock_tryrdlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *lock, const char *name, + const char *file, int line, const char *func) +{ + int res; + ast_store_lock_info(file, line, func, name, lock); + res = pthread_rwlock_tryrdlock(lock); + if (!res) + ast_mark_lock_acquired(); + else + ast_remove_lock_info(lock); + return res; +} + +#define ast_rwlock_trywrlock(a) \ + _ast_rwlock_trywrlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) + +static inline int _ast_rwlock_trywrlock(ast_rwlock_t *lock, const char *name, + const char *file, int line, const char *func) +{ + int res; + ast_store_lock_info(file, line, func, name, lock); + res = pthread_rwlock_trywrlock(lock); + if (!res) + ast_mark_lock_acquired(); + else + ast_remove_lock_info(lock); + return res; +} + +#else static inline int ast_rwlock_unlock(ast_rwlock_t *prwlock) { return pthread_rwlock_unlock(prwlock); @@ -726,6 +804,7 @@ static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock) { return pthread_rwlock_trywrlock(prwlock); } +#endif /* DEBUG_THREADS */ /* Statically declared read/write locks */ |