diff options
| author | 2015-02-20 11:41:30 -0500 | |
|---|---|---|
| committer | 2015-02-20 11:41:30 -0500 | |
| commit | 5f9939070e81691e04facca9ff431070988e5b05 (patch) | |
| tree | 9bd54cdde2c34dd2f63e0396260335f267a46ce1 /src/common/common_funcs.h | |
| parent | Merge pull request #587 from archshift/assert (diff) | |
| parent | Misc cleanup of common and related functions (diff) | |
| download | yuzu-5f9939070e81691e04facca9ff431070988e5b05.tar.gz yuzu-5f9939070e81691e04facca9ff431070988e5b05.tar.xz yuzu-5f9939070e81691e04facca9ff431070988e5b05.zip | |
Merge pull request #588 from archshift/somebranch
Sweeping cleanup of Common
Diffstat (limited to 'src/common/common_funcs.h')
| -rw-r--r-- | src/common/common_funcs.h | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index 4bbcc3571..bc296ed3e 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h | |||
| @@ -24,11 +24,6 @@ template<> struct CompileTimeAssert<true> {}; | |||
| 24 | #define b32(x) (b16(x) | (b16(x) >>16) ) | 24 | #define b32(x) (b16(x) | (b16(x) >>16) ) |
| 25 | #define ROUND_UP_POW2(x) (b32(x - 1) + 1) | 25 | #define ROUND_UP_POW2(x) (b32(x - 1) + 1) |
| 26 | 26 | ||
| 27 | #define MIN(a, b) ((a)<(b)?(a):(b)) | ||
| 28 | #define MAX(a, b) ((a)>(b)?(a):(b)) | ||
| 29 | |||
| 30 | #define CLAMP(x, min, max) (((x) > max) ? max : (((x) < min) ? min : (x))) | ||
| 31 | |||
| 32 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) | 27 | #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) |
| 33 | 28 | ||
| 34 | /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor. | 29 | /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor. |
| @@ -38,9 +33,8 @@ template<> struct CompileTimeAssert<true> {}; | |||
| 38 | // helper macro to properly align structure members. | 33 | // helper macro to properly align structure members. |
| 39 | // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", | 34 | // Calling INSERT_PADDING_BYTES will add a new member variable with a name like "pad121", |
| 40 | // depending on the current source line to make sure variable names are unique. | 35 | // depending on the current source line to make sure variable names are unique. |
| 41 | #define INSERT_PADDING_BYTES_HELPER1(x, y) x ## y | 36 | #define INSERT_PADDING_BYTES(num_bytes) u8 CONCAT2(pad, __LINE__)[(num_bytes)] |
| 42 | #define INSERT_PADDING_BYTES_HELPER2(x, y) INSERT_PADDING_BYTES_HELPER1(x, y) | 37 | #define INSERT_PADDING_WORDS(num_words) u32 CONCAT2(pad, __LINE__)[(num_words)] |
| 43 | #define INSERT_PADDING_BYTES(num_words) u8 INSERT_PADDING_BYTES_HELPER2(pad, __LINE__)[(num_words)] | ||
| 44 | 38 | ||
| 45 | #ifndef _MSC_VER | 39 | #ifndef _MSC_VER |
| 46 | 40 | ||
| @@ -148,15 +142,6 @@ inline u64 _rotr64(u64 x, unsigned int shift){ | |||
| 148 | #define Crash() {DebugBreak();} | 142 | #define Crash() {DebugBreak();} |
| 149 | #endif // _MSC_VER ndef | 143 | #endif // _MSC_VER ndef |
| 150 | 144 | ||
| 151 | // Dolphin's min and max functions | ||
| 152 | #undef min | ||
| 153 | #undef max | ||
| 154 | |||
| 155 | template<class T> | ||
| 156 | inline T min(const T& a, const T& b) {return a > b ? b : a;} | ||
| 157 | template<class T> | ||
| 158 | inline T max(const T& a, const T& b) {return a > b ? a : b;} | ||
| 159 | |||
| 160 | // Generic function to get last error message. | 145 | // Generic function to get last error message. |
| 161 | // Call directly after the command or use the error num. | 146 | // Call directly after the command or use the error num. |
| 162 | // This function might change the error code. | 147 | // This function might change the error code. |
| @@ -233,13 +218,4 @@ inline void swap<8>(u8* data) | |||
| 233 | *reinterpret_cast<u64*>(data) = swap64(data); | 218 | *reinterpret_cast<u64*>(data) = swap64(data); |
| 234 | } | 219 | } |
| 235 | 220 | ||
| 236 | template <typename T> | ||
| 237 | inline T FromBigEndian(T data) | ||
| 238 | { | ||
| 239 | //static_assert(std::is_arithmetic<T>::value, "function only makes sense with arithmetic types"); | ||
| 240 | |||
| 241 | swap<sizeof(data)>(reinterpret_cast<u8*>(&data)); | ||
| 242 | return data; | ||
| 243 | } | ||
| 244 | |||
| 245 | } // Namespace Common | 221 | } // Namespace Common |