00001 #ifndef __SSDEFS_HPP
00002 #define __SSDEFS_HPP
00003
00004 #include <cstddef>
00005
00006 namespace SS
00007 {
00008
00009
00010
00011
00012
00013 #if defined(_DEBUG) // debug build
00014 # undef SS_DEBUG
00015 # define SS_DEBUG
00016 #endif // _DEBUG
00017
00018
00019 #ifdef SS_DEBUG
00020 #define SS_DEBUG_CODE(X) X
00021 #else
00022 #define SS_DEBUG_CODE(X)
00023 #endif
00024
00025 #if defined (_MSC_VER)
00026 # define SS_BUILD_MSC // Microsoft Visual C++ (any version)
00027 # if (_MSC_VER == 1200)
00028 # define SS_BUILD_MSC6 // Microsoft Visual C++ 6.0 or higher (also SS_BUILD_MSC defined)
00029 # endif
00030 # define SS_X86_RETURN_EAX // even inline functions return parameters correctly in eax
00031 # define SS_COMPILER "Microsoft Visual C++"
00032 #endif
00033
00034 #define SS_NULL_STATEMENT (static_cast<void>(0)) // no statement
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #define SS_CT_ASSERT(expr) typedef bool SSCompilationTimeAssertion[(expr) ? 1 : -1]
00050
00051
00052
00053
00054
00055
00056 typedef char INT8;
00057 typedef unsigned char UINT8;
00058 typedef short int INT16;
00059 typedef unsigned short int UINT16;
00060 typedef int INT32;
00061 typedef unsigned int UINT32;
00062
00063
00064
00065
00066
00067 SS_CT_ASSERT(sizeof(INT16)==2);
00068 SS_CT_ASSERT(sizeof(UINT16)==2);
00069 SS_CT_ASSERT(sizeof(INT32)==4);
00070 SS_CT_ASSERT(sizeof(UINT32)==4);
00071
00072
00073
00074
00075
00076
00077 #if defined (SS_BUILD_MSC)
00078 # if !defined (for)
00079 inline bool getFalse (void) { return false; }
00080 # define for if(SS::getFalse()); else for
00081 # endif // for
00082 #endif // SS_BUILD_MSC
00083
00084
00085
00086
00087
00088 template <class T> inline void swap (T& a, T& b)
00089 {
00090 T t = a;
00091 a = b;
00092 b = t;
00093 }
00094
00095 template <class T> inline const T& min2 (const T& a, const T& b) { return a<=b ? a : b; }
00096 template <class T> inline const T& max2 (const T& a, const T& b) { return a>=b ? a : b; }
00097
00098
00099
00100
00101
00102 int intChop (const float&);
00103 int intFloor (const float&);
00104 int intCeil (const float&);
00105
00106
00107
00108
00109
00110
00111 inline int abs (int i) { return i < 0 ? -i : i; }
00112 inline float fabs (float f) { return f < 0 ? -f : f; }
00113 inline double fabs (double f) { return f < 0 ? -f : f; }
00114
00115
00116
00117
00118
00119 #undef min
00120 #undef max
00121
00122
00123
00124
00125
00126
00127 void assertFail (const char* expr, const char* file, int line, const char* message);
00128
00129 #if defined (SS_DEBUG) && !defined (SS_DISABLE_ASSERTS)
00130 # define SS_ASSERT(e) ((e) ? SS_NULL_STATEMENT : SS::assertFail(#e,__FILE__,__LINE__,""))
00131 # define SS_ASSERT_PRINT(a,b) ((a) ? SS_NULL_STATEMENT : SS::assertFail(#a,__FILE__,__LINE__,#b))
00132 # define SS_API_ASSERT(e) ((e) ? SS_NULL_STATEMENT : SS::assertFail("API Error:"#e,__FILE__,__LINE__,""))
00133 #else
00134 # define SS_ASSERT(e) (SS_NULL_STATEMENT)
00135 # define SS_ASSERT_PRINT(a,b) (SS_NULL_STATEMENT)
00136 # define SS_API_ASSERT(e) (SS_NULL_STATEMENT)
00137 #endif // SS_DEBUG
00138
00139 }
00140
00141
00142
00143 #endif // __SSDEFS_HPP