diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index 1c36b13590..6e23feb18e 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -66,21 +66,6 @@ extern "C" unsigned __int64 __xgetbv(int); # 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. // -------------------------------------------------------------------------------------- @@ -204,13 +189,10 @@ static const int __pagesize = PCSX2_PAGESIZE; # define PCSX2_ALIGNED16(x) __declspec(align(16)) x # define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x -# define __naked __declspec(naked) # define __noinline __declspec(noinline) # define __threadlocal __declspec(thread) // Don't know if there are Visual C++ equivalents of these. -# define __hot -# define __cold # define likely(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_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 CALLBACK __attribute__((stdcall)) @@ -250,46 +231,11 @@ static const int __pagesize = PCSX2_PAGESIZE; # define __forceinline __attribute__((unused)) # endif # define __noinline __attribute__((noinline)) -# define __hot __attribute__((hot)) -# define __cold __attribute__((cold)) # define __threadlocal __thread # define likely(x) __builtin_expect(!!(x), 1) # define unlikely(x) __builtin_expect(!!(x), 0) #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. // -------------------------------------------------------------------------------------- diff --git a/common/include/PluginCallbacks.h b/common/include/PluginCallbacks.h index 136e97359a..744a718556 100644 --- a/common/include/PluginCallbacks.h +++ b/common/include/PluginCallbacks.h @@ -148,7 +148,7 @@ #else // Ensure the user's defined PS2E_THISPTR retains the correct signature for our // plugin API. - C_ASSERT( sizeof(PS2E_THISPTR) == sizeof(void*) ); + static_assert( sizeof(PS2E_THISPTR) == sizeof(void*), "Incorrect signature for PS2E_THISPTR" ); #endif // PS2E_LIB_THISPTR - (library scope version of PS2E_THISPTR) @@ -157,7 +157,7 @@ #else // Ensure the user's defined PS2E_THISPTR retains the correct signature for our // 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 // Use fastcall by default, since under most circumstances the object-model approach of the diff --git a/common/include/Utilities/MemsetFast.inl b/common/include/Utilities/MemsetFast.inl index c52b58e526..788488c658 100644 --- a/common/include/Utilities/MemsetFast.inl +++ b/common/include/Utilities/MemsetFast.inl @@ -73,13 +73,13 @@ static __fi void memzero_sse_a( void* dest, const size_t size ) template< u8 data, typename T > __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( &dest, sizeof(dest) ); } template< typename T > 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) ); } diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index 5859eee8dd..e3012a226a 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -16,8 +16,6 @@ #ifndef 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... #ifdef _MSC_VER # pragma warning(disable:4250) //'class' inherits 'method' via dominance @@ -99,7 +97,7 @@ typedef FnType_Void* Fnptr_Void; # define strnicmp _strnicmp # define stricmp _stricmp -#else // must be GCC... +#else // must be GCC or Clang # include # include @@ -109,6 +107,6 @@ typedef FnType_Void* Fnptr_Void; # define __declspec(x) # endif -#endif // end GCC/Linux stuff +#endif #endif diff --git a/pcsx2/ps2/BiosTools.cpp b/pcsx2/ps2/BiosTools.cpp index cea35a0d7e..31309ba0e2 100644 --- a/pcsx2/ps2/BiosTools.cpp +++ b/pcsx2/ps2/BiosTools.cpp @@ -47,7 +47,7 @@ struct romdir # pragma pack() #endif -C_ASSERT( sizeof(romdir) == DIRENTRY_SIZE ); +static_assert( sizeof(romdir) == DIRENTRY_SIZE, "romdir struct not packed to 16 bytes" ); u32 BiosVersion; u32 BiosChecksum; diff --git a/pcsx2/x86/BaseblockEx.h b/pcsx2/x86/BaseblockEx.h index 963fda0695..3f0fe2af64 100644 --- a/pcsx2/x86/BaseblockEx.h +++ b/pcsx2/x86/BaseblockEx.h @@ -262,4 +262,4 @@ static void recLUT_SetPage(uptr reclut[0x10000], uptr hwlut[0x10000], hwlut[page] = 0u - (pagebase << 16); } -C_ASSERT( sizeof(BASEBLOCK) == 4 ); +static_assert( sizeof(BASEBLOCK) == 4, "BASEBLOCK is not 4 bytes" ); diff --git a/pcsx2/x86/microVU_IR.h b/pcsx2/x86/microVU_IR.h index 023a256b6b..9e50098d88 100644 --- a/pcsx2/x86/microVU_IR.h +++ b/pcsx2/x86/microVU_IR.h @@ -63,7 +63,7 @@ union __aligned16 microRegInfo { u32 full32[160/sizeof(u32)]; }; -C_ASSERT(sizeof(microRegInfo) == 160); +static_assert(sizeof(microRegInfo) == 160, "microRegInfo was not 160 bytes"); struct microProgram; struct microJumpCache { diff --git a/plugins/CDVDisoEFP/src/PS2Edefs.h b/plugins/CDVDisoEFP/src/PS2Edefs.h index a50c36fb79..77b6f4582e 100644 --- a/plugins/CDVDisoEFP/src/PS2Edefs.h +++ b/plugins/CDVDisoEFP/src/PS2Edefs.h @@ -34,11 +34,8 @@ #else #include #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) || \ defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \ defined(USBdefs) || defined(FWdefs) diff --git a/plugins/CDVDlinuz/Src/PS2Edefs.h b/plugins/CDVDlinuz/Src/PS2Edefs.h index afb989479a..9eb3ff35f4 100644 --- a/plugins/CDVDlinuz/Src/PS2Edefs.h +++ b/plugins/CDVDlinuz/Src/PS2Edefs.h @@ -41,10 +41,6 @@ /* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif - #if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \ defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \ defined(USBdefs) || defined(FWdefs) diff --git a/plugins/zerogs/dx/Regs.cpp b/plugins/zerogs/dx/Regs.cpp index 7f13732105..9fddf75454 100644 --- a/plugins/zerogs/dx/Regs.cpp +++ b/plugins/zerogs/dx/Regs.cpp @@ -70,7 +70,7 @@ GIFRegHandler g_GIFRegHandlers[] = { GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, 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 u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0}; diff --git a/plugins/zerogs/opengl/Regs.cpp b/plugins/zerogs/opengl/Regs.cpp index 23a07bda52..9a03749f8b 100644 --- a/plugins/zerogs/opengl/Regs.cpp +++ b/plugins/zerogs/opengl/Regs.cpp @@ -68,7 +68,7 @@ GIFRegHandler g_GIFRegHandlers[] = { GIFRegHandlerNull, GIFRegHandlerNull, GIFRegHandlerNull, 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 u32 s_uTex1Data[2][2] = {0}, s_uClampData[2] = {0}; diff --git a/plugins/zerogs/opengl/common/PS2Edefs.h b/plugins/zerogs/opengl/common/PS2Edefs.h index a897552ffe..228b6bac96 100644 --- a/plugins/zerogs/opengl/common/PS2Edefs.h +++ b/plugins/zerogs/opengl/common/PS2Edefs.h @@ -52,10 +52,6 @@ /* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif - #if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \ defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \ defined(USBdefs) || defined(FWdefs) diff --git a/plugins/zerogs/opengl/common/PS2Etypes.h b/plugins/zerogs/opengl/common/PS2Etypes.h index 5097610d39..5091291d9a 100644 --- a/plugins/zerogs/opengl/common/PS2Etypes.h +++ b/plugins/zerogs/opengl/common/PS2Etypes.h @@ -83,8 +83,6 @@ typedef unsigned int uint; #define PCSX2_ALIGNED16(x) __declspec(align(16)) x #define PCSX2_ALIGNED16_DECL(x) __declspec(align(16)) x -#define __naked __declspec(naked) - #else // _MSC_VER #ifdef __linux__ @@ -131,7 +129,6 @@ typedef union _LARGE_INTEGER #define __unused __attribute__((unused)) #define _inline __inline__ __attribute__((unused)) #define __forceinline __attribute__((always_inline,unused)) -#define __naked // GCC lacks the naked specifier #endif // __linux__ @@ -207,9 +204,4 @@ typedef struct { s8 *data; } freezeData; -/* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif - #endif /* __PS2ETYPES_H__ */