summaryrefslogtreecommitdiff
path: root/include/asterisk/utils.h
diff options
context:
space:
mode:
authorDiederik de Groot <ddegroot@talon.nl>2015-04-20 20:01:35 +0200
committerMark Michelson <mmichelson@digium.com>2015-04-20 17:09:10 -0500
commit2be9cc26434fa91dc6f5bf9a39097d0ef4582a13 (patch)
tree9bb31837d323b49610e85629cf1d71d9d6ff3371 /include/asterisk/utils.h
parentb74b2cdcda5b5c2228e55142ec33d3c16790e233 (diff)
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
Diffstat (limited to 'include/asterisk/utils.h')
-rw-r--r--include/asterisk/utils.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index f3f571972..664e347cf 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -1031,19 +1031,13 @@ char *ast_utils_which(const char *binary, char *fullpath, size_t fullpath_size);
*/
#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__)