summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Jordan <mjordan@digium.com>2015-04-22 14:25:47 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2015-04-22 14:25:47 -0500
commit86d5556b661c572f4fc85591103d72fbece816d3 (patch)
tree09c70d1190815fb337f2613abbf9adc66b372d6d
parent10b36298b2aa32ee890c46c3ee7744a4fe20fa03 (diff)
parent09c7c678a331e360463408b7be9671131154daea (diff)
Merge "Fix/Update clang-RAII macro implementation"
-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__)