mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 16:20:37 +00:00
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
This commit is contained in:
@@ -600,9 +600,7 @@ static void __attribute__((destructor)) fini_##rwlock(void) \
|
|||||||
* \param unlockfunc The function to call to unlock the lock
|
* \param unlockfunc The function to call to unlock the lock
|
||||||
*/
|
*/
|
||||||
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc) \
|
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc) \
|
||||||
auto void _dtor_ ## varname (typeof((lock)) * v); \
|
RAII_VAR(typeof((lock)), varname, ({lockfunc((lock)); (lock); }), unlockfunc)
|
||||||
auto void _dtor_ ## varname (typeof((lock)) * v) { unlockfunc(*v); } \
|
|
||||||
typeof((lock)) varname __attribute__((cleanup(_dtor_ ## varname))) = lock; lockfunc((lock))
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief scoped lock specialization for mutexes
|
* \brief scoped lock specialization for mutexes
|
||||||
|
|||||||
Reference in New Issue
Block a user