From 3355bb2fa5dd352a61a11aee14c84ea144f25756 Mon Sep 17 00:00:00 2001 From: Jason Parker <jparker@digium.com> Date: Tue, 9 Jul 2013 21:40:38 +0000 Subject: [PATCH] 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 --- include/asterisk/lock.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h index 4b1752cc42..6ede7de501 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 -- GitLab