Skip to content
Snippets Groups Projects
Commit 3355bb2f authored by Jason Parker's avatar Jason Parker
Browse files

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
parent 5dbaee23
No related branches found
No related tags found
No related merge requests found
...@@ -600,9 +600,7 @@ static void __attribute__((destructor)) fini_##rwlock(void) \ ...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment