diff options
author | Lioncash <mathew1800@gmail.com> | 2021-05-31 10:15:49 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2021-05-31 22:41:00 +0200 |
commit | 3aed797466f6ba166a8e941c47687a345bca7576 (patch) | |
tree | 18ed4fcc2073a1228e9f2bf7e05bbf7ae7188a96 /src/core | |
parent | Merge pull request #6394 from lat9nq/mingw-fix (diff) | |
download | yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.gz yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.bz2 yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.lz yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.xz yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.zst yuzu-3aed797466f6ba166a8e941c47687a345bca7576.zip |
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/result.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 43968386f..df3283fe3 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -358,3 +358,28 @@ ResultVal<std::remove_reference_t<Arg>> MakeResult(Arg&& arg) { return CONCAT2(check_result_L, __LINE__); \ } \ } while (false) + +#define R_SUCCEEDED(res) (res.IsSuccess()) + +/// Evaluates a boolean expression, and succeeds if that expression is true. +#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), RESULT_SUCCESS) + +/// Evaluates a boolean expression, and returns a result unless that expression is true. +#define R_UNLESS(expr, res) \ + { \ + if (!(expr)) { \ + if (res.IsError()) { \ + LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \ + } \ + return res; \ + } \ + } + +/// 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; \ + } \ + } |