summaryrefslogtreecommitdiff
path: root/src/core/hle/result.h
diff options
context:
space:
mode:
authorGravatar Lioncash2021-05-31 04:15:49 -0400
committerGravatar Lioncash2021-05-31 16:41:00 -0400
commit3aed797466f6ba166a8e941c47687a345bca7576 (patch)
tree18ed4fcc2073a1228e9f2bf7e05bbf7ae7188a96 /src/core/hle/result.h
parentMerge pull request #6394 from lat9nq/mingw-fix (diff)
downloadyuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.gz
yuzu-3aed797466f6ba166a8e941c47687a345bca7576.tar.xz
yuzu-3aed797466f6ba166a8e941c47687a345bca7576.zip
common_funcs: Move R_ macros to result.h
These macros all interact with the result code type, so they should ideally be within this file as well, so all the common_funcs machinery doesn't need to be pulled in just to use them.
Diffstat (limited to 'src/core/hle/result.h')
-rw-r--r--src/core/hle/result.h25
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) {
358 return CONCAT2(check_result_L, __LINE__); \ 358 return CONCAT2(check_result_L, __LINE__); \
359 } \ 359 } \
360 } while (false) 360 } while (false)
361
362#define R_SUCCEEDED(res) (res.IsSuccess())
363
364/// Evaluates a boolean expression, and succeeds if that expression is true.
365#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), RESULT_SUCCESS)
366
367/// Evaluates a boolean expression, and returns a result unless that expression is true.
368#define R_UNLESS(expr, res) \
369 { \
370 if (!(expr)) { \
371 if (res.IsError()) { \
372 LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \
373 } \
374 return res; \
375 } \
376 }
377
378/// Evaluates an expression that returns a result, and returns the result if it would fail.
379#define R_TRY(res_expr) \
380 { \
381 const auto _tmp_r_try_rc = (res_expr); \
382 if (_tmp_r_try_rc.IsError()) { \
383 return _tmp_r_try_rc; \
384 } \
385 }