mirror of https://github.com/PCSX2/pcsx2.git
Remove some horrible old code.
Remove an assert define and instead use the static_assert that all compilers provide. As an added bonus, assert messages\!
This commit is contained in:
parent
c46749f236
commit
a3bc6a73a3
|
@ -66,21 +66,6 @@ extern "C" unsigned __int64 __xgetbv(int);
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// C_ASSERT
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// compile-time assertion; usable at static variable define level.
|
|
||||||
// (typically used to confirm the correct sizeof() for struct types where size
|
|
||||||
// restaints must be enforced).
|
|
||||||
//
|
|
||||||
#ifndef C_ASSERT
|
|
||||||
#ifdef __linux__
|
|
||||||
# define C_ASSERT(e) static_assert(e, "this is a nice message to explain the failure ;)")
|
|
||||||
#else
|
|
||||||
# define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// Dev / Debug conditionals - Consts for using if() statements instead of uglier #ifdef.
|
// Dev / Debug conditionals - Consts for using if() statements instead of uglier #ifdef.
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
@ -204,13 +189,10 @@ static const int __pagesize = PCSX2_PAGESIZE;
|
||||||
# define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
# define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
||||||
# define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x
|
# define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x
|
||||||
|
|
||||||
# define __naked __declspec(naked)
|
|
||||||
# define __noinline __declspec(noinline)
|
# define __noinline __declspec(noinline)
|
||||||
# define __threadlocal __declspec(thread)
|
# define __threadlocal __declspec(thread)
|
||||||
|
|
||||||
// Don't know if there are Visual C++ equivalents of these.
|
// Don't know if there are Visual C++ equivalents of these.
|
||||||
# define __hot
|
|
||||||
# define __cold
|
|
||||||
# define likely(x) (!!(x))
|
# define likely(x) (!!(x))
|
||||||
# define unlikely(x) (!!(x))
|
# define unlikely(x) (!!(x))
|
||||||
|
|
||||||
|
@ -234,7 +216,6 @@ static const int __pagesize = PCSX2_PAGESIZE;
|
||||||
# define PCSX2_ALIGNED_EXTERN(alig,x) extern x __attribute((aligned(alig)))
|
# define PCSX2_ALIGNED_EXTERN(alig,x) extern x __attribute((aligned(alig)))
|
||||||
# define PCSX2_ALIGNED16_EXTERN(x) extern x __attribute((aligned(16)))
|
# define PCSX2_ALIGNED16_EXTERN(x) extern x __attribute((aligned(16)))
|
||||||
|
|
||||||
# define __naked // GCC lacks the naked specifier
|
|
||||||
# define __assume(cond) ((void)0) // GCC has no equivalent for __assume
|
# define __assume(cond) ((void)0) // GCC has no equivalent for __assume
|
||||||
# define CALLBACK __attribute__((stdcall))
|
# define CALLBACK __attribute__((stdcall))
|
||||||
|
|
||||||
|
@ -250,46 +231,11 @@ static const int __pagesize = PCSX2_PAGESIZE;
|
||||||
# define __forceinline __attribute__((unused))
|
# define __forceinline __attribute__((unused))
|
||||||
# endif
|
# endif
|
||||||
# define __noinline __attribute__((noinline))
|
# define __noinline __attribute__((noinline))
|
||||||
# define __hot __attribute__((hot))
|
|
||||||
# define __cold __attribute__((cold))
|
|
||||||
# define __threadlocal __thread
|
# define __threadlocal __thread
|
||||||
# define likely(x) __builtin_expect(!!(x), 1)
|
# define likely(x) __builtin_expect(!!(x), 1)
|
||||||
# define unlikely(x) __builtin_expect(!!(x), 0)
|
# define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// GNU C/C++ Specific Defines
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
#ifdef __GNUC__
|
|
||||||
|
|
||||||
// GCC 4.4.0 is a bit nutty, as compilers go. it gets a define to itself.
|
|
||||||
# define GCC_VERSION ( __GNUC__ * 10000 \
|
|
||||||
+ __GNUC_MINOR__ * 100 \
|
|
||||||
+ __GNUC_PATCHLEVEL__)
|
|
||||||
|
|
||||||
// Test for GCC > 4.4.0; Should be adjusted when new versions come out
|
|
||||||
# if GCC_VERSION >= 40400
|
|
||||||
# define THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
|
||||||
# define __nooptimization __attribute__((optimize("O0")))
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// This theoretically unoptimizes. Not having much luck so far.
|
|
||||||
/*
|
|
||||||
# ifdef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
|
||||||
# pragma GCC optimize ("O0")
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# ifdef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
|
||||||
# pragma GCC reset_options
|
|
||||||
# endif
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endif // end GCC-specific section.
|
|
||||||
|
|
||||||
#ifndef THE_UNBEARABLE_LIGHTNESS_OF_BEING_GCC_4_4_0
|
|
||||||
# define __nooptimization // Pretty sure this is obsolete now, since we fixed __asm contraints and stuff. --air
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// __releaseinline / __ri -- a forceinline macro that is enabled for RELEASE/PUBLIC builds ONLY.
|
// __releaseinline / __ri -- a forceinline macro that is enabled for RELEASE/PUBLIC builds ONLY.
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -148,7 +148,7 @@
|
||||||
#else
|
#else
|
||||||
// Ensure the user's defined PS2E_THISPTR retains the correct signature for our
|
// Ensure the user's defined PS2E_THISPTR retains the correct signature for our
|
||||||
// plugin API.
|
// plugin API.
|
||||||
C_ASSERT( sizeof(PS2E_THISPTR) == sizeof(void*) );
|
static_assert( sizeof(PS2E_THISPTR) == sizeof(void*), "Incorrect signature for PS2E_THISPTR" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// PS2E_LIB_THISPTR - (library scope version of PS2E_THISPTR)
|
// PS2E_LIB_THISPTR - (library scope version of PS2E_THISPTR)
|
||||||
|
@ -157,7 +157,7 @@
|
||||||
#else
|
#else
|
||||||
// Ensure the user's defined PS2E_THISPTR retains the correct signature for our
|
// Ensure the user's defined PS2E_THISPTR retains the correct signature for our
|
||||||
// plugin API.
|
// plugin API.
|
||||||
C_ASSERT( sizeof(PS2E_LIB_THISPTR) == sizeof(void*) );
|
static_assert( sizeof(PS2E_LIB_THISPTR) == sizeof(void*), "Incorrect signature for PS2E_LIB_THISPTR" );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Use fastcall by default, since under most circumstances the object-model approach of the
|
// Use fastcall by default, since under most circumstances the object-model approach of the
|
||||||
|
|
|
@ -73,13 +73,13 @@ static __fi void memzero_sse_a( void* dest, const size_t size )
|
||||||
template< u8 data, typename T >
|
template< u8 data, typename T >
|
||||||
__noinline void memset_sse_a( T& dest )
|
__noinline void memset_sse_a( T& dest )
|
||||||
{
|
{
|
||||||
C_ASSERT( (sizeof(dest) & 0xf) == 0 );
|
static_assert( (sizeof(dest) & 0xf) == 0, "Bad size for SSE memset" );
|
||||||
memset_sse_a<data>( &dest, sizeof(dest) );
|
memset_sse_a<data>( &dest, sizeof(dest) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< typename T >
|
template< typename T >
|
||||||
void memzero_sse_a( T& dest )
|
void memzero_sse_a( T& dest )
|
||||||
{
|
{
|
||||||
C_ASSERT( (sizeof(dest) & 0xf) == 0 );
|
static_assert( (sizeof(dest) & 0xf) == 0, "Bad size for SSE memset" );
|
||||||
memset_sse_a<0>( &dest, sizeof(dest) );
|
memset_sse_a<0>( &dest, sizeof(dest) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,8 +16,6 @@
|
||||||
#ifndef PCSX2_PRECOMPILED_HEADER
|
#ifndef PCSX2_PRECOMPILED_HEADER
|
||||||
#define PCSX2_PRECOMPILED_HEADER
|
#define PCSX2_PRECOMPILED_HEADER
|
||||||
|
|
||||||
//#pragma once // no dice, causes problems in GCC PCH (which doesn't really work very well anyway)
|
|
||||||
|
|
||||||
// Disable some pointless warnings...
|
// Disable some pointless warnings...
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# pragma warning(disable:4250) //'class' inherits 'method' via dominance
|
# pragma warning(disable:4250) //'class' inherits 'method' via dominance
|
||||||
|
@ -99,7 +97,7 @@ typedef FnType_Void* Fnptr_Void;
|
||||||
# define strnicmp _strnicmp
|
# define strnicmp _strnicmp
|
||||||
# define stricmp _stricmp
|
# define stricmp _stricmp
|
||||||
|
|
||||||
#else // must be GCC...
|
#else // must be GCC or Clang
|
||||||
|
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
# include <sys/timeb.h>
|
# include <sys/timeb.h>
|
||||||
|
@ -109,6 +107,6 @@ typedef FnType_Void* Fnptr_Void;
|
||||||
# define __declspec(x)
|
# define __declspec(x)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif // end GCC/Linux stuff
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct romdir
|
||||||
# pragma pack()
|
# pragma pack()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
C_ASSERT( sizeof(romdir) == DIRENTRY_SIZE );
|
static_assert( sizeof(romdir) == DIRENTRY_SIZE, "romdir struct not packed to 16 bytes" );
|
||||||
|
|
||||||
u32 BiosVersion;
|
u32 BiosVersion;
|
||||||
u32 BiosChecksum;
|
u32 BiosChecksum;
|
||||||
|
|
|
@ -262,4 +262,4 @@ static void recLUT_SetPage(uptr reclut[0x10000], uptr hwlut[0x10000],
|
||||||
hwlut[page] = 0u - (pagebase << 16);
|
hwlut[page] = 0u - (pagebase << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
C_ASSERT( sizeof(BASEBLOCK) == 4 );
|
static_assert( sizeof(BASEBLOCK) == 4, "BASEBLOCK is not 4 bytes" );
|
||||||
|
|
|
@ -63,7 +63,7 @@ union __aligned16 microRegInfo {
|
||||||
u32 full32[160/sizeof(u32)];
|
u32 full32[160/sizeof(u32)];
|
||||||
};
|
};
|
||||||
|
|
||||||
C_ASSERT(sizeof(microRegInfo) == 160);
|
static_assert(sizeof(microRegInfo) == 160, "microRegInfo was not 160 bytes");
|
||||||
|
|
||||||
struct microProgram;
|
struct microProgram;
|
||||||
struct microJumpCache {
|
struct microJumpCache {
|
||||||
|
|
|
@ -34,11 +34,8 @@
|
||||||
#else
|
#else
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
/* common defines */
|
|
||||||
#ifndef C_ASSERT
|
|
||||||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
/* common defines */
|
||||||
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
||||||
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
||||||
defined(USBdefs) || defined(FWdefs)
|
defined(USBdefs) || defined(FWdefs)
|
||||||
|
|
|
@ -41,10 +41,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* common defines */
|
/* common defines */
|
||||||
#ifndef C_ASSERT
|
|
||||||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
||||||
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
||||||
defined(USBdefs) || defined(FWdefs)
|
defined(USBdefs) || defined(FWdefs)
|
||||||
|
|
|
@ -70,7 +70,7 @@ GIFRegHandler g_GIFRegHandlers[] = {
|
||||||
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
|
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
|
||||||
GIFRegHandlerSIGNAL, GIFRegHandlerFINISH, GIFRegHandlerLABEL, GIFRegHandlerNull };
|
GIFRegHandlerSIGNAL, GIFRegHandlerFINISH, GIFRegHandlerLABEL, GIFRegHandlerNull };
|
||||||
|
|
||||||
C_ASSERT(sizeof(g_GIFRegHandlers)/sizeof(g_GIFRegHandlers[0]) == 100 );
|
static_assert(sizeof(g_GIFRegHandlers)/sizeof(g_GIFRegHandlers[0]) == 100, "Regs not equal 100");
|
||||||
|
|
||||||
// values for keeping track of changes
|
// values for keeping track of changes
|
||||||
u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
|
u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
|
||||||
|
|
|
@ -68,7 +68,7 @@ GIFRegHandler g_GIFRegHandlers[] = {
|
||||||
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
|
GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull,
|
||||||
GIFRegHandlerSIGNAL, GIFRegHandlerFINISH, GIFRegHandlerLABEL, GIFRegHandlerNull };
|
GIFRegHandlerSIGNAL, GIFRegHandlerFINISH, GIFRegHandlerLABEL, GIFRegHandlerNull };
|
||||||
|
|
||||||
C_ASSERT(sizeof(g_GIFRegHandlers)/sizeof(g_GIFRegHandlers[0]) == 100 );
|
static_assert(sizeof(g_GIFRegHandlers)/sizeof(g_GIFRegHandlers[0]) == 100, "Regs not equal 100");
|
||||||
|
|
||||||
// values for keeping track of changes
|
// values for keeping track of changes
|
||||||
u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
|
u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0};
|
||||||
|
|
|
@ -52,10 +52,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* common defines */
|
/* common defines */
|
||||||
#ifndef C_ASSERT
|
|
||||||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
||||||
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
||||||
defined(USBdefs) || defined(FWdefs)
|
defined(USBdefs) || defined(FWdefs)
|
||||||
|
|
|
@ -83,8 +83,6 @@ typedef unsigned int uint;
|
||||||
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
||||||
#define PCSX2_ALIGNED16_DECL(x) __declspec(align(16)) x
|
#define PCSX2_ALIGNED16_DECL(x) __declspec(align(16)) x
|
||||||
|
|
||||||
#define __naked __declspec(naked)
|
|
||||||
|
|
||||||
#else // _MSC_VER
|
#else // _MSC_VER
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
@ -131,7 +129,6 @@ typedef union _LARGE_INTEGER
|
||||||
#define __unused __attribute__((unused))
|
#define __unused __attribute__((unused))
|
||||||
#define _inline __inline__ __attribute__((unused))
|
#define _inline __inline__ __attribute__((unused))
|
||||||
#define __forceinline __attribute__((always_inline,unused))
|
#define __forceinline __attribute__((always_inline,unused))
|
||||||
#define __naked // GCC lacks the naked specifier
|
|
||||||
|
|
||||||
#endif // __linux__
|
#endif // __linux__
|
||||||
|
|
||||||
|
@ -207,9 +204,4 @@ typedef struct {
|
||||||
s8 *data;
|
s8 *data;
|
||||||
} freezeData;
|
} freezeData;
|
||||||
|
|
||||||
/* common defines */
|
|
||||||
#ifndef C_ASSERT
|
|
||||||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __PS2ETYPES_H__ */
|
#endif /* __PS2ETYPES_H__ */
|
||||||
|
|
Loading…
Reference in New Issue