From: chsieh Date: Sat, 18 Dec 2010 08:01:46 +0000 (-0800) Subject: Cosmetic cleanups...I think. X-Git-Tag: box2d-testbed~36 X-Git-Url: http://git.less.ly:3516/?a=commitdiff_plain;h=4e7d01ea95668fcc506c3fd62e32f35a5e773090;p=tanks-ios.git Cosmetic cleanups...I think. --- diff --git a/Classes/Foundation/Common/Assert.h b/Classes/Foundation/Common/Assert.h index 8e3cd40..d72fd4a 100755 --- a/Classes/Foundation/Common/Assert.h +++ b/Classes/Foundation/Common/Assert.h @@ -11,58 +11,58 @@ #include "GlobalDefines.h" - #if defined(__WINDOWS__) +#if defined(__WINDOWS__) - #define Assert(expression) if (!(expression)) __debugbreak(); + #define Assert(expression) if (!(expression)) __debugbreak(); - #elif defined(__iOS__) +#elif defined(__iOS__) - // Returns true if the current process is being debugged (either - // running under the debugger or has a debugger attached post facto). - static bool AmIBeingDebugged(void) - { - int junk; - int mib[4]; - struct kinfo_proc info; - size_t size; + // Returns true if the current process is being debugged (either + // running under the debugger or has a debugger attached post facto). + static bool AmIBeingDebugged(void) + { + int junk; + int mib[4]; + struct kinfo_proc info; + size_t size; - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. - info.kp_proc.p_flag = 0; + // Initialize the flags so that, if sysctl fails for some bizarre + // reason, we get a predictable result. + info.kp_proc.p_flag = 0; - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); + // Initialize mib, which tells sysctl the info we want, in this case + // we're looking for information about a specific process ID. + mib[0] = CTL_KERN; + mib[1] = KERN_PROC; + mib[2] = KERN_PROC_PID; + mib[3] = getpid(); - // Call sysctl. - size = sizeof(info); - junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); - assert(junk == 0); + // Call sysctl. + size = sizeof(info); + junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0); + assert(junk == 0); - // We're being debugged if the P_TRACED flag is set. - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - } + // We're being debugged if the P_TRACED flag is set. + return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); + } - // http://iphone.m20.nl/wp/?p=1#more-1 - //#define DEBUGSTOP(signal) __asm__ __volatile__ ("mov r0, %0\nmov r1, %1\nmov r12, #37\nswi 128\n" : : "r" (getpid ()), "r" (signal) : "r12", "r0", "r1", "cc"); - //#define DEBUGGER do { int trapSignal = AmIBeingDebugged () ? SIGINT : SIGSTOP; DEBUGSTOP(trapSignal); if (trapSignal == SIGSTOP) { DEBUGSTOP (SIGINT); } } while (false); + // http://iphone.m20.nl/wp/?p=1#more-1 + //#define DEBUGSTOP(signal) __asm__ __volatile__ ("mov r0, %0\nmov r1, %1\nmov r12, #37\nswi 128\n" : : "r" (getpid ()), "r" (signal) : "r12", "r0", "r1", "cc"); + //#define DEBUGGER do { int trapSignal = AmIBeingDebugged () ? SIGINT : SIGSTOP; DEBUGSTOP(trapSignal); if (trapSignal == SIGSTOP) { DEBUGSTOP (SIGINT); } } while (false); - // Graciously copied from http://cocoawithlove.com/2008/03/break-into-debugger.html - #define DebugBreak() if (AmIBeingDebugged()) { DebugBreak(); } + // Graciously copied from http://cocoawithlove.com/2008/03/break-into-debugger.html + #define DebugBreak() if (AmIBeingDebugged()) { DebugBreak(); } - #define Assert(expression) if (!(expression)) raise(SIGTRAP); + #define Assert(expression) if (!(expression)) raise(SIGTRAP); - #endif +#endif - #define AssertMessage(expression, message, ...) \ - if (!(expression)) Printf(message, ##__VA_ARGS__) +#define AssertMessage(expression, message, ...) \ + if (!(expression)) Printf(message, ##__VA_ARGS__) #else slInline void Assert(bool expression) {} slInline void AssertMsg(bool expression, char* msg, ...) {} -#endif \ No newline at end of file +#endif diff --git a/Classes/Foundation/Common/GlobalDefines.h b/Classes/Foundation/Common/GlobalDefines.h index aa242fa..d3faf15 100755 --- a/Classes/Foundation/Common/GlobalDefines.h +++ b/Classes/Foundation/Common/GlobalDefines.h @@ -2,6 +2,8 @@ #include "Foundation/Common/GlobalTypes.h" +//---------------------------------------------------------------------------------------- +// OS and CPU architecture defines #if defined(_WINDOWS) #define __WINDOWS__ #define __X86__ @@ -16,14 +18,18 @@ #endif #endif -#if defined(_DEBUG) +//---------------------------------------------------------------------------------------- +// configuration defines +#if defined(_DEBUG) && !defined(DEBUG) #define DEBUG #endif -#if defined(_NDEBUG) +#if defined(_NDEBUG) && !defined(RELEASE) #define RELEASE #endif +//---------------------------------------------------------------------------------------- +// some type defines that may or may not be defined already? #if !defined(NULL) #define NULL 0 #endif @@ -39,18 +45,24 @@ //---------------------------------------------------------------------------------------- // cache information #if !defined(CACHE_LINE_SIZE) -#define CACHE_LINE_SIZE 128 // normally equals to 2 lines for intel + #if defined(__X86__) + #define CACHE_LINE_SIZE 128 // normally equals to 2 lines for intel + #elif defined(__ARM__) + #define CACHE_LINE_SIZE 32 + #else + #define CACHE_LINE_SIZE 32 + #endif #endif //---------------------------------------------------------------------------------------- -//force inline on non-debug, might make code explode +// force inline on non-debug, might make code explode #if defined(DEBUG) #define slInline inline #else #define slInline __forceinline #endif -//compiler determined inline +// compiler determined inline #define clInline inline #define slRestrict __restrict @@ -95,7 +107,7 @@ #endif //---------------------------------------------------------------------------------------- -// color constants +// color constants...this probably needs to consider endianness? #define NULL_COLOR 0x00000000 #define BLACK_COLOR 0x000000ff #define RED_COLOR 0xff0000ff @@ -104,6 +116,10 @@ #define WHITE_COLOR 0xffffffff //---------------------------------------------------------------------------------------- +// some intrinsic/asm/fast stuff stuffs -- maybe this should be moved to another file +#define RightMostEnabledBit(x) ((x) & -(x)) + + #if defined(__ARM__) slInline uint8_t LZCount(uint64_t x) @@ -134,6 +150,3 @@ slInline uint8_t LZCount(uint64_t x) } #endif - -//---------------------------------------------------------------------------------------- -#define RightMostEnabledBit(x) ((x) & -(x)) \ No newline at end of file diff --git a/Classes/Foundation/Common/Singleton.h b/Classes/Foundation/Common/Singleton.h index cdbead7..bc1ae03 100755 --- a/Classes/Foundation/Common/Singleton.h +++ b/Classes/Foundation/Common/Singleton.h @@ -2,10 +2,7 @@ #include "Foundation/Common/GlobalInclude.h" -/* -Statically allocates for faster access -*/ - +//---------------------------------------------------------------------------------------- namespace Foundation { @@ -16,35 +13,30 @@ private: static T* m_Instance; protected: - Singleton(){m_Instance = 0;} + Singleton() { m_Instance = NULL; } public: - static T* Create() + static T* Init() { - Assert( m_Instance == 0); - if(m_Instance) - { - return m_Instance; - } - m_Instance = new(16) T(); + Assert( m_Instance == NULL); + m_Instance = new (16) T(); return m_Instance; } slInline static T* GetInstance() { - //Assert( m_Instance == 0); return m_Instance; } static void DestroyInstance() { - if(m_Instance) + if ( m_Instance ) { delete m_Instance; } } }; -template T* Singleton::m_Instance = 0; +template T* Singleton::m_Instance = NULL; } diff --git a/Classes/Foundation/Math/MathDefines.h b/Classes/Foundation/Math/MathDefines.h index 1aedb6b..b9bbdaa 100755 --- a/Classes/Foundation/Math/MathDefines.h +++ b/Classes/Foundation/Math/MathDefines.h @@ -11,4 +11,4 @@ #define k3Pi_4 2.3561944901923449288469825374596 #define k2Pi 6.283185307179586476925286766559 -#define kE 2.7182818284590452353602874713527 \ No newline at end of file +#define kE 2.7182818284590452353602874713527 diff --git a/Classes/Foundation/Synchronization/MemorySync.h b/Classes/Foundation/Synchronization/MemorySync.h index 08de018..156060a 100755 --- a/Classes/Foundation/Synchronization/MemorySync.h +++ b/Classes/Foundation/Synchronization/MemorySync.h @@ -8,14 +8,14 @@ #define ReadWriteSync() MemoryBarrier() -#elif defined(__PS3__) - -#define ReadWriteSync() __asm__("lwsync") - #elif defined(__ARM__) #define ReadWriteSync() __asm__("dsb") +#elif defined(__PPC__) + +#define ReadWriteSync() __asm__("lwsync") + #elif defined(__X86__) && defined(__iOS__) #include @@ -25,4 +25,4 @@ #error MemorySync not yet implemented for this build! -#endif \ No newline at end of file +#endif