From 4577dcd5f90ae4e4e19a5ebdcec0f6f847977edf Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 00:51:16 -0800 Subject: common: common_funcs: Add R_UNLESS_NOLOG for scenarios that should not log. --- src/common/common_funcs.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/common') diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 71b64e32a..cd3207a03 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -104,6 +104,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void); } \ } +/// Evaluates a boolean expression, and returns a result unless that expression is true. +#define R_UNLESS_NOLOG(expr, res) \ + { \ + if (!(expr)) { \ + return res; \ + } \ + } + #define R_SUCCEEDED(res) (res.IsSuccess()) /// Evaluates an expression that returns a result, and returns the result if it would fail. -- cgit v1.2.3 From 18175c71edf90eeb73c6f47745b2bad32e4a1478 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sun, 31 Jan 2021 16:54:10 -0800 Subject: common: scope_exit: Add a cancellable ScopeExit macro. --- src/common/scope_exit.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/common') diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h index fa46cb394..35dac3a8f 100644 --- a/src/common/scope_exit.h +++ b/src/common/scope_exit.h @@ -49,3 +49,9 @@ ScopeExitHelper ScopeExit(Func&& func) { * \endcode */ #define SCOPE_EXIT(body) auto CONCAT2(scope_exit_helper_, __LINE__) = detail::ScopeExit([&]() body) + +/** + * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be + * used when the caller might want to cancel the ScopeExit. + */ +#define SCOPE_GUARD(body) detail::ScopeExit([&]() body) -- cgit v1.2.3 From ea4f62615e71cd2b680517b7609928ed0abf216d Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 4 Feb 2021 16:56:57 -0800 Subject: hle: kernel: Drop R_UNLESS_NOLOG in favor of expanded if-statement. --- src/common/common_funcs.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/common') diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index cd3207a03..71b64e32a 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -104,14 +104,6 @@ __declspec(dllimport) void __stdcall DebugBreak(void); } \ } -/// Evaluates a boolean expression, and returns a result unless that expression is true. -#define R_UNLESS_NOLOG(expr, res) \ - { \ - if (!(expr)) { \ - return res; \ - } \ - } - #define R_SUCCEEDED(res) (res.IsSuccess()) /// Evaluates an expression that returns a result, and returns the result if it would fail. -- cgit v1.2.3