diff options
author | bunnei <bunneidev@gmail.com> | 2021-01-29 23:06:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 23:06:40 -0800 |
commit | a4526c4e1acb50808bbe205952101142288e1c60 (patch) | |
tree | 7109edf89606c43352da9de40d0e3a920a08b659 /src/common/common_funcs.h | |
parent | 5861bacafd76b76bc196e9522e0315fb243635f8 (diff) | |
parent | 543e2125541aa3c3399dd471cd170153ce67c369 (diff) |
Merge pull request #5779 from bunnei/kthread-rewrite
Rewrite KThread to be more accurate
Diffstat (limited to 'src/common/common_funcs.h')
-rw-r--r-- | src/common/common_funcs.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 75f3027fb..71b64e32a 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -97,10 +97,27 @@ __declspec(dllimport) void __stdcall DebugBreak(void); #define R_UNLESS(expr, res) \ { \ if (!(expr)) { \ + if (res.IsError()) { \ + LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \ + } \ return res; \ } \ } +#define R_SUCCEEDED(res) (res.IsSuccess()) + +/// Evaluates an expression that returns a result, and returns the result if it would fail. +#define R_TRY(res_expr) \ + { \ + const auto _tmp_r_try_rc = (res_expr); \ + if (_tmp_r_try_rc.IsError()) { \ + return _tmp_r_try_rc; \ + } \ + } + +/// Evaluates a boolean expression, and succeeds if that expression is true. +#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), RESULT_SUCCESS) + namespace Common { [[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) { |