diff options
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 @@ #if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM) #include <cstdlib> // for exit #endif - #include "common_types.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor. #define CONCAT2(x, y) DO_CONCAT2(x, y) -#define DO_CONCAT2(x, y) x ## y +#define DO_CONCAT2(x, y) x##y // helper macro to properly align structure members. // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", @@ -24,9 +23,9 @@ // Inlining #ifdef _WIN32 - #define FORCE_INLINE __forceinline +#define FORCE_INLINE __forceinline #else - #define FORCE_INLINE inline __attribute__((always_inline)) +#define FORCE_INLINE inline __attribute__((always_inline)) #endif #ifndef _MSC_VER @@ -46,7 +45,8 @@ #else inline u32 rotl(u32 x, int shift) { shift &= 31; - if (!shift) return x; + if (!shift) + return x; return (x << shift) | (x >> (32 - shift)); } #endif @@ -56,17 +56,18 @@ inline u32 rotl(u32 x, int shift) { #else inline u32 rotr(u32 x, int shift) { shift &= 31; - if (!shift) return x; + if (!shift) + return x; return (x >> shift) | (x << (32 - shift)); } #endif -inline u64 _rotl64(u64 x, unsigned int shift){ +inline u64 _rotl64(u64 x, unsigned int shift) { unsigned int n = shift % 64; return (x << n) | (x >> (64 - n)); } -inline u64 _rotr64(u64 x, unsigned int shift){ +inline u64 _rotr64(u64 x, unsigned int shift) { unsigned int n = shift % 64; return (x >> n) | (x << (64 - n)); } @@ -74,17 +75,17 @@ inline u64 _rotr64(u64 x, unsigned int shift){ #else // _MSC_VER #if (_MSC_VER < 1900) - // Function Cross-Compatibility - #define snprintf _snprintf +// Function Cross-Compatibility +#define snprintf _snprintf #endif // Locale Cross-Compatibility #define locale_t _locale_t extern "C" { - __declspec(dllimport) void __stdcall DebugBreak(void); +__declspec(dllimport) void __stdcall DebugBreak(void); } -#define Crash() {DebugBreak();} +#define Crash() DebugBreak() // cstdlib provides these on MSVC #define rotr _rotr |