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 IMPORT __declspec(dllexport)
00050 #define EXPORT __declspec(dllexport)
00051 #define ASSERT(c) {if(!(c)) BREAKPOINT;}
00052 typedef __int64 longlong;
00053 typedef unsigned __int64 ulonglong;
00054
00055
00056 #pragma warning( disable : 4244 )
00057 #pragma warning( disable : 4514 )
00058 #pragma warning( disable : 4146 )
00059 #pragma warning( disable : 4710 )
00060 #pragma warning( disable : 4355 )
00061 #pragma warning( disable : 4512 )
00062 #pragma warning( disable : 4800 )
00063
00064 #elif defined(__EPOC32__) || defined(__WINS__)
00065
00066
00067 #define COMPILE_FOR_SYMBIAN
00068 #include <e32std.h>
00069
00070 #if !defined(__BREAKPOINT)
00071
00072 #if defined(__WINS__)
00073
00074 #if defined(__WINSCW__)
00075 #define BREAKPOINT { _asm byte 0xcc }
00076 #else
00077 #define BREAKPOINT { _asm int 3 }
00078 #endif
00079
00080 #else
00081 #define BREAKPOINT
00082 #endif
00083
00084 #else
00085 #define BREAKPOINT {__BREAKPOINT()}
00086 #endif
00087
00088 #define IMPORT IMPORT_C
00089 #define EXPORT EXPORT_C
00091 #undef ASSERT
00092 #define ASSERT(c) {if(!(c)) BREAKPOINT;}
00094 #if !defined(DEBUG) && defined(_DEBUG)
00095 #define DEBUG
00096 #endif
00097
00098 typedef TInt64 longlong;
00099 typedef TUint64 ulonglong;
00100
00101
00102 #else
00103
00104 #define BREAKPOINT
00105 #define IMPORT
00106 #define EXPORT
00107 #define ASSERT(c) (void)(c)
00108 typedef long long longlong;
00109 typedef unsigned long long ulonglong;
00110
00111 #endif
00112
00113
00114 #ifdef DEBUG
00115 #define ASSERT_DEBUG(c) ASSERT(c)
00116 #else
00117 #define ASSERT_DEBUG(c)
00118 #endif
00119
00120
00121 #ifndef ASSERT_COMPILE
00122
00123 #define ASSERT_COMPILE(c) void assert_compile(int assert_compile[(c)?1:-1])
00124 #endif
00125
00126
00127 #ifndef NULL
00128 #define NULL 0
00129 #endif
00130
00131
00141 typedef unsigned char uint8_t;
00142 typedef unsigned short uint16_t;
00143 typedef unsigned int uint32_t;
00144 typedef ulonglong uint64_t;
00145 typedef signed char int8_t;
00146 typedef signed short int16_t;
00147 typedef signed int int32_t;
00148 typedef longlong int64_t;
00149 typedef int intptr_t;
00150 typedef unsigned int uintptr_t;
00151 typedef int64_t intmax_t;
00152 typedef uint64_t uintmax_t;
00153 typedef uintptr_t size_t;
00154 typedef intptr_t ptrdiff_t;
00157
00158 ASSERT_COMPILE(sizeof(uintptr_t)==sizeof(void*));
00159 ASSERT_COMPILE(sizeof(intptr_t)==sizeof(void*));
00160
00161
00165 #define INT_BITS (sizeof(int)*8)
00166
00167
00172 #define LOG2(x) ((unsigned)(\
00173 (unsigned)(x)<=(unsigned)(1<< 0) ? 0 : (unsigned)(x)<=(unsigned)(1<< 1) ? 1 : (unsigned)(x)<=(unsigned)(1<< 2) ? 2 : (unsigned)(x)<=(unsigned)(1<< 3) ? 3 : \
00174 (unsigned)(x)<=(unsigned)(1<< 4) ? 4 : (unsigned)(x)<=(unsigned)(1<< 5) ? 5 : (unsigned)(x)<=(unsigned)(1<< 6) ? 6 : (unsigned)(x)<=(unsigned)(1<< 7) ? 7 : \
00175 (unsigned)(x)<=(unsigned)(1<< 8) ? 8 : (unsigned)(x)<=(unsigned)(1<< 9) ? 9 : (unsigned)(x)<=(unsigned)(1<<10) ? 10 : (unsigned)(x)<=(unsigned)(1<<11) ? 11 : \
00176 (unsigned)(x)<=(unsigned)(1<<12) ? 12 : (unsigned)(x)<=(unsigned)(1<<13) ? 13 : (unsigned)(x)<=(unsigned)(1<<14) ? 14 : (unsigned)(x)<=(unsigned)(1<<15) ? 15 : \
00177 (unsigned)(x)<=(unsigned)(1<<16) ? 16 : (unsigned)(x)<=(unsigned)(1<<17) ? 17 : (unsigned)(x)<=(unsigned)(1<<18) ? 18 : (unsigned)(x)<=(unsigned)(1<<19) ? 19 : \
00178 (unsigned)(x)<=(unsigned)(1<<20) ? 20 : (unsigned)(x)<=(unsigned)(1<<21) ? 21 : (unsigned)(x)<=(unsigned)(1<<22) ? 22 : (unsigned)(x)<=(unsigned)(1<<23) ? 23 : \
00179 (unsigned)(x)<=(unsigned)(1<<24) ? 24 : (unsigned)(x)<=(unsigned)(1<<25) ? 25 : (unsigned)(x)<=(unsigned)(1<<26) ? 26 : (unsigned)(x)<=(unsigned)(1<<27) ? 27 : \
00180 (unsigned)(x)<=(unsigned)(1<<28) ? 28 : (unsigned)(x)<=(unsigned)(1<<29) ? 29 : (unsigned)(x)<=(unsigned)(1<<30) ? 30 : (unsigned)(x)<=(unsigned)(1<<31) ? 31 : \
00181 32))
00182
00183
00184 #if __GNUC__<4
00185
00188 #define offsetof(type,member) ((size_t)(&((type*)256)->member)-256)
00189 #else
00190 #define offsetof(type,member) __builtin_offsetof(type,member)
00191 #endif
00192
00193
00194 #if defined(__GNUC__) && defined(_ARM)
00195
00199 #define dummy_return(type) register type _r0 asm("r0"); asm("" : "=r"(_r0)); return _r0
00200
00201 #endif
00202
00203
00204 #ifndef COMPILE_FOR_SYMBIAN
00205
00209 inline void* operator new(size_t, void* ptr) throw()
00210 { return ptr; }
00211
00215 inline void operator delete(void*, void*) throw()
00216 { }
00217
00218 #endif // !COMPILE_FOR_SYMBIAN
00219
00220
00221 #endif