diff options
Diffstat (limited to 'src/common/common_funcs.h')
| -rw-r--r-- | src/common/common_funcs.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 367b6bf6e..75f3027fb 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -24,10 +24,10 @@ | |||
| 24 | #define INSERT_PADDING_WORDS(num_words) \ | 24 | #define INSERT_PADDING_WORDS(num_words) \ |
| 25 | std::array<u32, num_words> CONCAT2(pad, __LINE__) {} | 25 | std::array<u32, num_words> CONCAT2(pad, __LINE__) {} |
| 26 | 26 | ||
| 27 | /// These are similar to the INSERT_PADDING_* macros, but are needed for padding unions. This is | 27 | /// These are similar to the INSERT_PADDING_* macros but do not zero-initialize the contents. |
| 28 | /// because unions can only be initialized by one member. | 28 | /// This keeps the structure trivial to construct. |
| 29 | #define INSERT_UNION_PADDING_BYTES(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__) | 29 | #define INSERT_PADDING_BYTES_NOINIT(num_bytes) std::array<u8, num_bytes> CONCAT2(pad, __LINE__) |
| 30 | #define INSERT_UNION_PADDING_WORDS(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__) | 30 | #define INSERT_PADDING_WORDS_NOINIT(num_words) std::array<u32, num_words> CONCAT2(pad, __LINE__) |
| 31 | 31 | ||
| 32 | #ifndef _MSC_VER | 32 | #ifndef _MSC_VER |
| 33 | 33 | ||
| @@ -93,6 +93,14 @@ __declspec(dllimport) void __stdcall DebugBreak(void); | |||
| 93 | return static_cast<T>(key) == 0; \ | 93 | return static_cast<T>(key) == 0; \ |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /// Evaluates a boolean expression, and returns a result unless that expression is true. | ||
| 97 | #define R_UNLESS(expr, res) \ | ||
| 98 | { \ | ||
| 99 | if (!(expr)) { \ | ||
| 100 | return res; \ | ||
| 101 | } \ | ||
| 102 | } | ||
| 103 | |||
| 96 | namespace Common { | 104 | namespace Common { |
| 97 | 105 | ||
| 98 | [[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) { | 106 | [[nodiscard]] constexpr u32 MakeMagic(char a, char b, char c, char d) { |