00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef OVR_Types_H
00018 #define OVR_Types_H
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #if (defined(__APPLE__) && (defined(__GNUC__) ||\
00032 defined(__xlC__) || defined(__xlc__))) || defined(__MACOS__)
00033 # if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED))
00034 # define OVR_OS_IPHONE
00035 # else
00036 # define OVR_OS_DARWIN
00037 # define OVR_OS_MAC
00038 # endif
00039 #elif (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
00040 # define OVR_OS_WIN32
00041 #elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
00042 # define OVR_OS_WIN32
00043 #elif defined(__linux__) || defined(__linux)
00044 # define OVR_OS_LINUX
00045 #else
00046 # define OVR_OS_OTHER
00047 #endif
00048
00049 #if defined(ANDROID)
00050 # define OVR_OS_ANDROID
00051 #endif
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067 #if defined(__x86_64__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
00068 # define OVR_CPU_X86_64
00069 # define OVR_64BIT_POINTERS
00070 #elif defined(__i386__) || defined(OVR_OS_WIN32)
00071 # define OVR_CPU_X86
00072 #elif defined(__powerpc64__)
00073 # define OVR_CPU_PPC64
00074 #elif defined(__ppc__)
00075 # define OVR_CPU_PPC
00076 #elif defined(__mips__) || defined(__MIPSEL__)
00077 # define OVR_CPU_MIPS
00078 #elif defined(__arm__)
00079 # define OVR_CPU_ARM
00080 #else
00081 # define OVR_CPU_OTHER
00082 #endif
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 #if defined(__SSE__) || defined(OVR_OS_WIN32)
00094 # define OVR_CPU_SSE
00095 #endif // __SSE__
00096
00097 #if defined( __ALTIVEC__ )
00098 # define OVR_CPU_ALTIVEC
00099 #endif // __ALTIVEC__
00100
00101 #if defined(__ARM_NEON__)
00102 # define OVR_CPU_ARM_NEON
00103 #endif // __ARM_NEON__
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 #if defined(__INTEL_COMPILER)
00117
00118
00119
00120
00121
00122 # define OVR_CC_INTEL __INTEL_COMPILER
00123
00124 #elif defined(_MSC_VER)
00125
00126
00127
00128
00129
00130
00131
00132 # define OVR_CC_MSVC _MSC_VER
00133
00134 #elif defined(__GNUC__)
00135 # define OVR_CC_GNU
00136
00137 #elif defined(__CC_ARM)
00138 # define OVR_CC_ARM
00139
00140 #else
00141 # error "Oculus does not support this Compiler"
00142 #endif
00143
00144
00145
00146
00147
00148
00149 #if defined(OVR_CC_MSVC)
00150 # pragma warning(disable : 4127) // Inconsistent dll linkage
00151 # pragma warning(disable : 4530) // Exception handling
00152 # if (OVR_CC_MSVC<1300)
00153 # pragma warning(disable : 4514) // Unreferenced inline function has been removed
00154 # pragma warning(disable : 4710) // Function not inlined
00155 # pragma warning(disable : 4714) // _force_inline not inlined
00156 # pragma warning(disable : 4786) // Debug variable name longer than 255 chars
00157 # endif // (OVR_CC_MSVC<1300)
00158 #endif // (OVR_CC_MSVC)
00159
00160
00161
00162
00163
00164 #ifdef OVR_OS_LINUX
00165
00166 # ifndef _GNU_SOURCE
00167 # define _GNU_SOURCE
00168 # endif
00169 #endif
00170
00171
00172
00173
00174 #include <stddef.h>
00175 #include <limits.h>
00176 #include <float.h>
00177
00178
00179
00180 #if defined(OVR_CC_MSVC) && defined(OVR_BUILD_DEBUG)
00181 # define _CRTDBG_MAP_ALLOC
00182 # include <stdlib.h>
00183 # include <crtdbg.h>
00184
00185
00186
00187 # ifndef OVR_DEFINE_NEW
00188 # define OVR_DEFINE_NEW new(__FILE__, __LINE__)
00189 # define new OVR_DEFINE_NEW
00190 # endif
00191
00192 #endif
00193
00194
00195
00196
00197
00198 namespace OVR {
00199
00200 typedef char Char;
00201
00202
00203 typedef size_t UPInt;
00204 typedef ptrdiff_t SPInt;
00205
00206
00207 #if defined(OVR_OS_WIN32)
00208
00209 typedef char SByte;
00210 typedef unsigned char UByte;
00211 typedef short SInt16;
00212 typedef unsigned short UInt16;
00213 typedef long SInt32;
00214 typedef unsigned long UInt32;
00215 typedef __int64 SInt64;
00216 typedef unsigned __int64 UInt64;
00217
00218
00219 #elif defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE) || defined(OVR_CC_GNU)
00220
00221 typedef int SByte __attribute__((__mode__ (__QI__)));
00222 typedef unsigned int UByte __attribute__((__mode__ (__QI__)));
00223 typedef int SInt16 __attribute__((__mode__ (__HI__)));
00224 typedef unsigned int UInt16 __attribute__((__mode__ (__HI__)));
00225 typedef int SInt32 __attribute__((__mode__ (__SI__)));
00226 typedef unsigned int UInt32 __attribute__((__mode__ (__SI__)));
00227 typedef int SInt64 __attribute__((__mode__ (__DI__)));
00228 typedef unsigned int UInt64 __attribute__((__mode__ (__DI__)));
00229
00230 #else
00231
00232 #include <sys/types.h>
00233 typedef int8_t SByte;
00234 typedef uint8_t UByte;
00235 typedef int16_t SInt16;
00236 typedef uint16_t UInt16;
00237 typedef int32_t SInt32;
00238 typedef uint32_t UInt32;
00239 typedef int64_t SInt64;
00240 typedef uint64_t UInt64;
00241
00242 #endif
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253 namespace BaseTypes
00254 {
00255 using OVR::UPInt;
00256 using OVR::SPInt;
00257 using OVR::UByte;
00258 using OVR::SByte;
00259 using OVR::UInt16;
00260 using OVR::SInt16;
00261 using OVR::UInt32;
00262 using OVR::SInt32;
00263 using OVR::UInt64;
00264 using OVR::SInt64;
00265 }
00266
00267 }
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286 #define OVR_LITTLE_ENDIAN 1
00287 #define OVR_BIG_ENDIAN 2
00288
00289
00290
00291 #if defined(OVR_CC_MSVC)
00292 # define OVR_FORCE_INLINE __forceinline
00293 #elif defined(OVR_CC_GNU)
00294 # define OVR_FORCE_INLINE __attribute__((always_inline))
00295 #else
00296 # define OVR_FORCE_INLINE inline
00297 #endif // OVR_CC_MSVC
00298
00299
00300 #if defined(OVR_OS_WIN32)
00301
00302
00303
00304
00305 #define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN
00306
00307
00308 #ifdef __cplusplus_cli
00309 # define OVR_FASTCALL __stdcall
00310 #else
00311 # define OVR_FASTCALL __fastcall
00312 #endif
00313
00314 #define OVR_STDCALL __stdcall
00315 #define OVR_CDECL __cdecl
00316
00317
00318
00319 #if defined(OVR_CC_MSVC)
00320 # define OVR_ASM _asm
00321 #else
00322 # define OVR_ASM asm
00323 #endif // (OVR_CC_MSVC)
00324
00325 #ifdef UNICODE
00326 # define OVR_STR(str) L##str
00327 #else
00328 # define OVR_STR(str) str
00329 #endif // UNICODE
00330
00331 #else
00332
00333
00334
00335 #if (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))|| \
00336 (defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN))
00337 # define OVR_BYTE_ORDER OVR_BIG_ENDIAN
00338 #elif (defined(__ARMEB__) || defined(OVR_CPU_PPC) || defined(OVR_CPU_PPC64))
00339 # define OVR_BYTE_ORDER OVR_BIG_ENDIAN
00340 #else
00341 # define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN
00342 #endif
00343
00344
00345 #define OVR_ASM __asm__
00346 #define OVR_ASM_PROC(procname) OVR_ASM
00347 #define OVR_ASM_END OVR_ASM
00348
00349
00350 #define OVR_FASTCALL
00351 #define OVR_STDCALL
00352 #define OVR_CDECL
00353
00354 #endif // defined(OVR_OS_WIN32)
00355
00356
00357
00358
00359
00360
00361
00362 #ifndef OVR_BUILD_DEBUG
00363
00364 # define OVR_DEBUG_BREAK ((void)0)
00365 # define OVR_ASSERT(p) ((void)0)
00366
00367 #else
00368
00369
00370 #if defined(OVR_OS_WIN32)
00371 # ifdef OVR_CPU_X86
00372 # if defined(__cplusplus_cli)
00373 # define OVR_DEBUG_BREAK do { __debugbreak(); } while(0)
00374 # elif defined(OVR_CC_GNU)
00375 # define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0)
00376 # else
00377 # define OVR_DEBUG_BREAK do { OVR_ASM int 3 } while (0)
00378 # endif
00379 # else
00380 # define OVR_DEBUG_BREAK do { __debugbreak(); } while(0)
00381 # endif
00382
00383 #elif defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64)
00384 # define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0)
00385 #else
00386 # define OVR_DEBUG_BREAK do { *((int *) 0) = 1; } while(0)
00387 #endif
00388
00389
00390 #define OVR_ASSERT(p) do { if (!(p)) { OVR_DEBUG_BREAK; } } while(0)
00391
00392 #endif // OVR_BUILD_DEBUG
00393
00394
00395
00396 #define OVR_COMPILER_ASSERT(x) { int zero = 0; switch(zero) {case 0: case x:;} }
00397
00398
00399
00400
00401
00402
00403
00404 #if defined(OVR_CC_GNU)
00405 # define OVR_UNUSED(a) do {__typeof__ (&a) __attribute__ ((unused)) __tmp = &a; } while(0)
00406 #else
00407 # define OVR_UNUSED(a) (a)
00408 #endif
00409
00410 #define OVR_UNUSED1(a1) OVR_UNUSED(a1)
00411 #define OVR_UNUSED2(a1,a2) OVR_UNUSED(a1); OVR_UNUSED(a2)
00412 #define OVR_UNUSED3(a1,a2,a3) OVR_UNUSED2(a1,a2); OVR_UNUSED(a3)
00413 #define OVR_UNUSED4(a1,a2,a3,a4) OVR_UNUSED3(a1,a2,a3); OVR_UNUSED(a4)
00414 #define OVR_UNUSED5(a1,a2,a3,a4,a5) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED(a5)
00415 #define OVR_UNUSED6(a1,a2,a3,a4,a5,a6) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED2(a5,a6)
00416 #define OVR_UNUSED7(a1,a2,a3,a4,a5,a6,a7) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED3(a5,a6,a7)
00417 #define OVR_UNUSED8(a1,a2,a3,a4,a5,a6,a7,a8) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED4(a5,a6,a7,a8)
00418 #define OVR_UNUSED9(a1,a2,a3,a4,a5,a6,a7,a8,a9) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED5(a5,a6,a7,a8,a9)
00419
00420
00421
00422
00423
00424
00425 #ifdef OVR_BUILD_DEBUG
00426 # define OVR_BUILD_STRING "Debug"
00427 #else
00428 # define OVR_BUILD_STRING "Release"
00429 #endif
00430
00431
00433
00434
00435
00436
00437 #ifdef OVR_BUILD_DEBUG
00438 #define OVR_DEBUG_STATEMENT(s) s
00439 #define OVR_DEBUG_SELECT(d, nd) d
00440 #else
00441 #define OVR_DEBUG_STATEMENT(s)
00442 #define OVR_DEBUG_SELECT(d, nd) nd
00443 #endif
00444
00445
00446 #define OVR_ENABLE_THREADS
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456 #endif // OVR_Types_h