\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
\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
}\r
\r
#endif\r
-\r
-//----------------------------------------------------------------------------------------\r
-#define RightMostEnabledBit(x) ((x) & -(x))
\ No newline at end of file
\r
#include "Foundation/Common/GlobalInclude.h"\r
\r
-/*\r
-Statically allocates for faster access\r
-*/\r
-\r
+//----------------------------------------------------------------------------------------\r
namespace Foundation\r
{\r
\r
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