00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00029 #ifndef __PLATFORM_H__
00030 #define __PLATFORM_H__
00031
00032
00033
00034
00035
00037
00038 #if defined(WINDOWS) || defined(_WINDOWS) || defined(_WIN32) || defined(_WIN64)
00039
00040 #define PLATFORM_NAME "Windows"
00041
00042 #define PATH_SEP '\\'
00043
00044 #endif
00045
00046
00047
00049
00050 #if defined(linux) || defined(__linux__)
00051
00052 #define PLATFORM_NAME "Linux"
00053
00054 #define PATH_SEP '/'
00055
00056 #endif
00057
00058
00059
00061
00062 #if defined(__FreeBSD__)
00063
00064 #define PLATFORM_NAME "FreeBSD"
00065
00066 #define PATH_SEP '/'
00067
00068 #endif
00069
00070 #if defined(__NetBSD__)
00071
00072 #define PLATFORM_NAME "NetBSD"
00073
00074 #define PATH_SEP '/'
00075
00076 #endif
00077
00078 #if defined(__OpenBSD__)
00079
00080 #define PLATFORM_NAME "OpenBSD"
00081
00082 #define PATH_SEP '/'
00083
00084 #endif
00085
00086
00087
00089
00090 #if defined(sun) || defined(__sun__)
00091
00092 #define PLATFORM_NAME "Solaris"
00093
00094 #define PATH_SEP '/'
00095
00096 #endif
00097
00098
00099
00101
00102 #if defined( macintosh )
00103
00104 #define PLATFORM_NAME "MAC OS"
00105
00106 #define PATH_SEP ':'
00107
00108 #endif
00109
00110
00111 #if defined(__APPLE__) && defined(__MACH__)
00112
00113 #define MACOS_X 1
00114
00115 #define PLATFORM_NAME "MAC OS X"
00116
00117 #define PATH_SEP ':'
00118
00119 #endif
00120
00121
00122
00124
00125 #ifndef PLATFORM_NAME
00126
00127 #define PLATFORM_NAME "Unknown OS"
00128 #define PATH_SEP '/'
00129
00130 #endif
00131
00132
00133
00134
00135
00136 #if defined(_M_IX86) || defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
00137
00138 #define CPUSTRING "x86"
00139 #define __ARCH_X86__ 1
00140
00141 #elif defined(_M_ALPHA) || defined(__alpha__)
00142
00143 #define CPUSTRING "Alpha"
00144
00145 #elif defined(__powerpc__)
00146
00147 #define CPUSTRING "PowerPC"
00148
00149 #elif defined(__sparc__)
00150
00151 #define CPUSTRING "Sparc"
00152
00153 #else
00154
00155 #define CPUSTRING "Unknown CPU"
00156
00157 #endif
00158
00159
00160
00161 #if defined(WINDOWS) || defined(_WINDOWS) || defined(_WIN32) || defined(_WIN64)
00162
00163 #define OS_WINDOWS 1
00164
00165 #else
00166
00167 #define OS_UNIX 1
00168
00169 #endif
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 #ifdef OS_WINDOWS
00182
00183 typedef unsigned __int8 W8, *PW8;
00184 typedef signed __int8 SW8, *PSW8;
00185 typedef unsigned __int16 W16, *PW16;
00186 typedef signed __int16 SW16, *PSW16;
00187 typedef unsigned __int32 W32, *PW32;
00188 typedef signed __int32 SW32, *PSW32;
00189 typedef unsigned __int64 W64, *PW64;
00190 typedef signed __int64 SW64, *PSW64;
00191
00192 #elif OS_UNIX
00193
00194 #include <inttypes.h>
00195
00196 typedef uint8_t W8, *PW8;
00197 typedef int8_t SW8, *PSW8;
00198 typedef uint16_t W16, *PW16;
00199 typedef int16_t SW16, *PSW16;
00200 typedef uint32_t W32, *PW32;
00201 typedef int32_t SW32, *PSW32;
00202 typedef uint64_t W64, *PW64;
00203 typedef int64_t SW64, *PSW64;
00204
00205 #endif
00206
00207
00208
00209 #ifndef NULL
00210
00211 #ifdef __cplusplus
00212 #define NULL 0
00213 #else
00214 #define NULL ((void *)0)
00215 #endif
00216
00217 #endif
00218
00219
00220
00221
00222 #ifndef INLINECALL
00223
00224 #if defined(__cplusplus) || defined(__GNUC__)
00225
00226 #define INLINECALL inline
00227
00228 #elif defined(_WIN32) && !defined(__WATCOMC__)
00229
00230 #define INLINECALL __inline
00231
00232 #else
00233
00234 #define INLINECALL
00235
00236 #endif
00237
00238 #endif
00239
00240
00241
00242 typedef enum
00243 {
00244
00245 false = 0,
00246 true = 1
00247
00248 } wtBoolean;
00249
00250
00251
00252
00253 #define Swap16( x ) ( ( (((W16) (x)) & 0x00FF) << 8 ) | ( (((W16) (x))& 0xFF00) >> 8) )
00254 #define Swap32( x ) ( ( ((W32) (x)) & 0xFF000000) >> 24 ) | ( ((( (W32) (x) ) & 0xFF0000) >> 8) ) | ( ((( (W32) (x) ) & 0xFF00) << 8 ) ) | ( (( (W32) (x) ) & 0xFF) << 24 )
00255 #define Swap64( x ) ( ( Swap32( (x) & 0xFFFFFFFF ) << 32 ) | Swap32( (x) >> 32 ) )
00256
00257
00258 #if defined(__ARCH_X86__) // Little endian
00259
00260
00261 #define LITTLE_ENDIAN_SYSTEM 1
00262
00263
00264 #define BigShort( x ) Swap16( x )
00265 #define LittleShort( x ) ( x )
00266
00267 #define BigLong( x ) Swap32( x )
00268 #define LittleLong( x ) ( x )
00269
00270 #define BigFloat( x ) SwapFloat( x )
00271 #define LittleFloat( x ) ( x )
00272
00273 #define Big64( x ) Swap64( x )
00274 #define Little64( x ) ( x )
00275
00276
00277 #else // Big endian
00278
00279 #define BIG_ENDIAN_SYSTEM 1
00280
00281
00282 #define BigShort( x ) ( x )
00283 #define LittleShort( x ) Swap16( x )
00284
00285 #define BigLong( x ) ( x )
00286 #define LittleLong( x ) Swap32( x )
00287
00288 #define BigFloat( x ) ( x )
00289 #define LittleFloat( x ) SwapFloat( x )
00290
00291 #define Big64( x ) ( x )
00292 #define Little64( x ) Swap64( x )
00293
00294 #endif
00295
00296
00297
00298
00299
00300 #endif
00301