Cosmetic cleanups...I think.
authorchsieh <chester.developer@hotmail.com>
Sat, 18 Dec 2010 08:01:46 +0000 (00:01 -0800)
committerchsieh <chester.developer@hotmail.com>
Sat, 18 Dec 2010 08:01:46 +0000 (00:01 -0800)
Classes/Foundation/Common/Assert.h
Classes/Foundation/Common/GlobalDefines.h
Classes/Foundation/Common/Singleton.h
Classes/Foundation/Math/MathDefines.h
Classes/Foundation/Synchronization/MemorySync.h

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