[asterisk-commits] Fix/Update clang-RAII macro implementation (asterisk[13])

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 22 14:25:40 CDT 2015


Matt Jordan has submitted this change and it was merged.

Change subject: Fix/Update clang-RAII macro implementation
......................................................................


Fix/Update clang-RAII macro implementation

- When you need to refer to 'variable XXX' outside a block, it needs
to be declared as '__block XXX', otherwise it will not be available with-
in the block, making updating that variable hard to do, and ast_free
lead to issues.

- Removed the #error message
because it creates complications when compiling external projects
against asterisk For example when using a different compiler than the
one used to compile asterisk. The warning/error should be generated
during the configure process not the compilation process

ASTERISK-24917
Change-Id: I12091228090e90831bf2b498293858f46ea7a8c2
---
M include/asterisk/utils.h
1 file changed, 2 insertions(+), 8 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Matt Jordan: Looks good to me, approved; Verified
  George Joseph: Looks good to me, but someone else must approve



diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index f3f5719..664e347 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -1031,19 +1031,13 @@
  */
 
 #if defined(__clang__)
-
-#if defined(__has_feature) && __has_feature(blocks)
 typedef void (^_raii_cleanup_block_t)(void);
 static inline void _raii_cleanup_block(_raii_cleanup_block_t *b) { (*b)(); }
 
 #define RAII_VAR(vartype, varname, initval, dtor)                                                                \
     _raii_cleanup_block_t _raii_cleanup_ ## varname __attribute__((cleanup(_raii_cleanup_block),unused)) = NULL; \
-    vartype varname = initval;                                                                                   \
-    _raii_cleanup_ ## varname = ^{ dtor(varname); }
-
-#else
-	#error "CLANG must support the 'blocks' feature to compile Asterisk."
-#endif /* #if defined(__has_feature) && __has_feature(blocks) */
+    __block vartype varname = initval;                                                                           \
+    _raii_cleanup_ ## varname = ^{ {(void)dtor(varname);} }
 
 #elif defined(__GNUC__)
 

-- 
To view, visit https://gerrit.asterisk.org/159
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I12091228090e90831bf2b498293858f46ea7a8c2
Gerrit-PatchSet: 4
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Diederik de Groot <dkgroot at talon.nl>
Gerrit-Reviewer: Diederik de Groot <dkgroot at talon.nl>
Gerrit-Reviewer: George Joseph <george.joseph at fairview5.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>
Gerrit-Reviewer: Matt Jordan <mjordan at digium.com>



More information about the asterisk-commits mailing list