Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cpfs interface enter/exit wrappers
- #define CPFS_ENTER(fmt, ...) \
- do { \
- log_info(fmt, ##__VA_ARGS__); \
- util_cpfs_enter(cpfs_); \
- cpfs_ = NULL; \
- } while (false)
- #define _CPFS_RETURN(commit, retval) do { \
- util_cpfs_exit(commit, __func__); \
- return retval; \
- } while (false)
- // these wrappers could be done using type-generic macros
- // supported by GCC and C1x
- #define CPFS_RETURN_BOOL(retval) do { \
- static_assert(std::is_same<decltype(retval), bool>::value, "retval must be bool"); \
- bool _rv_ = (retval); \
- _CPFS_RETURN(_rv_, _rv_); \
- } while (false)
- #define CPFS_RETURN_FD(retval) do { \
- static_assert(std::is_same<decltype(retval), int>::value, "retval must be int"); \
- int _rv_ = (retval); \
- if (_rv_ == -1) _CPFS_RETURN(false, _rv_); \
- else { assert(fd_valid(_rv_)); _CPFS_RETURN(true, _rv_); } \
- } while (false)
- #define CPFS_RETURN_SIZE(retval, count) do { \
- static_assert(std::is_same<decltype(retval), CpfsSizeRet>::value, "retval must be CpfsSizeRet"); \
- CpfsSizeRet _rv_ = (retval); \
- decltype(_rv_) _cnt_ VARATTR_UNUSED = (count); \
- if (_rv_ == -1) _CPFS_RETURN(false, _rv_); \
- else { assert(_rv_ <= _cnt_); _CPFS_RETURN(true, _rv_); } \
- } while (false)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement