From d8617c1ee8220b073e437a3d0e5633e86dd74fd0 Mon Sep 17 00:00:00 2001 From: arcum42 Date: Wed, 29 Apr 2009 11:47:05 +0000 Subject: [PATCH] Get rid of duplicated code in PS2Etypes.h. :) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1088 96395faa-99c1-11dd-bbfe-3dabce05a288 --- build.sh | 6 +- common/include/PS2Edefs.h | 8 +- common/include/PS2Etypes.h | 218 +----------------------------------- common/include/Pcsx2Defs.h | 5 + common/include/Pcsx2Types.h | 22 ++-- pcsx2/Common.h | 2 +- pcsx2/Patch.h | 2 +- pcsx2/PrecompiledHeader.h | 2 +- pcsx2/R5900OpcodeTables.h | 2 +- pcsx2/System.h | 2 +- pcsx2/Threading.h | 2 +- pcsx2/configure.ac | 2 +- 12 files changed, 33 insertions(+), 240 deletions(-) diff --git a/build.sh b/build.sh index e409a5c185..a6aaa8710d 100644 --- a/build.sh +++ b/build.sh @@ -6,13 +6,13 @@ # Uncomment if building by itself, rather then with all the plugins #Normal -#export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --prefix `pwd`" +#export PCSX2OPTIONS="--prefix `pwd`" #Optimized, but a devbuild -export PCSX2OPTIONS="--enable-sse3 --enable-sse4 --enable-devbuild --prefix `pwd`" +export PCSX2OPTIONS="--enable-devbuild --prefix `pwd`" #Debug / Devbuild version -#export PCSX2OPTIONS="--enable-debug --enable-devbuild --enable-sse3 --prefix `pwd`" +#export PCSX2OPTIONS="--enable-debug --enable-devbuild --prefix `pwd`" #ZeroGS Normal mode export ZEROGSOPTIONS="--enable-sse2" diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index edee168d9e..eac022192b 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -48,13 +48,7 @@ */ -#include "PS2Etypes.h" - - -/* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif +#include "Pcsx2Defs.h" #if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \ defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \ diff --git a/common/include/PS2Etypes.h b/common/include/PS2Etypes.h index 474eb50eff..a2401d6041 100644 --- a/common/include/PS2Etypes.h +++ b/common/include/PS2Etypes.h @@ -15,221 +15,13 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + + // This file is just for backwards compatability. #ifndef __PS2ETYPES_H__ #define __PS2ETYPES_H__ -#if defined (__linux__) && !defined(__LINUX__) // some distributions are lower case -#define __LINUX__ -#endif - -#ifdef __CYGWIN__ -#define __LINUX__ -#endif - -// Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air) -#ifndef ArraySize -#define ArraySize(x) (sizeof(x)/sizeof((x)[0])) -#endif - -////////////////////////////////////////////////////////////////////////////////////////// -// jASSUME - give hints to the optimizer -// This is primarily useful for the default case switch optimizer, which enables VC to -// generate more compact switches. - -#ifdef NDEBUG -# define jBREAKPOINT() ((void) 0) -# ifdef _MSC_VER -# define jASSUME(exp) (__assume(exp)) -# else -# define jASSUME(exp) ((void) sizeof(exp)) -# endif -#else -# if defined(_MSC_VER) -# define jBREAKPOINT() do { __asm int 3 } while(0) -# else -# define jBREAKPOINT() ((void) *(volatile char *) 0) -# endif -# define jASSUME(exp) if(exp) ; else jBREAKPOINT() -#endif - -// disable the default case in a switch -#define jNO_DEFAULT \ -{ \ -default: \ - jASSUME(0); \ - break; \ -} - -////////////////////////////////////////////////////////////////////////////////////////// -// Basic Atomic Types - -#if defined(_MSC_VER) - -typedef __int8 s8; -typedef __int16 s16; -typedef __int32 s32; -typedef __int64 s64; - -typedef unsigned __int8 u8; -typedef unsigned __int16 u16; -typedef unsigned __int32 u32; -typedef unsigned __int64 u64; - -typedef unsigned int uint; - -// Note: building the 'extern' into PCSX2_ALIGNED16_DECL fixes Visual Assist X's intellisense. - -#define PCSX2_ALIGNED(alig,x) __declspec(align(alig)) x -#define PCSX2_ALIGNED_EXTERN(alig,x) extern __declspec(align(alig)) x -#define PCSX2_ALIGNED16(x) __declspec(align(16)) x -#define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x - -#define __naked __declspec(naked) -#define __unused /*unused*/ -#define __noinline __declspec(noinline) -#define CALLBACK __stdcall - -#else // _MSC_VER - -#ifdef __LINUX__ - -#ifdef HAVE_STDINT_H -#include "stdint.h" - -typedef int8_t s8; -typedef int16_t s16; -typedef int32_t s32; -typedef int64_t s64; - -typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - -typedef uintptr_t uptr; -typedef intptr_t sptr; - -#else // HAVE_STDINT_H - -typedef char s8; -typedef short s16; -typedef int s32; -typedef long long s64; - -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; - -#endif // HAVE_STDINT_H - -typedef unsigned int uint; - -#define LONG long -typedef union _LARGE_INTEGER -{ - long long QuadPart; -} LARGE_INTEGER; - -#define __fastcall __attribute__((fastcall)) -#define __unused __attribute__((unused)) -#define _inline __inline__ __attribute__((unused)) -#define __forceinline __attribute__((always_inline,unused)) -#define __noinline __attribute__((noinline)) -#define __naked // GCC lacks the naked specifier -#define CALLBACK // CALLBACK is win32-specific mess - -#endif // __LINUX__ - -#define PCSX2_ALIGNED(alig,x) x __attribute((aligned(alig))) -#define PCSX2_ALIGNED16(x) x __attribute((aligned(16))) - -// fixme - is this needed for recent versions of GCC? Or can we just use the macros -// above instead for both definitions (implementations) and declarations (includes)? -- air - -#define PCSX2_ALIGNED_EXTERN(alig,x) extern x __attribute((aligned(alig))) -#define PCSX2_ALIGNED16_EXTERN(x) extern x __attribute((aligned(16))) - -#endif // _MSC_VER - -#if !defined(__LINUX__) || !defined(HAVE_STDINT_H) -#if defined(__x86_64__) -typedef u64 uptr; -typedef s64 sptr; -#else -typedef u32 uptr; -typedef s32 sptr; -#endif -#endif - -////////////////////////////////////////////////////////////////////////////////////////// -// A rough-and-ready cross platform 128-bit datatype, Non-SSE style. -#ifdef __cplusplus -struct u128 -{ - u64 lo; - u64 hi; - - // Implicit conversion from u64 - u128( u64 src ) : - lo( src ) - , hi( 0 ) {} - - // Implicit conversion from u32 - u128( u32 src ) : - lo( src ) - , hi( 0 ) {} -}; - -struct s128 -{ - s64 lo; - s64 hi; - - // Implicit conversion from u64 - s128( s64 src ) : - lo( src ) - , hi( 0 ) {} - - // Implicit conversion from u32 - s128( s32 src ) : - lo( src ) - , hi( 0 ) {} -}; - -#else - -typedef union _u128_t -{ - u64 lo; - u64 hi; -} u128; - -typedef union _s128_t -{ - s64 lo; - s64 hi; -} s128; - -#endif - -typedef struct { - int size; - s8 *data; -} freezeData; - -// event values: -#define KEYPRESS 1 -#define KEYRELEASE 2 - -typedef struct _keyEvent { - u32 key; - u32 evt; -} keyEvent; - -/* common defines */ -#ifndef C_ASSERT -#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] -#endif +// This brings in both all the things that used to be in PS2types.h that weren't type related, +// and also brings Pcsx2Types in. +#include "Pcsx2Defs.h" #endif /* __PS2ETYPES_H__ */ diff --git a/common/include/Pcsx2Defs.h b/common/include/Pcsx2Defs.h index dbaf5ca315..20a5f8f1fa 100644 --- a/common/include/Pcsx2Defs.h +++ b/common/include/Pcsx2Defs.h @@ -27,6 +27,8 @@ #define __LINUX__ #endif +#include "Pcsx2Types.h" + // Renamed ARRAYSIZE to ArraySize -- looks nice and gets rid of Windows.h conflicts (air) #ifndef ArraySize #define ArraySize(x) (sizeof(x)/sizeof((x)[0])) @@ -77,6 +79,8 @@ default: \ #define PCSX2_ALIGNED16_EXTERN(x) extern __declspec(align(16)) x #define __naked __declspec(naked) +#define __unused /*unused*/ +#define __noinline __declspec(noinline) #define CALLBACK __stdcall #else @@ -96,6 +100,7 @@ default: \ #define __unused __attribute__((unused)) #define _inline __inline__ __attribute__((unused)) #define __forceinline __attribute__((always_inline,unused)) +#define __noinline __attribute__((noinline)) #endif typedef struct { diff --git a/common/include/Pcsx2Types.h b/common/include/Pcsx2Types.h index 942076e972..41e2d893a1 100644 --- a/common/include/Pcsx2Types.h +++ b/common/include/Pcsx2Types.h @@ -19,8 +19,6 @@ #ifndef __PCSX2TYPES_H__ #define __PCSX2TYPES_H__ -// Note; this header is experamental, and will be a shifting target. Only use this if you are willing to repeatedly fix breakage. - /* * Based on PS2E Definitions by linuzappz@hotmail.com, @@ -45,12 +43,10 @@ typedef unsigned __int32 u32; typedef unsigned __int64 u64; typedef unsigned int uint; -typedef u32 uptr; -typedef s32 sptr; -#else // _MSC_VER +#else // _MSC_VER*/ - #ifdef __LINUX__ +#ifdef __LINUX__ #ifdef HAVE_STDINT_H #include "stdint.h" @@ -80,9 +76,6 @@ typedef unsigned short u16; typedef unsigned int u32; typedef unsigned long long u64; -typedef u32 uptr; -typedef s32 sptr; - #endif // HAVE_STDINT_H typedef unsigned int uint; @@ -96,6 +89,15 @@ typedef union _LARGE_INTEGER #endif // __LINUX__ #endif //_MSC_VER +#if !defined(__LINUX__) || !defined(HAVE_STDINT_H) +#if defined(__x86_64__) +typedef u64 uptr; +typedef s64 sptr; +#else +typedef u32 uptr; +typedef s32 sptr; +#endif +#endif ////////////////////////////////////////////////////////////////////////////////////////// // A rough-and-ready cross platform 128-bit datatype, Non-SSE style. @@ -148,4 +150,4 @@ typedef union _s128_t #endif - #endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/pcsx2/Common.h b/pcsx2/Common.h index 4daeee5663..1995b786c4 100644 --- a/pcsx2/Common.h +++ b/pcsx2/Common.h @@ -19,7 +19,7 @@ #ifndef __COMMON_H__ #define __COMMON_H__ -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #define BIAS 2 // Bus is half of the actual ps2 speed //#define PS2CLK 36864000 /* 294.912 mhz */ diff --git a/pcsx2/Patch.h b/pcsx2/Patch.h index e032614d51..b077ae67fd 100644 --- a/pcsx2/Patch.h +++ b/pcsx2/Patch.h @@ -18,7 +18,7 @@ #ifndef __PATCH_H__ #define __PATCH_H__ -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" // // Defines diff --git a/pcsx2/PrecompiledHeader.h b/pcsx2/PrecompiledHeader.h index e2b24c72e3..b299dfb724 100644 --- a/pcsx2/PrecompiledHeader.h +++ b/pcsx2/PrecompiledHeader.h @@ -69,7 +69,7 @@ typedef int BOOL; // unchanged for long periods of time. #include "zlib/zlib.h" -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #include "MemcpyFast.h" #include "StringUtils.h" #include "Exceptions.h" diff --git a/pcsx2/R5900OpcodeTables.h b/pcsx2/R5900OpcodeTables.h index cd2a5e499c..a8d7346c59 100644 --- a/pcsx2/R5900OpcodeTables.h +++ b/pcsx2/R5900OpcodeTables.h @@ -18,7 +18,7 @@ #ifndef _R5900_OPCODETABLES_H #define _R5900_OPCODETABLES_H -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" // TODO : Move these into the OpcodeTables namespace extern void (*Int_COP2PrintTable[32])(); diff --git a/pcsx2/System.h b/pcsx2/System.h index 09dff0196c..41208581f7 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -19,7 +19,7 @@ #ifndef __SYSTEM_H__ #define __SYSTEM_H__ -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #include "Paths.h" #include "Pcsx2Config.h" #include "Exceptions.h" diff --git a/pcsx2/Threading.h b/pcsx2/Threading.h index a448e9a943..f75d3e4262 100644 --- a/pcsx2/Threading.h +++ b/pcsx2/Threading.h @@ -22,7 +22,7 @@ #include // EBUSY #include -#include "PS2Etypes.h" +#include "Pcsx2Defs.h" #include "Exceptions.h" namespace Threading diff --git a/pcsx2/configure.ac b/pcsx2/configure.ac index d2d5ea39d6..e76f484618 100644 --- a/pcsx2/configure.ac +++ b/pcsx2/configure.ac @@ -38,7 +38,7 @@ fi WARNING_FLAGS="-Wno-format -Wno-unused-parameter -Wno-unused-value -Wunused-variable " EXTRA_WARNING_FLAGS="-Wall -Wextra" NORMAL_FLAGS=" -pipe -msse -msse2 -O2 ${WARNING_FLAGS}" -# These optimizations seem to cause issues with GCC 4.3.3, so we'll turn them off. +# These optimizations seem to cause issues with GCC 4.3.3, so we'll turn them off. Comment if not on 4.3+ NORMAL_FLAGS+=" -fno-guess-branch-probability -fno-dse -fno-tree-dse " DEBUG_FLAGS+=" -g -msse -msse2 ${EXTRA_WARNING_FLAGS} ${WARNING_FLAGS} "