Misc cleanup of common and related functions
This commit is contained in:
parent
302f0b32f5
commit
4fb75d220a
|
@ -39,9 +39,7 @@ private:
|
|||
#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,25 +56,6 @@ 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
|
||||
|
@ -108,10 +84,6 @@ private:
|
|||
#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)
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/math_util.h"
|
||||
#include "common/thread_queue_list.h"
|
||||
|
||||
#include "core/arm/arm_interface.h"
|
||||
|
@ -339,7 +340,7 @@ static void DebugThreadQueue() {
|
|||
ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority,
|
||||
u32 arg, s32 processor_id, VAddr stack_top) {
|
||||
if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) {
|
||||
s32 new_priority = CLAMP(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
|
||||
s32 new_priority = MathUtil::Clamp<s32>(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
|
||||
LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
|
||||
name.c_str(), priority, new_priority);
|
||||
// TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm
|
||||
|
@ -387,7 +388,7 @@ static void ClampPriority(const Thread* thread, s32* priority) {
|
|||
if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) {
|
||||
DEBUG_ASSERT_MSG(false, "Application passed an out of range priority. An error should be returned.");
|
||||
|
||||
s32 new_priority = CLAMP(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
|
||||
s32 new_priority = MathUtil::Clamp<s32>(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST);
|
||||
LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d",
|
||||
thread->name.c_str(), *priority, new_priority);
|
||||
// TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm
|
||||
|
|
Loading…
Reference in New Issue