mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Misc cleanup of common and related functions
This commit is contained in:
		
							parent
							
								
									302f0b32f5
								
							
						
					
					
						commit
						4fb75d220a
					
				
					 4 changed files with 31 additions and 81 deletions
				
			
		|  | @ -35,13 +35,11 @@ private: | |||
| #ifdef __APPLE__ | ||||
| // The Darwin ABI requires that stack frames be aligned to 16-byte boundaries.
 | ||||
| // This is only needed on i386 gcc - x86_64 already aligns to 16 bytes.
 | ||||
| #if defined __i386__ && defined __GNUC__ | ||||
| #undef STACKALIGN | ||||
| #define STACKALIGN __attribute__((__force_align_arg_pointer__)) | ||||
| #endif | ||||
| 
 | ||||
|     #if defined __i386__ && defined __GNUC__ | ||||
|         #undef STACKALIGN | ||||
|         #define STACKALIGN __attribute__((__force_align_arg_pointer__)) | ||||
|     #endif | ||||
| #elif defined _WIN32 | ||||
| 
 | ||||
| // Check MSC ver
 | ||||
|     #if defined _MSC_VER && _MSC_VER <= 1000 | ||||
|         #error needs at least version 1000 of MSC | ||||
|  | @ -51,9 +49,6 @@ private: | |||
|     #define NOMINMAX | ||||
|     #endif | ||||
| 
 | ||||
| // Memory leak checks
 | ||||
|     #define CHECK_HEAP_INTEGRITY() | ||||
| 
 | ||||
| // Alignment
 | ||||
|     #define MEMORY_ALIGNED16(x) __declspec(align(16)) x | ||||
|     #define MEMORY_ALIGNED32(x) __declspec(align(32)) x | ||||
|  | @ -61,57 +56,34 @@ private: | |||
|     #define MEMORY_ALIGNED128(x) __declspec(align(128)) x | ||||
|     #define MEMORY_ALIGNED16_DECL(x) __declspec(align(16)) x | ||||
|     #define MEMORY_ALIGNED64_DECL(x) __declspec(align(64)) x | ||||
| 
 | ||||
| // Since they are always around on windows
 | ||||
|     #define HAVE_WX 1 | ||||
|     #define HAVE_OPENAL 1 | ||||
| 
 | ||||
|     #define HAVE_PORTAUDIO 1 | ||||
| 
 | ||||
| // Debug definitions
 | ||||
|     #if defined(_DEBUG) | ||||
|         #include <crtdbg.h> | ||||
|         #undef CHECK_HEAP_INTEGRITY | ||||
|         #define CHECK_HEAP_INTEGRITY() {if (!_CrtCheckMemory()) PanicAlert("memory corruption detected. see log.");} | ||||
|         // If you want to see how much a pain in the ass singletons are, for example:
 | ||||
|         // {614} normal block at 0x030C5310, 188 bytes long.
 | ||||
|         // Data: <Master Log      > 4D 61 73 74 65 72 20 4C 6F 67 00 00 00 00 00 00
 | ||||
|         struct CrtDebugBreak { CrtDebugBreak(int spot) { _CrtSetBreakAlloc(spot); } }; | ||||
|         //CrtDebugBreak breakAt(614);
 | ||||
|     #endif // end DEBUG/FAST
 | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| // Windows compatibility
 | ||||
| #ifndef _WIN32 | ||||
| #ifdef _LP64 | ||||
| #define _M_X64 1 | ||||
| #else | ||||
| #define _M_IX86 1 | ||||
| #endif | ||||
| #define __forceinline inline __attribute__((always_inline)) | ||||
| #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x | ||||
| #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x | ||||
| #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x | ||||
| #define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x | ||||
| #define MEMORY_ALIGNED16_DECL(x) __attribute__((aligned(16))) x | ||||
| #define MEMORY_ALIGNED64_DECL(x) __attribute__((aligned(64))) x | ||||
|     #ifdef _LP64 | ||||
|         #define _M_X64 1 | ||||
|     #else | ||||
|         #define _M_IX86 1 | ||||
|     #endif | ||||
|     #define __forceinline inline __attribute__((always_inline)) | ||||
|     #define MEMORY_ALIGNED16(x) __attribute__((aligned(16))) x | ||||
|     #define MEMORY_ALIGNED32(x) __attribute__((aligned(32))) x | ||||
|     #define MEMORY_ALIGNED64(x) __attribute__((aligned(64))) x | ||||
|     #define MEMORY_ALIGNED128(x) __attribute__((aligned(128))) x | ||||
|     #define MEMORY_ALIGNED16_DECL(x) __attribute__((aligned(16))) x | ||||
|     #define MEMORY_ALIGNED64_DECL(x) __attribute__((aligned(64))) x | ||||
| #endif | ||||
| 
 | ||||
| #ifdef _MSC_VER | ||||
| #define __strdup _strdup | ||||
| #define __getcwd _getcwd | ||||
| #define __chdir _chdir | ||||
|     #define __strdup _strdup | ||||
|     #define __getcwd _getcwd | ||||
|     #define __chdir _chdir | ||||
| #else | ||||
| #define __strdup strdup | ||||
| #define __getcwd getcwd | ||||
| #define __chdir chdir | ||||
|     #define __strdup strdup | ||||
|     #define __getcwd getcwd | ||||
|     #define __chdir chdir | ||||
| #endif | ||||
| 
 | ||||
| // Dummy macro for marking translatable strings that can not be immediately translated.
 | ||||
| // wxWidgets does not have a true dummy macro for this.
 | ||||
| #define _trans(a) a | ||||
| 
 | ||||
| #if defined _M_GENERIC | ||||
| #  define _M_SSE 0x0 | ||||
| #elif defined __GNUC__ | ||||
|  |  | |||
|  | @ -24,11 +24,6 @@ template<> struct CompileTimeAssert<true> {}; | |||
| #define b32(x)  (b16(x) | (b16(x) >>16) ) | ||||
| #define ROUND_UP_POW2(x)    (b32(x - 1) + 1) | ||||
| 
 | ||||
| #define MIN(a, b)   ((a)<(b)?(a):(b)) | ||||
| #define MAX(a, b)   ((a)>(b)?(a):(b)) | ||||
| 
 | ||||
| #define CLAMP(x, min, max)  (((x) > max) ? max : (((x) < min) ? min : (x))) | ||||
| 
 | ||||
| #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) | ||||
| 
 | ||||
| /// Textually concatenates two tokens. The double-expansion is required by the C preprocessor.
 | ||||
|  | @ -147,15 +142,6 @@ inline u64 _rotr64(u64 x, unsigned int shift){ | |||
|     #define Crash() {DebugBreak();} | ||||
| #endif // _MSC_VER ndef
 | ||||
| 
 | ||||
| // Dolphin's min and max functions
 | ||||
| #undef min | ||||
| #undef max | ||||
| 
 | ||||
| template<class T> | ||||
| inline T min(const T& a, const T& b) {return a > b ? b : a;} | ||||
| template<class T> | ||||
| inline T max(const T& a, const T& b) {return a > b ? a : b;} | ||||
| 
 | ||||
| // Generic function to get last error message.
 | ||||
| // Call directly after the command or use the error num.
 | ||||
| // This function might change the error code.
 | ||||
|  | @ -232,13 +218,4 @@ inline void swap<8>(u8* data) | |||
|     *reinterpret_cast<u64*>(data) = swap64(data); | ||||
| } | ||||
| 
 | ||||
| template <typename T> | ||||
| inline T FromBigEndian(T data) | ||||
| { | ||||
|     //static_assert(std::is_arithmetic<T>::value, "function only makes sense with arithmetic types");
 | ||||
| 
 | ||||
|     swap<sizeof(data)>(reinterpret_cast<u8*>(&data)); | ||||
|     return data; | ||||
| } | ||||
| 
 | ||||
| }  // Namespace Common
 | ||||
|  |  | |||
|  | @ -156,7 +156,7 @@ u64 GetMurmurHash3(const u8 *src, int len, u32 samples) | |||
|     const u8 * data = (const u8*)src; | ||||
|     const int nblocks = len / 16; | ||||
|     u32 Step = (len / 8); | ||||
|     if(samples == 0) samples = max(Step, 1u); | ||||
|     if(samples == 0) samples = std::max(Step, 1u); | ||||
|     Step = Step / samples; | ||||
|     if(Step < 1) Step = 1; | ||||
| 
 | ||||
|  | @ -234,7 +234,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples) | |||
|     u32 Step = (len / 8); | ||||
|     const u64 *data = (const u64 *)src; | ||||
|     const u64 *end = data + Step; | ||||
|     if(samples == 0) samples = max(Step, 1u); | ||||
|     if(samples == 0) samples = std::max(Step, 1u); | ||||
|     Step = Step / samples; | ||||
|     if(Step < 1) Step = 1; | ||||
|     while(data < end) | ||||
|  | @ -266,7 +266,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples) | |||
|     u32 Step = (len / 8); | ||||
|     const u64 *data = (const u64 *)src; | ||||
|     const u64 *end = data + Step; | ||||
|     if(samples == 0) samples = max(Step, 1u); | ||||
|     if(samples == 0) samples = std::max(Step, 1u); | ||||
|     Step = Step / samples; | ||||
|     if(Step < 1) Step = 1; | ||||
|     while(data < end) | ||||
|  | @ -309,7 +309,7 @@ u64 GetCRC32(const u8 *src, int len, u32 samples) | |||
|     u32 Step = (len/4); | ||||
|     const u32 *data = (const u32 *)src; | ||||
|     const u32 *end = data + Step; | ||||
|     if(samples == 0) samples = max(Step, 1u); | ||||
|     if(samples == 0) samples = std::max(Step, 1u); | ||||
|     Step  = Step / samples; | ||||
|     if(Step < 1) Step = 1; | ||||
|     while(data < end) | ||||
|  | @ -381,7 +381,7 @@ u64 GetMurmurHash3(const u8* src, int len, u32 samples) | |||
|     u32 out[2]; | ||||
|     const int nblocks = len / 8; | ||||
|     u32 Step = (len / 4); | ||||
|     if(samples == 0) samples = max(Step, 1u); | ||||
|     if(samples == 0) samples = std::max(Step, 1u); | ||||
|     Step = Step / samples; | ||||
|     if(Step < 1) Step = 1; | ||||
| 
 | ||||
|  | @ -457,7 +457,7 @@ u64 GetHashHiresTexture(const u8 *src, int len, u32 samples) | |||
|     u32 Step = (len / 8); | ||||
|     const u64 *data = (const u64 *)src; | ||||
|     const u64 *end = data + Step; | ||||
|     if(samples == 0) samples = max(Step, 1u); | ||||
|     if(samples == 0) samples = std::max(Step, 1u); | ||||
|     Step = Step / samples; | ||||
|     if(Step < 1) Step = 1; | ||||
|     while(data < end) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue