oculus1
diff libovr/Src/Kernel/OVR_Types.h @ 3:b069a5c27388
added a couple more stuff, fixed all the LibOVR line endings
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 15 Sep 2013 04:10:05 +0300 |
parents | e2f9e4603129 |
children |
line diff
1.1 --- a/libovr/Src/Kernel/OVR_Types.h Sat Sep 14 17:51:03 2013 +0300 1.2 +++ b/libovr/Src/Kernel/OVR_Types.h Sun Sep 15 04:10:05 2013 +0300 1.3 @@ -1,1 +1,456 @@ 1.4 -/************************************************************************************ 1.5 1.6 PublicHeader: OVR.h 1.7 Filename : OVR_Types.h 1.8 Content : Standard library defines and simple types 1.9 Created : September 19, 2012 1.10 Notes : 1.11 1.12 Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. 1.13 1.14 Use of this software is subject to the terms of the Oculus license 1.15 agreement provided at the time of installation or download, or which 1.16 otherwise accompanies this software in either electronic or hard copy form. 1.17 1.18 ************************************************************************************/ 1.19 1.20 #ifndef OVR_Types_H 1.21 #define OVR_Types_H 1.22 1.23 //----------------------------------------------------------------------------------- 1.24 // ****** Operating System 1.25 // 1.26 // Type definitions exist for the following operating systems: (OVR_OS_x) 1.27 // 1.28 // WIN32 - Win32 (Windows 95/98/ME and Windows NT/2000/XP) 1.29 // DARWIN - Darwin OS (Mac OS X) 1.30 // LINUX - Linux 1.31 // ANDROID - Android 1.32 // IPHONE - iPhone 1.33 1.34 #if (defined(__APPLE__) && (defined(__GNUC__) ||\ 1.35 defined(__xlC__) || defined(__xlc__))) || defined(__MACOS__) 1.36 # if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)) 1.37 # define OVR_OS_IPHONE 1.38 # else 1.39 # define OVR_OS_DARWIN 1.40 # define OVR_OS_MAC 1.41 # endif 1.42 #elif (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) 1.43 # define OVR_OS_WIN32 1.44 #elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) 1.45 # define OVR_OS_WIN32 1.46 #elif defined(__linux__) || defined(__linux) 1.47 # define OVR_OS_LINUX 1.48 #else 1.49 # define OVR_OS_OTHER 1.50 #endif 1.51 1.52 #if defined(ANDROID) 1.53 # define OVR_OS_ANDROID 1.54 #endif 1.55 1.56 1.57 //----------------------------------------------------------------------------------- 1.58 // ***** CPU Architecture 1.59 // 1.60 // The following CPUs are defined: (OVR_CPU_x) 1.61 // 1.62 // X86 - x86 (IA-32) 1.63 // X86_64 - x86_64 (amd64) 1.64 // PPC - PowerPC 1.65 // PPC64 - PowerPC64 1.66 // MIPS - MIPS 1.67 // OTHER - CPU for which no special support is present or needed 1.68 1.69 1.70 #if defined(__x86_64__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) 1.71 # define OVR_CPU_X86_64 1.72 # define OVR_64BIT_POINTERS 1.73 #elif defined(__i386__) || defined(OVR_OS_WIN32) 1.74 # define OVR_CPU_X86 1.75 #elif defined(__powerpc64__) 1.76 # define OVR_CPU_PPC64 1.77 #elif defined(__ppc__) 1.78 # define OVR_CPU_PPC 1.79 #elif defined(__mips__) || defined(__MIPSEL__) 1.80 # define OVR_CPU_MIPS 1.81 #elif defined(__arm__) 1.82 # define OVR_CPU_ARM 1.83 #else 1.84 # define OVR_CPU_OTHER 1.85 #endif 1.86 1.87 //----------------------------------------------------------------------------------- 1.88 // ***** Co-Processor Architecture 1.89 // 1.90 // The following co-processors are defined: (OVR_CPU_x) 1.91 // 1.92 // SSE - Available on all modern x86 processors. 1.93 // Altivec - Available on all modern ppc processors. 1.94 // Neon - Available on some armv7+ processors. 1.95 1.96 #if defined(__SSE__) || defined(OVR_OS_WIN32) 1.97 # define OVR_CPU_SSE 1.98 #endif // __SSE__ 1.99 1.100 #if defined( __ALTIVEC__ ) 1.101 # define OVR_CPU_ALTIVEC 1.102 #endif // __ALTIVEC__ 1.103 1.104 #if defined(__ARM_NEON__) 1.105 # define OVR_CPU_ARM_NEON 1.106 #endif // __ARM_NEON__ 1.107 1.108 1.109 //----------------------------------------------------------------------------------- 1.110 // ***** Compiler 1.111 // 1.112 // The following compilers are defined: (OVR_CC_x) 1.113 // 1.114 // MSVC - Microsoft Visual C/C++ 1.115 // INTEL - Intel C++ for Linux / Windows 1.116 // GNU - GNU C++ 1.117 // ARM - ARM C/C++ 1.118 1.119 #if defined(__INTEL_COMPILER) 1.120 // Intel 4.0 = 400 1.121 // Intel 5.0 = 500 1.122 // Intel 6.0 = 600 1.123 // Intel 8.0 = 800 1.124 // Intel 9.0 = 900 1.125 # define OVR_CC_INTEL __INTEL_COMPILER 1.126 1.127 #elif defined(_MSC_VER) 1.128 // MSVC 5.0 = 1100 1.129 // MSVC 6.0 = 1200 1.130 // MSVC 7.0 (VC2002) = 1300 1.131 // MSVC 7.1 (VC2003) = 1310 1.132 // MSVC 8.0 (VC2005) = 1400 1.133 // MSVC 9.0 (VC2008) = 1500 1.134 // MSVC 10.0 (VC2010) = 1600 1.135 # define OVR_CC_MSVC _MSC_VER 1.136 1.137 #elif defined(__GNUC__) 1.138 # define OVR_CC_GNU 1.139 1.140 #elif defined(__CC_ARM) 1.141 # define OVR_CC_ARM 1.142 1.143 #else 1.144 # error "Oculus does not support this Compiler" 1.145 #endif 1.146 1.147 1.148 //----------------------------------------------------------------------------------- 1.149 // ***** Compiler Warnings 1.150 1.151 // Disable MSVC warnings 1.152 #if defined(OVR_CC_MSVC) 1.153 # pragma warning(disable : 4127) // Inconsistent dll linkage 1.154 # pragma warning(disable : 4530) // Exception handling 1.155 # if (OVR_CC_MSVC<1300) 1.156 # pragma warning(disable : 4514) // Unreferenced inline function has been removed 1.157 # pragma warning(disable : 4710) // Function not inlined 1.158 # pragma warning(disable : 4714) // _force_inline not inlined 1.159 # pragma warning(disable : 4786) // Debug variable name longer than 255 chars 1.160 # endif // (OVR_CC_MSVC<1300) 1.161 #endif // (OVR_CC_MSVC) 1.162 1.163 1.164 1.165 // *** Linux Unicode - must come before Standard Includes 1.166 1.167 #ifdef OVR_OS_LINUX 1.168 // Use glibc unicode functions on linux. 1.169 # ifndef _GNU_SOURCE 1.170 # define _GNU_SOURCE 1.171 # endif 1.172 #endif 1.173 1.174 //----------------------------------------------------------------------------------- 1.175 // ***** Standard Includes 1.176 // 1.177 #include <stddef.h> 1.178 #include <limits.h> 1.179 #include <float.h> 1.180 1.181 1.182 // MSVC Based Memory Leak checking - for now 1.183 #if defined(OVR_CC_MSVC) && defined(OVR_BUILD_DEBUG) 1.184 # define _CRTDBG_MAP_ALLOC 1.185 # include <stdlib.h> 1.186 # include <crtdbg.h> 1.187 1.188 // Uncomment this to help debug memory leaks under Visual Studio in OVR apps only. 1.189 // This shouldn't be defined in customer releases. 1.190 # ifndef OVR_DEFINE_NEW 1.191 # define OVR_DEFINE_NEW new(__FILE__, __LINE__) 1.192 # define new OVR_DEFINE_NEW 1.193 # endif 1.194 1.195 #endif 1.196 1.197 1.198 //----------------------------------------------------------------------------------- 1.199 // ***** Type definitions for Common Systems 1.200 1.201 namespace OVR { 1.202 1.203 typedef char Char; 1.204 1.205 // Pointer-sized integer 1.206 typedef size_t UPInt; 1.207 typedef ptrdiff_t SPInt; 1.208 1.209 1.210 #if defined(OVR_OS_WIN32) 1.211 1.212 typedef char SByte; // 8 bit Integer (Byte) 1.213 typedef unsigned char UByte; 1.214 typedef short SInt16; // 16 bit Integer (Word) 1.215 typedef unsigned short UInt16; 1.216 typedef long SInt32; // 32 bit Integer 1.217 typedef unsigned long UInt32; 1.218 typedef __int64 SInt64; // 64 bit Integer (QWord) 1.219 typedef unsigned __int64 UInt64; 1.220 1.221 1.222 #elif defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE) || defined(OVR_CC_GNU) 1.223 1.224 typedef int SByte __attribute__((__mode__ (__QI__))); 1.225 typedef unsigned int UByte __attribute__((__mode__ (__QI__))); 1.226 typedef int SInt16 __attribute__((__mode__ (__HI__))); 1.227 typedef unsigned int UInt16 __attribute__((__mode__ (__HI__))); 1.228 typedef int SInt32 __attribute__((__mode__ (__SI__))); 1.229 typedef unsigned int UInt32 __attribute__((__mode__ (__SI__))); 1.230 typedef int SInt64 __attribute__((__mode__ (__DI__))); 1.231 typedef unsigned int UInt64 __attribute__((__mode__ (__DI__))); 1.232 1.233 #else 1.234 1.235 #include <sys/types.h> 1.236 typedef int8_t SByte; 1.237 typedef uint8_t UByte; 1.238 typedef int16_t SInt16; 1.239 typedef uint16_t UInt16; 1.240 typedef int32_t SInt32; 1.241 typedef uint32_t UInt32; 1.242 typedef int64_t SInt64; 1.243 typedef uint64_t UInt64; 1.244 1.245 #endif 1.246 1.247 1.248 // ***** BaseTypes Namespace 1.249 1.250 // BaseTypes namespace is explicitly declared to allow base types to be used 1.251 // by customers directly without other contents of OVR namespace. 1.252 // 1.253 // Its is expected that GFx samples will declare 'using namespace OVR::BaseTypes' 1.254 // to allow using these directly without polluting the target scope with other 1.255 // OVR declarations, such as Ptr<>, String or Mutex. 1.256 namespace BaseTypes 1.257 { 1.258 using OVR::UPInt; 1.259 using OVR::SPInt; 1.260 using OVR::UByte; 1.261 using OVR::SByte; 1.262 using OVR::UInt16; 1.263 using OVR::SInt16; 1.264 using OVR::UInt32; 1.265 using OVR::SInt32; 1.266 using OVR::UInt64; 1.267 using OVR::SInt64; 1.268 } // OVR::BaseTypes 1.269 1.270 } // OVR 1.271 1.272 1.273 //----------------------------------------------------------------------------------- 1.274 // ***** Macro Definitions 1.275 // 1.276 // We define the following: 1.277 // 1.278 // OVR_BYTE_ORDER - Defined to either OVR_LITTLE_ENDIAN or OVR_BIG_ENDIAN 1.279 // OVR_FORCE_INLINE - Forces inline expansion of function 1.280 // OVR_ASM - Assembly language prefix 1.281 // OVR_STR - Prefixes string with L"" if building unicode 1.282 // 1.283 // OVR_STDCALL - Use stdcall calling convention (Pascal arg order) 1.284 // OVR_CDECL - Use cdecl calling convention (C argument order) 1.285 // OVR_FASTCALL - Use fastcall calling convention (registers) 1.286 // 1.287 1.288 // Byte order constants, OVR_BYTE_ORDER is defined to be one of these. 1.289 #define OVR_LITTLE_ENDIAN 1 1.290 #define OVR_BIG_ENDIAN 2 1.291 1.292 1.293 // Force inline substitute - goes before function declaration 1.294 #if defined(OVR_CC_MSVC) 1.295 # define OVR_FORCE_INLINE __forceinline 1.296 #elif defined(OVR_CC_GNU) 1.297 # define OVR_FORCE_INLINE __attribute__((always_inline)) inline 1.298 #else 1.299 # define OVR_FORCE_INLINE inline 1.300 #endif // OVR_CC_MSVC 1.301 1.302 1.303 #if defined(OVR_OS_WIN32) 1.304 1.305 // ***** Win32 1.306 1.307 // Byte order 1.308 #define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN 1.309 1.310 // Calling convention - goes after function return type but before function name 1.311 #ifdef __cplusplus_cli 1.312 # define OVR_FASTCALL __stdcall 1.313 #else 1.314 # define OVR_FASTCALL __fastcall 1.315 #endif 1.316 1.317 #define OVR_STDCALL __stdcall 1.318 #define OVR_CDECL __cdecl 1.319 1.320 1.321 // Assembly macros 1.322 #if defined(OVR_CC_MSVC) 1.323 # define OVR_ASM _asm 1.324 #else 1.325 # define OVR_ASM asm 1.326 #endif // (OVR_CC_MSVC) 1.327 1.328 #ifdef UNICODE 1.329 # define OVR_STR(str) L##str 1.330 #else 1.331 # define OVR_STR(str) str 1.332 #endif // UNICODE 1.333 1.334 #else 1.335 1.336 // **** Standard systems 1.337 1.338 #if (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))|| \ 1.339 (defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)) 1.340 # define OVR_BYTE_ORDER OVR_BIG_ENDIAN 1.341 #elif (defined(__ARMEB__) || defined(OVR_CPU_PPC) || defined(OVR_CPU_PPC64)) 1.342 # define OVR_BYTE_ORDER OVR_BIG_ENDIAN 1.343 #else 1.344 # define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN 1.345 #endif 1.346 1.347 // Assembly macros 1.348 #define OVR_ASM __asm__ 1.349 #define OVR_ASM_PROC(procname) OVR_ASM 1.350 #define OVR_ASM_END OVR_ASM 1.351 1.352 // Calling convention - goes after function return type but before function name 1.353 #define OVR_FASTCALL 1.354 #define OVR_STDCALL 1.355 #define OVR_CDECL 1.356 1.357 #endif // defined(OVR_OS_WIN32) 1.358 1.359 1.360 1.361 //----------------------------------------------------------------------------------- 1.362 // ***** OVR_DEBUG_BREAK, OVR_ASSERT 1.363 // 1.364 // If not in debug build, macros do nothing 1.365 #ifndef OVR_BUILD_DEBUG 1.366 1.367 # define OVR_DEBUG_BREAK ((void)0) 1.368 # define OVR_ASSERT(p) ((void)0) 1.369 1.370 #else 1.371 1.372 // Microsoft Win32 specific debugging support 1.373 #if defined(OVR_OS_WIN32) 1.374 # ifdef OVR_CPU_X86 1.375 # if defined(__cplusplus_cli) 1.376 # define OVR_DEBUG_BREAK do { __debugbreak(); } while(0) 1.377 # elif defined(OVR_CC_GNU) 1.378 # define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0) 1.379 # else 1.380 # define OVR_DEBUG_BREAK do { OVR_ASM int 3 } while (0) 1.381 # endif 1.382 # else 1.383 # define OVR_DEBUG_BREAK do { __debugbreak(); } while(0) 1.384 # endif 1.385 // Unix specific debugging support 1.386 #elif defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) 1.387 # define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0) 1.388 #else 1.389 # define OVR_DEBUG_BREAK do { *((int *) 0) = 1; } while(0) 1.390 #endif 1.391 1.392 // This will cause compiler breakpoint 1.393 #define OVR_ASSERT(p) do { if (!(p)) { OVR_DEBUG_BREAK; } } while(0) 1.394 1.395 #endif // OVR_BUILD_DEBUG 1.396 1.397 1.398 // Compile-time assert; produces compiler error if condition is false 1.399 #define OVR_COMPILER_ASSERT(x) { int zero = 0; switch(zero) {case 0: case x:;} } 1.400 1.401 1.402 1.403 //----------------------------------------------------------------------------------- 1.404 // ***** OVR_UNUSED - Unused Argument handling 1.405 1.406 // Macro to quiet compiler warnings about unused parameters/variables. 1.407 #if defined(OVR_CC_GNU) 1.408 # define OVR_UNUSED(a) do {__typeof__ (&a) __attribute__ ((unused)) __tmp = &a; } while(0) 1.409 #else 1.410 # define OVR_UNUSED(a) (a) 1.411 #endif 1.412 1.413 #define OVR_UNUSED1(a1) OVR_UNUSED(a1) 1.414 #define OVR_UNUSED2(a1,a2) OVR_UNUSED(a1); OVR_UNUSED(a2) 1.415 #define OVR_UNUSED3(a1,a2,a3) OVR_UNUSED2(a1,a2); OVR_UNUSED(a3) 1.416 #define OVR_UNUSED4(a1,a2,a3,a4) OVR_UNUSED3(a1,a2,a3); OVR_UNUSED(a4) 1.417 #define OVR_UNUSED5(a1,a2,a3,a4,a5) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED(a5) 1.418 #define OVR_UNUSED6(a1,a2,a3,a4,a5,a6) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED2(a5,a6) 1.419 #define OVR_UNUSED7(a1,a2,a3,a4,a5,a6,a7) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED3(a5,a6,a7) 1.420 #define OVR_UNUSED8(a1,a2,a3,a4,a5,a6,a7,a8) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED4(a5,a6,a7,a8) 1.421 #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) 1.422 1.423 1.424 //----------------------------------------------------------------------------------- 1.425 // ***** Configuration Macros 1.426 1.427 // SF Build type 1.428 #ifdef OVR_BUILD_DEBUG 1.429 # define OVR_BUILD_STRING "Debug" 1.430 #else 1.431 # define OVR_BUILD_STRING "Release" 1.432 #endif 1.433 1.434 1.435 //// Enables SF Debugging information 1.436 //# define OVR_BUILD_DEBUG 1.437 1.438 // OVR_DEBUG_STATEMENT injects a statement only in debug builds. 1.439 // OVR_DEBUG_SELECT injects first argument in debug builds, second argument otherwise. 1.440 #ifdef OVR_BUILD_DEBUG 1.441 #define OVR_DEBUG_STATEMENT(s) s 1.442 #define OVR_DEBUG_SELECT(d, nd) d 1.443 #else 1.444 #define OVR_DEBUG_STATEMENT(s) 1.445 #define OVR_DEBUG_SELECT(d, nd) nd 1.446 #endif 1.447 1.448 1.449 #define OVR_ENABLE_THREADS 1.450 // 1.451 // Prevents OVR from defining new within 1.452 // type macros, so developers can override 1.453 // new using the #define new new(...) trick 1.454 // - used with OVR_DEFINE_NEW macro 1.455 //# define OVR_BUILD_DEFINE_NEW 1.456 // 1.457 1.458 1.459 #endif // OVR_Types_h 1.460 \ No newline at end of file 1.461 +/************************************************************************************ 1.462 + 1.463 +PublicHeader: OVR.h 1.464 +Filename : OVR_Types.h 1.465 +Content : Standard library defines and simple types 1.466 +Created : September 19, 2012 1.467 +Notes : 1.468 + 1.469 +Copyright : Copyright 2012 Oculus VR, Inc. All Rights reserved. 1.470 + 1.471 +Use of this software is subject to the terms of the Oculus license 1.472 +agreement provided at the time of installation or download, or which 1.473 +otherwise accompanies this software in either electronic or hard copy form. 1.474 + 1.475 +************************************************************************************/ 1.476 + 1.477 +#ifndef OVR_Types_H 1.478 +#define OVR_Types_H 1.479 + 1.480 +//----------------------------------------------------------------------------------- 1.481 +// ****** Operating System 1.482 +// 1.483 +// Type definitions exist for the following operating systems: (OVR_OS_x) 1.484 +// 1.485 +// WIN32 - Win32 (Windows 95/98/ME and Windows NT/2000/XP) 1.486 +// DARWIN - Darwin OS (Mac OS X) 1.487 +// LINUX - Linux 1.488 +// ANDROID - Android 1.489 +// IPHONE - iPhone 1.490 + 1.491 +#if (defined(__APPLE__) && (defined(__GNUC__) ||\ 1.492 + defined(__xlC__) || defined(__xlc__))) || defined(__MACOS__) 1.493 +# if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED)) 1.494 +# define OVR_OS_IPHONE 1.495 +# else 1.496 +# define OVR_OS_DARWIN 1.497 +# define OVR_OS_MAC 1.498 +# endif 1.499 +#elif (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) 1.500 +# define OVR_OS_WIN32 1.501 +#elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) 1.502 +# define OVR_OS_WIN32 1.503 +#elif defined(__linux__) || defined(__linux) 1.504 +# define OVR_OS_LINUX 1.505 +#else 1.506 +# define OVR_OS_OTHER 1.507 +#endif 1.508 + 1.509 +#if defined(ANDROID) 1.510 +# define OVR_OS_ANDROID 1.511 +#endif 1.512 + 1.513 + 1.514 +//----------------------------------------------------------------------------------- 1.515 +// ***** CPU Architecture 1.516 +// 1.517 +// The following CPUs are defined: (OVR_CPU_x) 1.518 +// 1.519 +// X86 - x86 (IA-32) 1.520 +// X86_64 - x86_64 (amd64) 1.521 +// PPC - PowerPC 1.522 +// PPC64 - PowerPC64 1.523 +// MIPS - MIPS 1.524 +// OTHER - CPU for which no special support is present or needed 1.525 + 1.526 + 1.527 +#if defined(__x86_64__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) 1.528 +# define OVR_CPU_X86_64 1.529 +# define OVR_64BIT_POINTERS 1.530 +#elif defined(__i386__) || defined(OVR_OS_WIN32) 1.531 +# define OVR_CPU_X86 1.532 +#elif defined(__powerpc64__) 1.533 +# define OVR_CPU_PPC64 1.534 +#elif defined(__ppc__) 1.535 +# define OVR_CPU_PPC 1.536 +#elif defined(__mips__) || defined(__MIPSEL__) 1.537 +# define OVR_CPU_MIPS 1.538 +#elif defined(__arm__) 1.539 +# define OVR_CPU_ARM 1.540 +#else 1.541 +# define OVR_CPU_OTHER 1.542 +#endif 1.543 + 1.544 +//----------------------------------------------------------------------------------- 1.545 +// ***** Co-Processor Architecture 1.546 +// 1.547 +// The following co-processors are defined: (OVR_CPU_x) 1.548 +// 1.549 +// SSE - Available on all modern x86 processors. 1.550 +// Altivec - Available on all modern ppc processors. 1.551 +// Neon - Available on some armv7+ processors. 1.552 + 1.553 +#if defined(__SSE__) || defined(OVR_OS_WIN32) 1.554 +# define OVR_CPU_SSE 1.555 +#endif // __SSE__ 1.556 + 1.557 +#if defined( __ALTIVEC__ ) 1.558 +# define OVR_CPU_ALTIVEC 1.559 +#endif // __ALTIVEC__ 1.560 + 1.561 +#if defined(__ARM_NEON__) 1.562 +# define OVR_CPU_ARM_NEON 1.563 +#endif // __ARM_NEON__ 1.564 + 1.565 + 1.566 +//----------------------------------------------------------------------------------- 1.567 +// ***** Compiler 1.568 +// 1.569 +// The following compilers are defined: (OVR_CC_x) 1.570 +// 1.571 +// MSVC - Microsoft Visual C/C++ 1.572 +// INTEL - Intel C++ for Linux / Windows 1.573 +// GNU - GNU C++ 1.574 +// ARM - ARM C/C++ 1.575 + 1.576 +#if defined(__INTEL_COMPILER) 1.577 +// Intel 4.0 = 400 1.578 +// Intel 5.0 = 500 1.579 +// Intel 6.0 = 600 1.580 +// Intel 8.0 = 800 1.581 +// Intel 9.0 = 900 1.582 +# define OVR_CC_INTEL __INTEL_COMPILER 1.583 + 1.584 +#elif defined(_MSC_VER) 1.585 +// MSVC 5.0 = 1100 1.586 +// MSVC 6.0 = 1200 1.587 +// MSVC 7.0 (VC2002) = 1300 1.588 +// MSVC 7.1 (VC2003) = 1310 1.589 +// MSVC 8.0 (VC2005) = 1400 1.590 +// MSVC 9.0 (VC2008) = 1500 1.591 +// MSVC 10.0 (VC2010) = 1600 1.592 +# define OVR_CC_MSVC _MSC_VER 1.593 + 1.594 +#elif defined(__GNUC__) 1.595 +# define OVR_CC_GNU 1.596 + 1.597 +#elif defined(__CC_ARM) 1.598 +# define OVR_CC_ARM 1.599 + 1.600 +#else 1.601 +# error "Oculus does not support this Compiler" 1.602 +#endif 1.603 + 1.604 + 1.605 +//----------------------------------------------------------------------------------- 1.606 +// ***** Compiler Warnings 1.607 + 1.608 +// Disable MSVC warnings 1.609 +#if defined(OVR_CC_MSVC) 1.610 +# pragma warning(disable : 4127) // Inconsistent dll linkage 1.611 +# pragma warning(disable : 4530) // Exception handling 1.612 +# if (OVR_CC_MSVC<1300) 1.613 +# pragma warning(disable : 4514) // Unreferenced inline function has been removed 1.614 +# pragma warning(disable : 4710) // Function not inlined 1.615 +# pragma warning(disable : 4714) // _force_inline not inlined 1.616 +# pragma warning(disable : 4786) // Debug variable name longer than 255 chars 1.617 +# endif // (OVR_CC_MSVC<1300) 1.618 +#endif // (OVR_CC_MSVC) 1.619 + 1.620 + 1.621 + 1.622 +// *** Linux Unicode - must come before Standard Includes 1.623 + 1.624 +#ifdef OVR_OS_LINUX 1.625 +// Use glibc unicode functions on linux. 1.626 +# ifndef _GNU_SOURCE 1.627 +# define _GNU_SOURCE 1.628 +# endif 1.629 +#endif 1.630 + 1.631 +//----------------------------------------------------------------------------------- 1.632 +// ***** Standard Includes 1.633 +// 1.634 +#include <stddef.h> 1.635 +#include <limits.h> 1.636 +#include <float.h> 1.637 + 1.638 + 1.639 +// MSVC Based Memory Leak checking - for now 1.640 +#if defined(OVR_CC_MSVC) && defined(OVR_BUILD_DEBUG) 1.641 +# define _CRTDBG_MAP_ALLOC 1.642 +# include <stdlib.h> 1.643 +# include <crtdbg.h> 1.644 + 1.645 +// Uncomment this to help debug memory leaks under Visual Studio in OVR apps only. 1.646 +// This shouldn't be defined in customer releases. 1.647 +# ifndef OVR_DEFINE_NEW 1.648 +# define OVR_DEFINE_NEW new(__FILE__, __LINE__) 1.649 +# define new OVR_DEFINE_NEW 1.650 +# endif 1.651 + 1.652 +#endif 1.653 + 1.654 + 1.655 +//----------------------------------------------------------------------------------- 1.656 +// ***** Type definitions for Common Systems 1.657 + 1.658 +namespace OVR { 1.659 + 1.660 +typedef char Char; 1.661 + 1.662 +// Pointer-sized integer 1.663 +typedef size_t UPInt; 1.664 +typedef ptrdiff_t SPInt; 1.665 + 1.666 + 1.667 +#if defined(OVR_OS_WIN32) 1.668 + 1.669 +typedef char SByte; // 8 bit Integer (Byte) 1.670 +typedef unsigned char UByte; 1.671 +typedef short SInt16; // 16 bit Integer (Word) 1.672 +typedef unsigned short UInt16; 1.673 +typedef long SInt32; // 32 bit Integer 1.674 +typedef unsigned long UInt32; 1.675 +typedef __int64 SInt64; // 64 bit Integer (QWord) 1.676 +typedef unsigned __int64 UInt64; 1.677 + 1.678 + 1.679 +#elif defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE) || defined(OVR_CC_GNU) 1.680 + 1.681 +typedef int SByte __attribute__((__mode__ (__QI__))); 1.682 +typedef unsigned int UByte __attribute__((__mode__ (__QI__))); 1.683 +typedef int SInt16 __attribute__((__mode__ (__HI__))); 1.684 +typedef unsigned int UInt16 __attribute__((__mode__ (__HI__))); 1.685 +typedef int SInt32 __attribute__((__mode__ (__SI__))); 1.686 +typedef unsigned int UInt32 __attribute__((__mode__ (__SI__))); 1.687 +typedef int SInt64 __attribute__((__mode__ (__DI__))); 1.688 +typedef unsigned int UInt64 __attribute__((__mode__ (__DI__))); 1.689 + 1.690 +#else 1.691 + 1.692 +#include <sys/types.h> 1.693 +typedef int8_t SByte; 1.694 +typedef uint8_t UByte; 1.695 +typedef int16_t SInt16; 1.696 +typedef uint16_t UInt16; 1.697 +typedef int32_t SInt32; 1.698 +typedef uint32_t UInt32; 1.699 +typedef int64_t SInt64; 1.700 +typedef uint64_t UInt64; 1.701 + 1.702 +#endif 1.703 + 1.704 + 1.705 +// ***** BaseTypes Namespace 1.706 + 1.707 +// BaseTypes namespace is explicitly declared to allow base types to be used 1.708 +// by customers directly without other contents of OVR namespace. 1.709 +// 1.710 +// Its is expected that GFx samples will declare 'using namespace OVR::BaseTypes' 1.711 +// to allow using these directly without polluting the target scope with other 1.712 +// OVR declarations, such as Ptr<>, String or Mutex. 1.713 +namespace BaseTypes 1.714 +{ 1.715 + using OVR::UPInt; 1.716 + using OVR::SPInt; 1.717 + using OVR::UByte; 1.718 + using OVR::SByte; 1.719 + using OVR::UInt16; 1.720 + using OVR::SInt16; 1.721 + using OVR::UInt32; 1.722 + using OVR::SInt32; 1.723 + using OVR::UInt64; 1.724 + using OVR::SInt64; 1.725 +} // OVR::BaseTypes 1.726 + 1.727 +} // OVR 1.728 + 1.729 + 1.730 +//----------------------------------------------------------------------------------- 1.731 +// ***** Macro Definitions 1.732 +// 1.733 +// We define the following: 1.734 +// 1.735 +// OVR_BYTE_ORDER - Defined to either OVR_LITTLE_ENDIAN or OVR_BIG_ENDIAN 1.736 +// OVR_FORCE_INLINE - Forces inline expansion of function 1.737 +// OVR_ASM - Assembly language prefix 1.738 +// OVR_STR - Prefixes string with L"" if building unicode 1.739 +// 1.740 +// OVR_STDCALL - Use stdcall calling convention (Pascal arg order) 1.741 +// OVR_CDECL - Use cdecl calling convention (C argument order) 1.742 +// OVR_FASTCALL - Use fastcall calling convention (registers) 1.743 +// 1.744 + 1.745 +// Byte order constants, OVR_BYTE_ORDER is defined to be one of these. 1.746 +#define OVR_LITTLE_ENDIAN 1 1.747 +#define OVR_BIG_ENDIAN 2 1.748 + 1.749 + 1.750 +// Force inline substitute - goes before function declaration 1.751 +#if defined(OVR_CC_MSVC) 1.752 +# define OVR_FORCE_INLINE __forceinline 1.753 +#elif defined(OVR_CC_GNU) 1.754 +# define OVR_FORCE_INLINE __attribute__((always_inline)) inline 1.755 +#else 1.756 +# define OVR_FORCE_INLINE inline 1.757 +#endif // OVR_CC_MSVC 1.758 + 1.759 + 1.760 +#if defined(OVR_OS_WIN32) 1.761 + 1.762 + // ***** Win32 1.763 + 1.764 + // Byte order 1.765 + #define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN 1.766 + 1.767 + // Calling convention - goes after function return type but before function name 1.768 + #ifdef __cplusplus_cli 1.769 + # define OVR_FASTCALL __stdcall 1.770 + #else 1.771 + # define OVR_FASTCALL __fastcall 1.772 + #endif 1.773 + 1.774 + #define OVR_STDCALL __stdcall 1.775 + #define OVR_CDECL __cdecl 1.776 + 1.777 + 1.778 + // Assembly macros 1.779 + #if defined(OVR_CC_MSVC) 1.780 + # define OVR_ASM _asm 1.781 + #else 1.782 + # define OVR_ASM asm 1.783 + #endif // (OVR_CC_MSVC) 1.784 + 1.785 + #ifdef UNICODE 1.786 + # define OVR_STR(str) L##str 1.787 + #else 1.788 + # define OVR_STR(str) str 1.789 + #endif // UNICODE 1.790 + 1.791 +#else 1.792 + 1.793 + // **** Standard systems 1.794 + 1.795 + #if (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))|| \ 1.796 + (defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN)) 1.797 + # define OVR_BYTE_ORDER OVR_BIG_ENDIAN 1.798 + #elif (defined(__ARMEB__) || defined(OVR_CPU_PPC) || defined(OVR_CPU_PPC64)) 1.799 + # define OVR_BYTE_ORDER OVR_BIG_ENDIAN 1.800 + #else 1.801 + # define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN 1.802 + #endif 1.803 + 1.804 + // Assembly macros 1.805 + #define OVR_ASM __asm__ 1.806 + #define OVR_ASM_PROC(procname) OVR_ASM 1.807 + #define OVR_ASM_END OVR_ASM 1.808 + 1.809 + // Calling convention - goes after function return type but before function name 1.810 + #define OVR_FASTCALL 1.811 + #define OVR_STDCALL 1.812 + #define OVR_CDECL 1.813 + 1.814 +#endif // defined(OVR_OS_WIN32) 1.815 + 1.816 + 1.817 + 1.818 +//----------------------------------------------------------------------------------- 1.819 +// ***** OVR_DEBUG_BREAK, OVR_ASSERT 1.820 +// 1.821 +// If not in debug build, macros do nothing 1.822 +#ifndef OVR_BUILD_DEBUG 1.823 + 1.824 +# define OVR_DEBUG_BREAK ((void)0) 1.825 +# define OVR_ASSERT(p) ((void)0) 1.826 + 1.827 +#else 1.828 + 1.829 +// Microsoft Win32 specific debugging support 1.830 +#if defined(OVR_OS_WIN32) 1.831 +# ifdef OVR_CPU_X86 1.832 +# if defined(__cplusplus_cli) 1.833 +# define OVR_DEBUG_BREAK do { __debugbreak(); } while(0) 1.834 +# elif defined(OVR_CC_GNU) 1.835 +# define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0) 1.836 +# else 1.837 +# define OVR_DEBUG_BREAK do { OVR_ASM int 3 } while (0) 1.838 +# endif 1.839 +# else 1.840 +# define OVR_DEBUG_BREAK do { __debugbreak(); } while(0) 1.841 +# endif 1.842 +// Unix specific debugging support 1.843 +#elif defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64) 1.844 +# define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0) 1.845 +#else 1.846 +# define OVR_DEBUG_BREAK do { *((int *) 0) = 1; } while(0) 1.847 +#endif 1.848 + 1.849 +// This will cause compiler breakpoint 1.850 +#define OVR_ASSERT(p) do { if (!(p)) { OVR_DEBUG_BREAK; } } while(0) 1.851 + 1.852 +#endif // OVR_BUILD_DEBUG 1.853 + 1.854 + 1.855 +// Compile-time assert; produces compiler error if condition is false 1.856 +#define OVR_COMPILER_ASSERT(x) { int zero = 0; switch(zero) {case 0: case x:;} } 1.857 + 1.858 + 1.859 + 1.860 +//----------------------------------------------------------------------------------- 1.861 +// ***** OVR_UNUSED - Unused Argument handling 1.862 + 1.863 +// Macro to quiet compiler warnings about unused parameters/variables. 1.864 +#if defined(OVR_CC_GNU) 1.865 +# define OVR_UNUSED(a) do {__typeof__ (&a) __attribute__ ((unused)) __tmp = &a; } while(0) 1.866 +#else 1.867 +# define OVR_UNUSED(a) (a) 1.868 +#endif 1.869 + 1.870 +#define OVR_UNUSED1(a1) OVR_UNUSED(a1) 1.871 +#define OVR_UNUSED2(a1,a2) OVR_UNUSED(a1); OVR_UNUSED(a2) 1.872 +#define OVR_UNUSED3(a1,a2,a3) OVR_UNUSED2(a1,a2); OVR_UNUSED(a3) 1.873 +#define OVR_UNUSED4(a1,a2,a3,a4) OVR_UNUSED3(a1,a2,a3); OVR_UNUSED(a4) 1.874 +#define OVR_UNUSED5(a1,a2,a3,a4,a5) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED(a5) 1.875 +#define OVR_UNUSED6(a1,a2,a3,a4,a5,a6) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED2(a5,a6) 1.876 +#define OVR_UNUSED7(a1,a2,a3,a4,a5,a6,a7) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED3(a5,a6,a7) 1.877 +#define OVR_UNUSED8(a1,a2,a3,a4,a5,a6,a7,a8) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED4(a5,a6,a7,a8) 1.878 +#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) 1.879 + 1.880 + 1.881 +//----------------------------------------------------------------------------------- 1.882 +// ***** Configuration Macros 1.883 + 1.884 +// SF Build type 1.885 +#ifdef OVR_BUILD_DEBUG 1.886 +# define OVR_BUILD_STRING "Debug" 1.887 +#else 1.888 +# define OVR_BUILD_STRING "Release" 1.889 +#endif 1.890 + 1.891 + 1.892 +//// Enables SF Debugging information 1.893 +//# define OVR_BUILD_DEBUG 1.894 + 1.895 +// OVR_DEBUG_STATEMENT injects a statement only in debug builds. 1.896 +// OVR_DEBUG_SELECT injects first argument in debug builds, second argument otherwise. 1.897 +#ifdef OVR_BUILD_DEBUG 1.898 +#define OVR_DEBUG_STATEMENT(s) s 1.899 +#define OVR_DEBUG_SELECT(d, nd) d 1.900 +#else 1.901 +#define OVR_DEBUG_STATEMENT(s) 1.902 +#define OVR_DEBUG_SELECT(d, nd) nd 1.903 +#endif 1.904 + 1.905 + 1.906 +#define OVR_ENABLE_THREADS 1.907 +// 1.908 +// Prevents OVR from defining new within 1.909 +// type macros, so developers can override 1.910 +// new using the #define new new(...) trick 1.911 +// - used with OVR_DEFINE_NEW macro 1.912 +//# define OVR_BUILD_DEFINE_NEW 1.913 +// 1.914 + 1.915 + 1.916 +#endif // OVR_Types_h