mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Some cleanup in /Common
This commit is contained in:
parent
995da23425
commit
215abfb951
13 changed files with 63 additions and 97 deletions
|
@ -24,6 +24,8 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "Common.h"
|
||||
#include "MsgHandler.h"
|
||||
|
||||
// TODO: Check if Pandora still needs signal.h/kill here. Symbian doesn't.
|
||||
|
||||
// VCVT flags
|
||||
|
|
|
@ -150,7 +150,7 @@ void PointerWrap::DoMarker(const char *prevName, u32 arbitraryNumber) {
|
|||
u32 cookie = arbitraryNumber;
|
||||
Do(cookie);
|
||||
if (mode == PointerWrap::MODE_READ && cookie != arbitraryNumber) {
|
||||
PanicAlertT("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
|
||||
PanicAlert("Error: After \"%s\", found %d (0x%X) instead of save marker %d (0x%X). Aborting savestate load...", prevName, cookie, cookie, arbitraryNumber, arbitraryNumber);
|
||||
SetError(ERROR_FAILURE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,6 @@ private:
|
|||
|
||||
#include "Log.h"
|
||||
#include "CommonTypes.h"
|
||||
#include "MsgHandler.h"
|
||||
#include "CommonFuncs.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
@ -70,7 +69,9 @@ private:
|
|||
#define STACKALIGN __attribute__((__force_align_arg_pointer__))
|
||||
#endif
|
||||
|
||||
#elif defined _WIN32
|
||||
#define CHECK_HEAP_INTEGRITY()
|
||||
|
||||
#elif defined(_WIN32)
|
||||
|
||||
// Check MSC ver
|
||||
#if !defined _MSC_VER || _MSC_VER <= 1000
|
||||
|
@ -93,12 +94,10 @@ private:
|
|||
#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
|
||||
#else
|
||||
|
||||
#define CHECK_HEAP_INTEGRITY()
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -126,11 +125,9 @@ private:
|
|||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define __strdup _strdup
|
||||
#define __getcwd _getcwd
|
||||
#define __chdir _chdir
|
||||
#else
|
||||
#define __strdup strdup
|
||||
#define __getcwd getcwd
|
||||
#define __chdir chdir
|
||||
#endif
|
||||
|
@ -151,52 +148,6 @@ private:
|
|||
# define _M_SSE 0x402
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _XBOX
|
||||
inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
|
||||
inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
|
||||
inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); }
|
||||
#else
|
||||
inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); }
|
||||
inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); }
|
||||
inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); }
|
||||
#endif
|
||||
#else
|
||||
// TODO: speedup
|
||||
inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
|
||||
inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24);}
|
||||
inline unsigned long long bswap64(unsigned long long x) {return ((unsigned long long)bswap32(x) << 32) | bswap32(x >> 32); }
|
||||
#endif
|
||||
|
||||
inline float bswapf( float f )
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
unsigned int u32;
|
||||
} dat1, dat2;
|
||||
|
||||
dat1.f = f;
|
||||
dat2.u32 = bswap32(dat1.u32);
|
||||
|
||||
return dat2.f;
|
||||
}
|
||||
|
||||
inline double bswapd( double f )
|
||||
{
|
||||
union
|
||||
{
|
||||
double f;
|
||||
unsigned long long u64;
|
||||
} dat1, dat2;
|
||||
|
||||
dat1.f = f;
|
||||
dat2.u64 = bswap64(dat1.u64);
|
||||
|
||||
return dat2.f;
|
||||
}
|
||||
|
||||
#include "Swap.h"
|
||||
|
||||
#endif // _COMMON_H_
|
||||
|
|
|
@ -258,4 +258,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -76,4 +76,4 @@
|
|||
<UniqueIdentifier>{1b593f03-7b28-4707-9228-4981796f5589}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "base/compat.h"
|
||||
|
||||
#if defined(IOS) || defined(MIPS)
|
||||
#include <signal.h>
|
||||
|
@ -30,17 +31,13 @@ template<> struct CompileTimeAssert<true> {};
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
// go to debugger mode
|
||||
#ifdef GEKKO
|
||||
#define Crash()
|
||||
#else
|
||||
// Assume !ARM && !MIPS = x86
|
||||
#if !defined(ARM) && !defined(MIPS)
|
||||
#define Crash() {asm ("int $3");}
|
||||
#else
|
||||
#define Crash() {kill( getpid(), SIGINT ) ; }
|
||||
#endif
|
||||
#define Crash() {kill(getpid(), SIGINT);}
|
||||
#endif
|
||||
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
|
||||
inline u32 __rotl(u32 x, int shift) {
|
||||
|
@ -66,12 +63,11 @@ inline u64 __rotr64(u64 x, unsigned int shift){
|
|||
}
|
||||
|
||||
#else // WIN32
|
||||
|
||||
// Function Cross-Compatibility
|
||||
#define strcasecmp _stricmp
|
||||
#define strncasecmp _strnicmp
|
||||
#define unlink _unlink
|
||||
#define snprintf _snprintf
|
||||
#define vscprintf _vscprintf
|
||||
#define __rotl _rotl
|
||||
#define __rotl64 _rotl64
|
||||
#define __rotr _rotr
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "MsgHandler.h"
|
||||
|
||||
#ifdef __arm__
|
||||
#if !defined(ARM)
|
||||
#define ARM
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
#define _MSGHANDLER_H_
|
||||
|
||||
// Message alerts
|
||||
enum MSG_TYPE
|
||||
{
|
||||
enum MSG_TYPE {
|
||||
INFORMATION,
|
||||
QUESTION,
|
||||
WARNING,
|
||||
|
@ -36,42 +35,16 @@ void SetEnableAlert(bool enable);
|
|||
|
||||
#ifndef GEKKO
|
||||
#ifdef _WIN32
|
||||
#define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)
|
||||
#define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)
|
||||
// Use these macros (that do the same thing) if the message should be translated.
|
||||
#define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, __VA_ARGS__)
|
||||
#define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, __VA_ARGS__)
|
||||
#define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, __VA_ARGS__)
|
||||
#define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, __VA_ARGS__)
|
||||
#define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, __VA_ARGS__)
|
||||
#else
|
||||
#define SuccessAlert(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)
|
||||
#define PanicAlert(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)
|
||||
#define PanicYesNo(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)
|
||||
#define AskYesNo(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
|
||||
#define CriticalAlert(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
|
||||
// Use these macros (that do the same thing) if the message should be translated.
|
||||
#define SuccessAlertT(format, ...) MsgAlert(false, INFORMATION, format, ##__VA_ARGS__)
|
||||
#define PanicAlertT(format, ...) MsgAlert(false, WARNING, format, ##__VA_ARGS__)
|
||||
#define PanicYesNoT(format, ...) MsgAlert(true, WARNING, format, ##__VA_ARGS__)
|
||||
#define AskYesNoT(format, ...) MsgAlert(true, QUESTION, format, ##__VA_ARGS__)
|
||||
#define CriticalAlertT(format, ...) MsgAlert(false, CRITICAL, format, ##__VA_ARGS__)
|
||||
#endif
|
||||
#else
|
||||
// GEKKO
|
||||
#define SuccessAlert(format, ...) ;
|
||||
#define PanicAlert(format, ...) ;
|
||||
#define PanicYesNo(format, ...) ;
|
||||
#define AskYesNo(format, ...) ;
|
||||
#define CriticalAlert(format, ...) ;
|
||||
#define SuccessAlertT(format, ...) ;
|
||||
#define PanicAlertT(format, ...) ;
|
||||
#define PanicYesNoT(format, ...) ;
|
||||
#define AskYesNoT(format, ...) ;
|
||||
#define CriticalAlertT(format, ...) ;
|
||||
#endif
|
||||
|
||||
#endif // _MSGHANDLER_H_
|
||||
|
|
|
@ -61,6 +61,47 @@
|
|||
#define COMMON_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#ifndef _XBOX
|
||||
inline unsigned long long bswap64(unsigned long long x) { return _byteswap_uint64(x); }
|
||||
inline unsigned int bswap32(unsigned int x) { return _byteswap_ulong(x); }
|
||||
inline unsigned short bswap16(unsigned short x) { return _byteswap_ushort(x); }
|
||||
#else
|
||||
inline unsigned long long bswap64(unsigned long long x) { return __loaddoublewordbytereverse(0, &x); }
|
||||
inline unsigned int bswap32(unsigned int x) { return __loadwordbytereverse(0, &x); }
|
||||
inline unsigned short bswap16(unsigned short x) { return __loadshortbytereverse(0, &x); }
|
||||
#endif
|
||||
#else
|
||||
// TODO: speedup
|
||||
inline unsigned short bswap16(unsigned short x) { return (x << 8) | (x >> 8); }
|
||||
inline unsigned int bswap32(unsigned int x) { return (x >> 24) | ((x & 0xFF0000) >> 8) | ((x & 0xFF00) << 8) | (x << 24); }
|
||||
inline unsigned long long bswap64(unsigned long long x) { return ((unsigned long long)bswap32(x) << 32) | bswap32(x >> 32); }
|
||||
#endif
|
||||
|
||||
inline float bswapf(float f) {
|
||||
union {
|
||||
float f;
|
||||
unsigned int u32;
|
||||
} dat1, dat2;
|
||||
|
||||
dat1.f = f;
|
||||
dat2.u32 = bswap32(dat1.u32);
|
||||
|
||||
return dat2.f;
|
||||
}
|
||||
|
||||
inline double bswapd(double f) {
|
||||
union {
|
||||
double f;
|
||||
unsigned long long u64;
|
||||
} dat1, dat2;
|
||||
|
||||
dat1.f = f;
|
||||
dat2.u64 = bswap64(dat1.u64);
|
||||
|
||||
return dat2.f;
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
struct swap_struct_t {
|
||||
typedef swap_struct_t<T, F> swapped_t;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "ABI.h"
|
||||
#include "CPUDetect.h"
|
||||
#include "MemoryUtil.h"
|
||||
#include "MsgHandler.h"
|
||||
|
||||
namespace Gen
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@ SOURCES += $$P/native/audio/*.cpp \
|
|||
$$P/native/base/backtrace.cpp \
|
||||
$$P/native/base/buffer.cpp \
|
||||
$$P/native/base/colorutil.cpp \
|
||||
$$P/native/base/compat.cpp \
|
||||
$$P/native/base/display.cpp \
|
||||
$$P/native/base/error_context.cpp \
|
||||
$$P/native/base/fastlist_test.cpp \
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include "ui_atlas.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#pragma execution_character_set("utf-8")
|
||||
#endif
|
||||
|
||||
|
|
2
native
2
native
|
@ -1 +1 @@
|
|||
Subproject commit 8e38e177b4a7573bf21c65c00ef8bf684493995b
|
||||
Subproject commit ef3912f63f5bbb4738cc6fa6949e25197626e5c5
|
Loading…
Add table
Reference in a new issue