summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJason Parker <jparker@digium.com>2013-07-09 21:40:38 +0000
committerJason Parker <jparker@digium.com>2013-07-09 21:40:38 +0000
commit3355bb2fa5dd352a61a11aee14c84ea144f25756 (patch)
tree6e3040eb53c47b4998f80c16f5e7dafbc67c60a2 /include
parent5dbaee232c2c88f2017886a5e203c40dce948758 (diff)
Make SCOPED_LOCK use RAII_VAR.
This fixes an issue with requiring SCOPED_LOCK to be the last variable declaration and removes duplicate code in the process. Review: https://reviewboard.asterisk.org/r/2665/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@393919 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/lock.h4
1 files changed, 1 insertions, 3 deletions
diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index 4b1752cc4..6ede7de50 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -600,9 +600,7 @@ static void __attribute__((destructor)) fini_##rwlock(void) \
* \param unlockfunc The function to call to unlock the lock
*/
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc) \
- auto void _dtor_ ## varname (typeof((lock)) * v); \
- auto void _dtor_ ## varname (typeof((lock)) * v) { unlockfunc(*v); } \
- typeof((lock)) varname __attribute__((cleanup(_dtor_ ## varname))) = lock; lockfunc((lock))
+ RAII_VAR(typeof((lock)), varname, ({lockfunc((lock)); (lock); }), unlockfunc)
/*!
* \brief scoped lock specialization for mutexes