summaryrefslogtreecommitdiff
path: root/src/common/common_funcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/common_funcs.h')
-rw-r--r--src/common/common_funcs.h17
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);
97#define R_UNLESS(expr, res) \ 97#define R_UNLESS(expr, res) \
98 { \ 98 { \
99 if (!(expr)) { \ 99 if (!(expr)) { \
100 if (res.IsError()) { \
101 LOG_ERROR(Kernel, "Failed with result: {}", res.raw); \
102 } \
100 return res; \ 103 return res; \
101 } \ 104 } \
102 } 105 }
103 106
107#define R_SUCCEEDED(res) (res.IsSuccess())
108
109/// Evaluates an expression that returns a result, and returns the result if it would fail.
110#define R_TRY(res_expr) \
111 { \
112 const auto _tmp_r_try_rc = (res_expr); \
113 if (_tmp_r_try_rc.IsError()) { \
114 return _tmp_r_try_rc; \
115 } \
116 }
117
118/// Evaluates a boolean expression, and succeeds if that expression is true.
119#define R_SUCCEED_IF(expr) R_UNLESS(!(expr), RESULT_SUCCESS)
120
104namespace Common { 121namespace Common {
105 122
106[[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) { 123[[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) {