common.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00037 #ifndef COMMON_H
00038 #define COMMON_H
00039
00040
00041 #if _DEBUG
00042 #undef DEBUG
00043 #define DEBUG
00044 #endif
00045
00046 #if defined(_MSC_VER)
00047
00048 #define BREAKPOINT { _asm int 3 }
00049 #define ASSERT(c) {if(!(c)) BREAKPOINT;}
00050 typedef __int64 longlong;
00051 typedef unsigned __int64 ulonglong;
00052
00053
00054 #pragma warning( disable : 4244 )
00055 #pragma warning( disable : 4514 )
00056 #pragma warning( disable : 4146 )
00057 #pragma warning( disable : 4710 )
00058 #pragma warning( disable : 4355 )
00059 #pragma warning( disable : 4512 )
00060 #pragma warning( disable : 4800 )
00061
00062 #elif defined(__EPOC32__) || defined(__WINS__)
00063
00064
00065 #define COMPILE_FOR_SYMBIAN
00066 #include <e32std.h>
00067
00068 #if !defined(__BREAKPOINT)
00069
00070 #if defined(__WINS__)
00071
00072 #if defined(__WINSCW__)
00073 #define BREAKPOINT { _asm byte 0xcc }
00074 #else
00075 #define BREAKPOINT { _asm int 3 }
00076 #endif
00077
00078 #else
00079 #define BREAKPOINT
00080 #endif
00081
00082 #else
00083 #define BREAKPOINT {__BREAKPOINT()}
00084 #endif
00085
00086 #undef ASSERT
00087 #define ASSERT(c) {if(!(c)) BREAKPOINT;}
00089 #if !defined(DEBUG) && defined(_DEBUG)
00090 #define DEBUG
00091 #endif
00092
00093 typedef TInt64 longlong;
00094 typedef TUint64 ulonglong;
00095
00096
00097 #else
00098
00099 #define BREAKPOINT
00101 extern int AssertFailed(const char* file, int line);
00102 #undef ASSERT
00103 #define ASSERT(c) (void)((c)||AssertFailed(__FILE__,__LINE__))
00105 typedef long long longlong;
00106 typedef unsigned long long ulonglong;
00107
00108
00109 #endif
00110
00111
00112 #ifdef DEBUG
00113 #define ASSERT_DEBUG(c) ASSERT(c)
00114 #else
00115 #define ASSERT_DEBUG(c)
00116 #endif
00117
00118
00119 #ifndef ASSERT_COMPILE
00120
00121 #define ASSERT_COMPILE(c) void assert_compile(int assert_compile[(c)?1:-1])
00122 #endif
00123
00124
00134 typedef unsigned char uint8_t;
00135 typedef unsigned short uint16_t;
00136 typedef unsigned int uint32_t;
00137 typedef ulonglong uint64_t;
00138 typedef signed char int8_t;
00139 typedef signed short int16_t;
00140 typedef signed int int32_t;
00141 typedef longlong int64_t;
00142 typedef int intptr_t;
00143 typedef unsigned int uintptr_t;
00144 typedef int64_t intmax_t;
00145 typedef uint64_t uintmax_t;
00146 typedef uintptr_t size_t;
00147 typedef intptr_t ptrdiff_t;
00150
00151 ASSERT_COMPILE(sizeof(uintptr_t)==sizeof(void*));
00152 ASSERT_COMPILE(sizeof(intptr_t)==sizeof(void*));
00153
00154
00155 #if __GNUC__<4
00156
00159 #define offsetof(type,member) ((size_t)(&((type*)256)->member)-256)
00160 #else
00161 #define offsetof(type,member) __builtin_offsetof(type,member)
00162 #endif
00163
00164
00165 #if defined(__GNUC__) && defined(_ARM)
00166
00170 #define dummy_return(type) register type _r0 asm("r0"); asm("" : "=r"(_r0)); return _r0
00171
00172 #endif
00173
00174
00175 #ifndef COMPILE_FOR_SYMBIAN
00176
00180 inline void* operator new(size_t, void* ptr) throw()
00181 { return ptr; }
00182
00186 inline void operator delete(void*, void*) throw()
00187 { }
00188
00189 #endif // !COMPILE_FOR_SYMBIAN
00190
00191
00192 #endif