diff options
author | Matt Jordan <mjordan@digium.com> | 2015-04-22 14:25:40 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit2@gerrit.digium.api> | 2015-04-22 14:25:40 -0500 |
commit | 5a3948a66f325036ace5964a5a4cbdae6f28c6dc (patch) | |
tree | fe0e06ac7a421aef6eb47636ebc77bbbebdbf5e4 | |
parent | 2ef1e1fc682d94f4c50027026ad70fd2fa40420c (diff) | |
parent | 2be9cc26434fa91dc6f5bf9a39097d0ef4582a13 (diff) |
Merge "Fix/Update clang-RAII macro implementation" into 13
-rw-r--r-- | include/asterisk/utils.h | 10 |
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__) |