summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-03-21 03:40:03 +0100
committerbunnei <bunneidev@gmail.com>2020-04-17 06:59:27 +0200
commitb11b424a2df48c6e17968be1d6dd2b69c7c728db (patch)
treea28052da071b98bdf3533a576e56daa1d30d2a00
parentprocess: SetupMainThread: Zero out argument on process start. (diff)
downloadyuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.tar
yuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.tar.gz
yuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.tar.bz2
yuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.tar.lz
yuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.tar.xz
yuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.tar.zst
yuzu-b11b424a2df48c6e17968be1d6dd2b69c7c728db.zip
-rw-r--r--src/common/common_funcs.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h
index 052254678..88cf5250a 100644
--- a/src/common/common_funcs.h
+++ b/src/common/common_funcs.h
@@ -55,6 +55,38 @@ __declspec(dllimport) void __stdcall DebugBreak(void);
// Defined in Misc.cpp.
std::string GetLastErrorMsg();
+#define DECLARE_ENUM_FLAG_OPERATORS(type) \
+ constexpr type operator|(type a, type b) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ return static_cast<type>(static_cast<T>(a) | static_cast<T>(b)); \
+ } \
+ constexpr type operator&(type a, type b) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ return static_cast<type>(static_cast<T>(a) & static_cast<T>(b)); \
+ } \
+ constexpr type& operator|=(type& a, type b) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ a = static_cast<type>(static_cast<T>(a) | static_cast<T>(b)); \
+ return a; \
+ } \
+ constexpr type& operator&=(type& a, type b) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ a = static_cast<type>(static_cast<T>(a) & static_cast<T>(b)); \
+ return a; \
+ } \
+ constexpr type operator~(type key) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ return static_cast<type>(~static_cast<T>(key)); \
+ } \
+ constexpr bool True(type key) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ return static_cast<T>(key) != 0; \
+ } \
+ constexpr bool False(type key) noexcept { \
+ using T = std::underlying_type_t<type>; \
+ return static_cast<T>(key) == 0; \
+ }
+
namespace Common {
constexpr u32 MakeMagic(char a, char b, char c, char d) {