diff options
| author | 2016-09-21 11:29:48 -0700 | |
|---|---|---|
| committer | 2016-09-21 11:29:48 -0700 | |
| commit | d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a (patch) | |
| tree | 8a22ca73ff838f3f0090b29a548ae81087fc90ed /src/common/common_funcs.h | |
| parent | README: Specify master branch for Travis CI badge (diff) | |
| parent | Fix Travis clang-format check (diff) | |
| download | yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.gz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.tar.xz yuzu-d5d2ca8058a0f1c00ab7ca9fe2c058ba47546c0a.zip | |
Merge pull request #2086 from linkmauve/clang-format
Add clang-format as part of our {commit,travis}-time checks
Diffstat (limited to 'src/common/common_funcs.h')
| -rw-r--r-- | src/common/common_funcs.h | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 4633897ce..b141e79ed 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -7,14 +7,13 @@ | |||
| 7 | #if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM) | 7 | #if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM) |
| 8 | #include <cstdlib> // for exit | 8 | #include <cstdlib> // for exit |
| 9 | #endif | 9 | #endif |
| 10 | |||
| 11 | #include "common_types.h" | 10 | #include "common_types.h" |
| 12 | 11 | ||
| 13 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) | 12 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 14 | 13 | ||
| 15 | /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor. | 14 | /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor. |
| 16 | #define CONCAT2(x, y) DO_CONCAT2(x, y) | 15 | #define CONCAT2(x, y) DO_CONCAT2(x, y) |
| 17 | #define DO_CONCAT2(x, y) x ## y | 16 | #define DO_CONCAT2(x, y) x##y |
| 18 | 17 | ||
| 19 | // helper macro to properly align structure members. | 18 | // helper macro to properly align structure members. |
| 20 | // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", | 19 | // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", |
| @@ -24,9 +23,9 @@ | |||
| 24 | 23 | ||
| 25 | // Inlining | 24 | // Inlining |
| 26 | #ifdef _WIN32 | 25 | #ifdef _WIN32 |
| 27 | #define FORCE_INLINE __forceinline | 26 | #define FORCE_INLINE __forceinline |
| 28 | #else | 27 | #else |
| 29 | #define FORCE_INLINE inline __attribute__((always_inline)) | 28 | #define FORCE_INLINE inline __attribute__((always_inline)) |
| 30 | #endif | 29 | #endif |
| 31 | 30 | ||
| 32 | #ifndef _MSC_VER | 31 | #ifndef _MSC_VER |
| @@ -46,7 +45,8 @@ | |||
| 46 | #else | 45 | #else |
| 47 | inline u32 rotl(u32 x, int shift) { | 46 | inline u32 rotl(u32 x, int shift) { |
| 48 | shift &= 31; | 47 | shift &= 31; |
| 49 | if (!shift) return x; | 48 | if (!shift) |
| 49 | return x; | ||
| 50 | return (x << shift) | (x >> (32 - shift)); | 50 | return (x << shift) | (x >> (32 - shift)); |
| 51 | } | 51 | } |
| 52 | #endif | 52 | #endif |
| @@ -56,17 +56,18 @@ inline u32 rotl(u32 x, int shift) { | |||
| 56 | #else | 56 | #else |
| 57 | inline u32 rotr(u32 x, int shift) { | 57 | inline u32 rotr(u32 x, int shift) { |
| 58 | shift &= 31; | 58 | shift &= 31; |
| 59 | if (!shift) return x; | 59 | if (!shift) |
| 60 | return x; | ||
| 60 | return (x >> shift) | (x << (32 - shift)); | 61 | return (x >> shift) | (x << (32 - shift)); |
| 61 | } | 62 | } |
| 62 | #endif | 63 | #endif |
| 63 | 64 | ||
| 64 | inline u64 _rotl64(u64 x, unsigned int shift){ | 65 | inline u64 _rotl64(u64 x, unsigned int shift) { |
| 65 | unsigned int n = shift % 64; | 66 | unsigned int n = shift % 64; |
| 66 | return (x << n) | (x >> (64 - n)); | 67 | return (x << n) | (x >> (64 - n)); |
| 67 | } | 68 | } |
| 68 | 69 | ||
| 69 | inline u64 _rotr64(u64 x, unsigned int shift){ | 70 | inline u64 _rotr64(u64 x, unsigned int shift) { |
| 70 | unsigned int n = shift % 64; | 71 | unsigned int n = shift % 64; |
| 71 | return (x >> n) | (x << (64 - n)); | 72 | return (x >> n) | (x << (64 - n)); |
| 72 | } | 73 | } |
| @@ -74,17 +75,17 @@ inline u64 _rotr64(u64 x, unsigned int shift){ | |||
| 74 | #else // _MSC_VER | 75 | #else // _MSC_VER |
| 75 | 76 | ||
| 76 | #if (_MSC_VER < 1900) | 77 | #if (_MSC_VER < 1900) |
| 77 | // Function Cross-Compatibility | 78 | // Function Cross-Compatibility |
| 78 | #define snprintf _snprintf | 79 | #define snprintf _snprintf |
| 79 | #endif | 80 | #endif |
| 80 | 81 | ||
| 81 | // Locale Cross-Compatibility | 82 | // Locale Cross-Compatibility |
| 82 | #define locale_t _locale_t | 83 | #define locale_t _locale_t |
| 83 | 84 | ||
| 84 | extern "C" { | 85 | extern "C" { |
| 85 | __declspec(dllimport) void __stdcall DebugBreak(void); | 86 | __declspec(dllimport) void __stdcall DebugBreak(void); |
| 86 | } | 87 | } |
| 87 | #define Crash() {DebugBreak();} | 88 | #define Crash() DebugBreak() |
| 88 | 89 | ||
| 89 | // cstdlib provides these on MSVC | 90 | // cstdlib provides these on MSVC |
| 90 | #define rotr _rotr | 91 | #define rotr _rotr |