ovr_sdk

annotate LibOVR/Src/Kernel/OVR_Types.h @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
rev   line source
nuclear@0 1 /************************************************************************************
nuclear@0 2
nuclear@0 3 PublicHeader: OVR_Kernel.h
nuclear@0 4 Filename : OVR_Types.h
nuclear@0 5 Content : Standard library defines and simple types
nuclear@0 6 Created : September 19, 2012
nuclear@0 7 Notes :
nuclear@0 8
nuclear@0 9 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
nuclear@0 10
nuclear@0 11 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
nuclear@0 12 you may not use the Oculus VR Rift SDK except in compliance with the License,
nuclear@0 13 which is provided at the time of installation or download, or which
nuclear@0 14 otherwise accompanies this software in either electronic or hard copy form.
nuclear@0 15
nuclear@0 16 You may obtain a copy of the License at
nuclear@0 17
nuclear@0 18 http://www.oculusvr.com/licenses/LICENSE-3.2
nuclear@0 19
nuclear@0 20 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
nuclear@0 21 distributed under the License is distributed on an "AS IS" BASIS,
nuclear@0 22 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nuclear@0 23 See the License for the specific language governing permissions and
nuclear@0 24 limitations under the License.
nuclear@0 25
nuclear@0 26 ************************************************************************************/
nuclear@0 27
nuclear@0 28 #ifndef OVR_Types_H
nuclear@0 29 #define OVR_Types_H
nuclear@0 30
nuclear@0 31 #include "OVR_Compiler.h"
nuclear@0 32
nuclear@0 33
nuclear@0 34 // Unsupported compiler configurations
nuclear@0 35 #if _MSC_VER == 0x1600
nuclear@0 36 # if _MSC_FULL_VER < 160040219
nuclear@0 37 # error "Oculus does not support VS2010 without SP1 installed: It will crash in Release mode"
nuclear@0 38 # endif
nuclear@0 39 #endif
nuclear@0 40
nuclear@0 41
nuclear@0 42 //-----------------------------------------------------------------------------------
nuclear@0 43 // ****** Operating system identification
nuclear@0 44 //
nuclear@0 45 // Try to use the most generic version of these defines as possible in order to achieve
nuclear@0 46 // the simplest portable code. For example, instead of using #if (defined(OVR_OS_IPHONE) || defined(OVR_OS_MAC)),
nuclear@0 47 // consider using #if defined(OVR_OS_APPLE).
nuclear@0 48 //
nuclear@0 49 // Type definitions exist for the following operating systems: (OVR_OS_x)
nuclear@0 50 //
nuclear@0 51 // WIN32 - Win32 and Win64 (Windows XP and later) Does not include Microsoft phone and console platforms, despite that Microsoft's _WIN32 may be defined by the compiler for them.
nuclear@0 52 // WIN64 - Win64 (Windows XP and later)
nuclear@0 53 // MAC - Mac OS X (may be defined in addition to BSD)
nuclear@0 54 // LINUX - Linux
nuclear@0 55 // BSD - BSD Unix
nuclear@0 56 // ANDROID - Android (may be defined in addition to LINUX)
nuclear@0 57 // IPHONE - iPhone
nuclear@0 58 // MS_MOBILE - Microsoft mobile OS.
nuclear@0 59 //
nuclear@0 60 // Meta platforms
nuclear@0 61 // MS - Any OS by Microsoft (e.g. Win32, Win64, phone, console)
nuclear@0 62 // APPLE - Any OS by Apple (e.g. iOS, OS X)
nuclear@0 63 // UNIX - Linux, BSD, Mac OS X.
nuclear@0 64 // MOBILE - iOS, Android, Microsoft phone
nuclear@0 65 // CONSOLE - Console platforms
nuclear@0 66 //
nuclear@0 67
nuclear@0 68 #if (defined(__APPLE__) && (defined(__GNUC__) ||\
nuclear@0 69 defined(__xlC__) || defined(__xlc__))) || defined(__MACOS__)
nuclear@0 70 # if (defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__) || defined(__IPHONE_OS_VERSION_MIN_REQUIRED))
nuclear@0 71 # define OVR_OS_IPHONE
nuclear@0 72 # else
nuclear@0 73 # define OVR_OS_DARWIN
nuclear@0 74 # define OVR_OS_MAC
nuclear@0 75 # define OVR_OS_BSD
nuclear@0 76 # endif
nuclear@0 77 #elif (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
nuclear@0 78 # define OVR_OS_WIN64
nuclear@0 79 # define OVR_OS_WIN32 // Defined for compatibility and because the Win64 API supports the Win32 API.
nuclear@0 80 #elif (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
nuclear@0 81 # define OVR_OS_WIN32
nuclear@0 82 #elif defined(ANDROID) || defined(__ANDROID__)
nuclear@0 83 # define OVR_OS_ANDROID
nuclear@0 84 # define OVR_OS_LINUX
nuclear@0 85 #elif defined(__linux__) || defined(__linux)
nuclear@0 86 # define OVR_OS_LINUX
nuclear@0 87 #elif defined(_BSD_) || defined(__FreeBSD__)
nuclear@0 88 # define OVR_OS_BSD
nuclear@0 89 #else
nuclear@0 90 # define OVR_OS_OTHER
nuclear@0 91 #endif
nuclear@0 92
nuclear@0 93 #if !defined(OVR_OS_MS_MOBILE)
nuclear@0 94 # if (defined(_M_ARM) || defined(_M_IX86) || defined(_M_AMD64)) && !defined(OVR_OS_WIN32) && !defined(OVR_OS_CONSOLE)
nuclear@0 95 # define OVR_OS_MS_MOBILE
nuclear@0 96 # endif
nuclear@0 97 #endif
nuclear@0 98
nuclear@0 99 #if !defined(OVR_OS_MS)
nuclear@0 100 # if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64) || defined(OVR_OS_MS_MOBILE)
nuclear@0 101 # define OVR_OS_MS
nuclear@0 102 # endif
nuclear@0 103 #endif
nuclear@0 104
nuclear@0 105 #if !defined(OVR_OS_APPLE)
nuclear@0 106 # if defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE)
nuclear@0 107 # define OVR_OS_APPLE
nuclear@0 108 # endif
nuclear@0 109 #endif
nuclear@0 110
nuclear@0 111 #if !defined(OVR_OS_UNIX)
nuclear@0 112 # if defined(OVR_OS_ANDROID) || defined(OVR_OS_BSD) || defined(OVR_OS_LINUX) || defined(OVR_OS_MAC)
nuclear@0 113 # define OVR_OS_UNIX
nuclear@0 114 # endif
nuclear@0 115 #endif
nuclear@0 116
nuclear@0 117 #if !defined(OVR_OS_MOBILE)
nuclear@0 118 # if defined(OVR_OS_ANDROID) || defined(OVR_OS_IPHONE) || defined(OVR_OS_MS_MOBILE)
nuclear@0 119 # define OVR_OS_MOBILE
nuclear@0 120 # endif
nuclear@0 121 #endif
nuclear@0 122
nuclear@0 123
nuclear@0 124
nuclear@0 125
nuclear@0 126 //-----------------------------------------------------------------------------------
nuclear@0 127 // ***** CPU Architecture
nuclear@0 128 //
nuclear@0 129 // The following CPUs are defined: (OVR_CPU_x)
nuclear@0 130 //
nuclear@0 131 // X86 - x86 (IA-32)
nuclear@0 132 // X86_64 - x86_64 (amd64)
nuclear@0 133 // PPC - PowerPC
nuclear@0 134 // PPC64 - PowerPC64
nuclear@0 135 // MIPS - MIPS
nuclear@0 136 // OTHER - CPU for which no special support is present or needed
nuclear@0 137
nuclear@0 138
nuclear@0 139 #if defined(__x86_64__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64__) || defined(_M_AMD64)
nuclear@0 140 # define OVR_CPU_X86_64
nuclear@0 141 # define OVR_64BIT_POINTERS
nuclear@0 142 #elif defined(__i386__) || defined(OVR_OS_WIN32)
nuclear@0 143 # define OVR_CPU_X86
nuclear@0 144 #elif defined(__powerpc64__)
nuclear@0 145 # define OVR_CPU_PPC64
nuclear@0 146 #elif defined(__ppc__)
nuclear@0 147 # define OVR_CPU_PPC
nuclear@0 148 #elif defined(__mips__) || defined(__MIPSEL__)
nuclear@0 149 # define OVR_CPU_MIPS
nuclear@0 150 #elif defined(__arm__)
nuclear@0 151 # define OVR_CPU_ARM
nuclear@0 152 #else
nuclear@0 153 # define OVR_CPU_OTHER
nuclear@0 154 #endif
nuclear@0 155
nuclear@0 156 //-----------------------------------------------------------------------------------
nuclear@0 157 // ***** Co-Processor Architecture
nuclear@0 158 //
nuclear@0 159 // The following co-processors are defined: (OVR_CPU_x)
nuclear@0 160 //
nuclear@0 161 // SSE - Available on all modern x86 processors.
nuclear@0 162 // Altivec - Available on all modern ppc processors.
nuclear@0 163 // Neon - Available on some armv7+ processors.
nuclear@0 164
nuclear@0 165 #if defined(__SSE__) || defined(_M_IX86) || defined(_M_AMD64) // _M_IX86 and _M_AMD64 are Microsoft identifiers for Intel-based platforms.
nuclear@0 166 # define OVR_CPU_SSE
nuclear@0 167 #endif // __SSE__
nuclear@0 168
nuclear@0 169 #if defined( __ALTIVEC__ )
nuclear@0 170 # define OVR_CPU_ALTIVEC
nuclear@0 171 #endif // __ALTIVEC__
nuclear@0 172
nuclear@0 173 #if defined(__ARM_NEON__)
nuclear@0 174 # define OVR_CPU_ARM_NEON
nuclear@0 175 #endif // __ARM_NEON__
nuclear@0 176
nuclear@0 177
nuclear@0 178 //-----------------------------------------------------------------------------------
nuclear@0 179 // ***** Compiler Warnings
nuclear@0 180
nuclear@0 181 // Disable MSVC warnings
nuclear@0 182 #if defined(OVR_CC_MSVC)
nuclear@0 183 # pragma warning(disable : 4127) // Inconsistent dll linkage
nuclear@0 184 # pragma warning(disable : 4530) // Exception handling
nuclear@0 185 # if (OVR_CC_MSVC<1300)
nuclear@0 186 # pragma warning(disable : 4514) // Unreferenced inline function has been removed
nuclear@0 187 # pragma warning(disable : 4710) // Function not inlined
nuclear@0 188 # pragma warning(disable : 4714) // _force_inline not inlined
nuclear@0 189 # pragma warning(disable : 4786) // Debug variable name longer than 255 chars
nuclear@0 190 # endif // (OVR_CC_MSVC<1300)
nuclear@0 191 #endif // (OVR_CC_MSVC)
nuclear@0 192
nuclear@0 193
nuclear@0 194
nuclear@0 195 // *** Linux Unicode - must come before Standard Includes
nuclear@0 196
nuclear@0 197 #ifdef OVR_OS_LINUX
nuclear@0 198 // Use glibc unicode functions on linux.
nuclear@0 199 # ifndef _GNU_SOURCE
nuclear@0 200 # define _GNU_SOURCE
nuclear@0 201 # endif
nuclear@0 202 #endif
nuclear@0 203
nuclear@0 204 //-----------------------------------------------------------------------------------
nuclear@0 205 // ***** Standard Includes
nuclear@0 206 //
nuclear@0 207 #include <stddef.h>
nuclear@0 208 #include <limits.h>
nuclear@0 209 #include <float.h>
nuclear@0 210
nuclear@0 211
nuclear@0 212 // MSVC Based Memory Leak checking - for now
nuclear@0 213 #if defined(OVR_CC_MSVC) && defined(OVR_BUILD_DEBUG)
nuclear@0 214 # define _CRTDBG_MAP_ALLOC
nuclear@0 215 # include <stdlib.h>
nuclear@0 216 # include <crtdbg.h>
nuclear@0 217 #endif
nuclear@0 218
nuclear@0 219
nuclear@0 220 //-----------------------------------------------------------------------------------
nuclear@0 221 // ***** int8_t, int16_t, etc.
nuclear@0 222
nuclear@0 223 #if defined(OVR_CC_MSVC) && (OVR_CC_VER <= 1500) // VS2008 and earlier
nuclear@0 224 typedef signed char int8_t;
nuclear@0 225 typedef unsigned char uint8_t;
nuclear@0 226 typedef signed short int16_t;
nuclear@0 227 typedef unsigned short uint16_t;
nuclear@0 228 typedef signed int int32_t;
nuclear@0 229 typedef unsigned int uint32_t;
nuclear@0 230 typedef signed __int64 int64_t;
nuclear@0 231 typedef unsigned __int64 uint64_t;
nuclear@0 232 #else
nuclear@0 233 #include <stdint.h>
nuclear@0 234 #endif
nuclear@0 235
nuclear@0 236
nuclear@0 237 //-----------------------------------------------------------------------------------
nuclear@0 238 // ***** Type definitions for Common Systems
nuclear@0 239
nuclear@0 240 namespace OVR {
nuclear@0 241
nuclear@0 242 typedef char Char;
nuclear@0 243
nuclear@0 244 // Pointer-sized integer
nuclear@0 245 typedef size_t UPInt;
nuclear@0 246 typedef ptrdiff_t SPInt;
nuclear@0 247
nuclear@0 248
nuclear@0 249 #if defined(OVR_OS_MS)
nuclear@0 250
nuclear@0 251 typedef char SByte; // 8 bit Integer (Byte)
nuclear@0 252 typedef unsigned char UByte;
nuclear@0 253 typedef short SInt16; // 16 bit Integer (Word)
nuclear@0 254 typedef unsigned short UInt16;
nuclear@0 255 typedef long SInt32; // 32 bit Integer
nuclear@0 256 typedef unsigned long UInt32;
nuclear@0 257 typedef __int64 SInt64; // 64 bit Integer (QWord)
nuclear@0 258 typedef unsigned __int64 UInt64;
nuclear@0 259
nuclear@0 260
nuclear@0 261 #elif defined(OVR_OS_MAC) || defined(OVR_OS_IPHONE) || defined(OVR_CC_GNU)
nuclear@0 262
nuclear@0 263 typedef int SByte __attribute__((__mode__ (__QI__)));
nuclear@0 264 typedef unsigned int UByte __attribute__((__mode__ (__QI__)));
nuclear@0 265 typedef int SInt16 __attribute__((__mode__ (__HI__)));
nuclear@0 266 typedef unsigned int UInt16 __attribute__((__mode__ (__HI__)));
nuclear@0 267 typedef int SInt32 __attribute__((__mode__ (__SI__)));
nuclear@0 268 typedef unsigned int UInt32 __attribute__((__mode__ (__SI__)));
nuclear@0 269 typedef int SInt64 __attribute__((__mode__ (__DI__)));
nuclear@0 270 typedef unsigned int UInt64 __attribute__((__mode__ (__DI__)));
nuclear@0 271
nuclear@0 272 #else
nuclear@0 273
nuclear@0 274 #include <sys/types.h>
nuclear@0 275 typedef int8_t SByte;
nuclear@0 276 typedef uint8_t UByte;
nuclear@0 277 typedef int16_t SInt16;
nuclear@0 278 typedef uint16_t UInt16;
nuclear@0 279 typedef int32_t SInt32;
nuclear@0 280 typedef uint32_t UInt32;
nuclear@0 281 typedef int64_t SInt64;
nuclear@0 282 typedef uint64_t UInt64;
nuclear@0 283
nuclear@0 284 #endif
nuclear@0 285
nuclear@0 286
nuclear@0 287 //osx PID is a signed int32 (already defined to pid_t in OSX framework)
nuclear@0 288 //linux PID is a signed int32 (already defined)
nuclear@0 289 //win32 PID is an unsigned int64
nuclear@0 290 #ifdef OVR_OS_WIN32
nuclear@0 291 //process ID representation
nuclear@0 292 typedef unsigned long pid_t;
nuclear@0 293 #endif
nuclear@0 294
nuclear@0 295 struct OVR_GUID
nuclear@0 296 {
nuclear@0 297 uint32_t Data1;
nuclear@0 298 uint16_t Data2;
nuclear@0 299 uint16_t Data3;
nuclear@0 300 uint8_t Data4[8];
nuclear@0 301 };
nuclear@0 302
nuclear@0 303
nuclear@0 304
nuclear@0 305 } // OVR
nuclear@0 306
nuclear@0 307
nuclear@0 308
nuclear@0 309 //-----------------------------------------------------------------------------------
nuclear@0 310 // ****** Standard C/C++ Library
nuclear@0 311 //
nuclear@0 312 // Identifies which standard library is currently being used.
nuclear@0 313 //
nuclear@0 314 // LIBSTDCPP - GNU libstdc++, used by GCC.
nuclear@0 315 // LIBCPP - LLVM libc++, typically used by clang and GCC.
nuclear@0 316 // DINKUMWARE - Used by Microsoft and various non-Microsoft compilers (e.g. Sony clang).
nuclear@0 317
nuclear@0 318 #if !defined(OVR_STDLIB_LIBSTDCPP)
nuclear@0 319 #if defined(__GLIBCXX__)
nuclear@0 320 #define OVR_STDLIB_LIBSTDCPP 1
nuclear@0 321 #endif
nuclear@0 322 #endif
nuclear@0 323
nuclear@0 324 #if !defined(OVR_STDLIB_LIBCPP)
nuclear@0 325 #if defined(__clang__)
nuclear@0 326 #if defined(__cplusplus) && __has_include(<__config>)
nuclear@0 327 #define OVR_STDLIB_LIBCPP 1
nuclear@0 328 #endif
nuclear@0 329 #endif
nuclear@0 330 #endif
nuclear@0 331
nuclear@0 332 #if !defined(OVR_STDLIB_DINKUMWARE)
nuclear@0 333 #if defined(_YVALS) // Dinkumware globally #defines _YVALS from the #includes above.
nuclear@0 334 #define OVR_STDLIB_DINKUMWARE 1
nuclear@0 335 #endif
nuclear@0 336 #endif
nuclear@0 337
nuclear@0 338
nuclear@0 339 //-----------------------------------------------------------------------------------
nuclear@0 340 // ***** Macro Definitions
nuclear@0 341 //
nuclear@0 342 // We define the following:
nuclear@0 343 //
nuclear@0 344 // OVR_BYTE_ORDER - Defined to either OVR_LITTLE_ENDIAN or OVR_BIG_ENDIAN
nuclear@0 345 // OVR_FORCE_INLINE - Forces inline expansion of function
nuclear@0 346 // OVR_ASM - Assembly language prefix
nuclear@0 347 // OVR_STR - Prefixes string with L"" if building unicode
nuclear@0 348 //
nuclear@0 349 // OVR_STDCALL - Use stdcall calling convention (Pascal arg order)
nuclear@0 350 // OVR_CDECL - Use cdecl calling convention (C argument order)
nuclear@0 351 // OVR_FASTCALL - Use fastcall calling convention (registers)
nuclear@0 352 //
nuclear@0 353
nuclear@0 354 // Byte order constants, OVR_BYTE_ORDER is defined to be one of these.
nuclear@0 355 #define OVR_LITTLE_ENDIAN 1
nuclear@0 356 #define OVR_BIG_ENDIAN 2
nuclear@0 357
nuclear@0 358
nuclear@0 359 #if defined(OVR_OS_MS)
nuclear@0 360
nuclear@0 361 // ***** Windows and non-desktop platforms
nuclear@0 362
nuclear@0 363 // Byte order
nuclear@0 364 #define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN
nuclear@0 365
nuclear@0 366 // Calling convention - goes after function return type but before function name
nuclear@0 367 #ifdef __cplusplus_cli
nuclear@0 368 # define OVR_FASTCALL __stdcall
nuclear@0 369 #else
nuclear@0 370 # define OVR_FASTCALL __fastcall
nuclear@0 371 #endif
nuclear@0 372
nuclear@0 373 #define OVR_STDCALL __stdcall
nuclear@0 374 #define OVR_CDECL __cdecl
nuclear@0 375
nuclear@0 376
nuclear@0 377 // Assembly macros
nuclear@0 378 #if defined(OVR_CC_MSVC)
nuclear@0 379 # define OVR_ASM _asm
nuclear@0 380 #else
nuclear@0 381 # define OVR_ASM asm
nuclear@0 382 #endif // (OVR_CC_MSVC)
nuclear@0 383
nuclear@0 384 #ifdef UNICODE
nuclear@0 385 # define OVR_STR(str) L##str
nuclear@0 386 #else
nuclear@0 387 # define OVR_STR(str) str
nuclear@0 388 #endif // UNICODE
nuclear@0 389
nuclear@0 390 #else
nuclear@0 391
nuclear@0 392 // **** Standard systems
nuclear@0 393
nuclear@0 394 #if (defined(BYTE_ORDER) && (BYTE_ORDER == BIG_ENDIAN))|| \
nuclear@0 395 (defined(_BYTE_ORDER) && (_BYTE_ORDER == _BIG_ENDIAN))
nuclear@0 396 # define OVR_BYTE_ORDER OVR_BIG_ENDIAN
nuclear@0 397 #elif (defined(__ARMEB__) || defined(OVR_CPU_PPC) || defined(OVR_CPU_PPC64))
nuclear@0 398 # define OVR_BYTE_ORDER OVR_BIG_ENDIAN
nuclear@0 399 #else
nuclear@0 400 # define OVR_BYTE_ORDER OVR_LITTLE_ENDIAN
nuclear@0 401 #endif
nuclear@0 402
nuclear@0 403 // Assembly macros
nuclear@0 404 #define OVR_ASM __asm__
nuclear@0 405 #define OVR_ASM_PROC(procname) OVR_ASM
nuclear@0 406 #define OVR_ASM_END OVR_ASM
nuclear@0 407
nuclear@0 408 // Calling convention - goes after function return type but before function name
nuclear@0 409 #define OVR_FASTCALL
nuclear@0 410 #define OVR_STDCALL
nuclear@0 411 #define OVR_CDECL
nuclear@0 412
nuclear@0 413 #endif // defined(OVR_OS_WIN32)
nuclear@0 414
nuclear@0 415
nuclear@0 416 //-----------------------------------------------------------------------------------
nuclear@0 417 // ***** OVR_PTR_SIZE
nuclear@0 418 //
nuclear@0 419 // Specifies the byte size of pointers (same as sizeof void*).
nuclear@0 420
nuclear@0 421 #if !defined(OVR_PTR_SIZE)
nuclear@0 422 #if defined(__WORDSIZE)
nuclear@0 423 #define OVR_PTR_SIZE ((__WORDSIZE) / 8)
nuclear@0 424 #elif defined(_WIN64) || defined(__LP64__) || defined(_LP64) || defined(_M_IA64) || defined(__ia64__) || defined(__arch64__) || defined(__64BIT__) || defined(__Ptr_Is_64)
nuclear@0 425 #define OVR_PTR_SIZE 8
nuclear@0 426 #elif defined(__CC_ARM) && (__sizeof_ptr == 8)
nuclear@0 427 #define OVR_PTR_SIZE 8
nuclear@0 428 #else
nuclear@0 429 #define OVR_PTR_SIZE 4
nuclear@0 430 #endif
nuclear@0 431 #endif
nuclear@0 432
nuclear@0 433
nuclear@0 434 //-----------------------------------------------------------------------------------
nuclear@0 435 // ***** OVR_WORD_SIZE
nuclear@0 436 //
nuclear@0 437 // Specifies the byte size of a machine word/register. Not necessarily the same as
nuclear@0 438 // the size of pointers, but usually >= the size of pointers.
nuclear@0 439
nuclear@0 440 #if !defined(OVR_WORD_SIZE)
nuclear@0 441 #define OVR_WORD_SIZE OVR_PTR_SIZE // For our currently supported platforms these are equal.
nuclear@0 442 #endif
nuclear@0 443
nuclear@0 444
nuclear@0 445 // ------------------------------------------------------------------------
nuclear@0 446 // ***** OVR_FORCE_INLINE
nuclear@0 447 //
nuclear@0 448 // Force inline substitute - goes before function declaration
nuclear@0 449 // Example usage:
nuclear@0 450 // OVR_FORCE_INLINE void Test();
nuclear@0 451
nuclear@0 452 #if !defined(OVR_FORCE_INLINE)
nuclear@0 453 #if defined(OVR_CC_MSVC)
nuclear@0 454 #define OVR_FORCE_INLINE __forceinline
nuclear@0 455 #elif defined(OVR_CC_GNU)
nuclear@0 456 #define OVR_FORCE_INLINE __attribute__((always_inline)) inline
nuclear@0 457 #else
nuclear@0 458 #define OVR_FORCE_INLINE inline
nuclear@0 459 #endif // OVR_CC_MSVC
nuclear@0 460 #endif
nuclear@0 461
nuclear@0 462
nuclear@0 463 // ------------------------------------------------------------------------
nuclear@0 464 // ***** OVR_NO_INLINE
nuclear@0 465 //
nuclear@0 466 // Cannot be used with inline or OVR_FORCE_INLINE.
nuclear@0 467 // Example usage:
nuclear@0 468 // OVR_NO_INLINE void Test();
nuclear@0 469
nuclear@0 470 #if !defined(OVR_NO_INLINE)
nuclear@0 471 #if defined(OVR_CC_MSVC) && (_MSC_VER >= 1500) // VS2008+
nuclear@0 472 #define OVR_NO_INLINE __declspec(noinline)
nuclear@0 473 #elif !defined(OVR_CC_MSVC)
nuclear@0 474 #define OVR_NO_INLINE __attribute__((noinline))
nuclear@0 475 #endif
nuclear@0 476 #endif
nuclear@0 477
nuclear@0 478
nuclear@0 479 // -----------------------------------------------------------------------------------
nuclear@0 480 // ***** OVR_STRINGIZE
nuclear@0 481 //
nuclear@0 482 // Converts a preprocessor symbol to a string.
nuclear@0 483 //
nuclear@0 484 // Example usage:
nuclear@0 485 // printf("Line: %s", OVR_STRINGIZE(__LINE__));
nuclear@0 486 //
nuclear@0 487 #if !defined(OVR_STRINGIFY)
nuclear@0 488 #define OVR_STRINGIZEIMPL(x) #x
nuclear@0 489 #define OVR_STRINGIZE(x) OVR_STRINGIZEIMPL(x)
nuclear@0 490 #endif
nuclear@0 491
nuclear@0 492
nuclear@0 493 // -----------------------------------------------------------------------------------
nuclear@0 494 // ***** OVR_JOIN
nuclear@0 495 //
nuclear@0 496 // Joins two preprocessing symbols together. Supports the case when either or the
nuclear@0 497 // the symbols are macros themselves.
nuclear@0 498 //
nuclear@0 499 // Example usage:
nuclear@0 500 // char OVR_JOIN(unique_, __LINE__); // Results in (e.g.) char unique_123;
nuclear@0 501 //
nuclear@0 502 #if !defined(OVR_JOIN)
nuclear@0 503 #define OVR_JOIN(a, b) OVR_JOIN1(a, b)
nuclear@0 504 #define OVR_JOIN1(a, b) OVR_JOIN2(a, b)
nuclear@0 505 #define OVR_JOIN2(a, b) a##b
nuclear@0 506 #endif
nuclear@0 507
nuclear@0 508
nuclear@0 509 //-----------------------------------------------------------------------------------
nuclear@0 510 // ***** OVR_OFFSETOF
nuclear@0 511 //
nuclear@0 512 // Portable implementation of offsetof for structs and classes. offsetof and GCC's
nuclear@0 513 // __builtin_offsetof work only with POD types (standard-layout types under C++11),
nuclear@0 514 // despite that it can safely work with a number of types that aren't POD. This
nuclear@0 515 // version works with more types without generating compiler warnings or errors.
nuclear@0 516 // Returns the offset as a size_t, as per offsetof.
nuclear@0 517 //
nuclear@0 518 // Example usage:
nuclear@0 519 // struct Test{ int i; float f; };
nuclear@0 520 // size_t fPos = OVR_OFFSETOF(Test, f);
nuclear@0 521
nuclear@0 522 #if defined(OVR_CC_GNU)
nuclear@0 523 #define OVR_OFFSETOF(class_, member_) ((size_t)(((uintptr_t)&reinterpret_cast<const volatile char&>((((class_*)65536)->member_))) - 65536))
nuclear@0 524 #else
nuclear@0 525 #define OVR_OFFSETOF(class_, member_) offsetof(class_, member_)
nuclear@0 526 #endif
nuclear@0 527
nuclear@0 528
nuclear@0 529 //-----------------------------------------------------------------------------------
nuclear@0 530 // ***** OVR_SIZEOF_MEMBER
nuclear@0 531 //
nuclear@0 532 // Implements a portable way to determine the size of struct or class data member.
nuclear@0 533 // C++11 allows this directly via sizeof (see OVR_CPP_NO_EXTENDED_SIZEOF), and this
nuclear@0 534 // macro exists to handle pre-C++11 compilers.
nuclear@0 535 // Returns the offset as a size_t, as per sizeof.
nuclear@0 536 //
nuclear@0 537 // Example usage:
nuclear@0 538 // struct Test{ int i; float f; };
nuclear@0 539 // size_t fSize = OVR_SIZEOF_MEMBER(Test, f);
nuclear@0 540 //
nuclear@0 541 #if defined(OVR_CPP_NO_EXTENDED_SIZEOF)
nuclear@0 542 #define OVR_SIZEOF_MEMBER(class_, member_) (sizeof(((class_*)0)->member_))
nuclear@0 543 #else
nuclear@0 544 #define OVR_SIZEOF_MEMBER(class_, member_) (sizeof(class_::member_))
nuclear@0 545 #endif
nuclear@0 546
nuclear@0 547
nuclear@0 548 //-----------------------------------------------------------------------------------
nuclear@0 549 // ***** OVR_DEBUG_BREAK, OVR_DEBUG_CODE,
nuclear@0 550 // OVR_ASSERT, OVR_ASSERT_M, OVR_ASSERT_AND_UNUSED
nuclear@0 551 //
nuclear@0 552 // Macros have effect only in debug builds.
nuclear@0 553 //
nuclear@0 554 // Example OVR_DEBUG_BREAK usage (note the lack of parentheses):
nuclear@0 555 // #define MY_ASSERT(expression) do { if (!(expression)) { OVR_DEBUG_BREAK; } } while(0)
nuclear@0 556 //
nuclear@0 557 // Example OVR_DEBUG_CODE usage:
nuclear@0 558 // OVR_DEBUG_CODE(printf("debug test\n");)
nuclear@0 559 // or
nuclear@0 560 // OVR_DEBUG_CODE(printf("debug test\n"));
nuclear@0 561 //
nuclear@0 562 // Example OVR_ASSERT usage:
nuclear@0 563 // OVR_ASSERT(count < 100);
nuclear@0 564 // OVR_ASSERT_M(count < 100, "count is too high");
nuclear@0 565 //
nuclear@0 566 #if defined(OVR_BUILD_DEBUG)
nuclear@0 567 // Causes a debugger breakpoint in debug builds. Has no effect in release builds.
nuclear@0 568 // Microsoft Win32 specific debugging support
nuclear@0 569 #if defined(OVR_CC_MSVC)
nuclear@0 570 #define OVR_DEBUG_BREAK __debugbreak()
nuclear@0 571 #elif defined(OVR_CC_GNU) || defined(OVR_CC_CLANG)
nuclear@0 572 #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64)
nuclear@0 573 #define OVR_DEBUG_BREAK do { OVR_ASM("int $3\n\t"); } while(0)
nuclear@0 574 #else
nuclear@0 575 #define OVR_DEBUG_BREAK __builtin_trap()
nuclear@0 576 #endif
nuclear@0 577 #else
nuclear@0 578 #define OVR_DEBUG_BREAK do { *((int *) 0) = 1; } while(0)
nuclear@0 579 #endif
nuclear@0 580
nuclear@0 581 // The expresssion is defined only in debug builds. It is defined away in release builds.
nuclear@0 582 #define OVR_DEBUG_CODE(c) c
nuclear@0 583
nuclear@0 584 // In debug builds this tests the given expression; if false then executes OVR_DEBUG_BREAK,
nuclear@0 585 // if true then no action. Has no effect in release builds.
nuclear@0 586 #if defined(__clang_analyzer__) // During static analysis, make it so the analyzer thinks that failed asserts result in program exit. Reduced false positives.
nuclear@0 587 #include <stdlib.h>
nuclear@0 588 #define OVR_ASSERT_M(p, message) do { if (!(p)) { OVR_DEBUG_BREAK; exit(0); } } while(0)
nuclear@0 589 #define OVR_ASSERT(p) do { if (!(p)) { OVR_DEBUG_BREAK; exit(0); } } while(0)
nuclear@0 590 #else
nuclear@0 591 // void OVR_ASSERT_M(bool expression, const char message);
nuclear@0 592 // Note: The expresion below is expanded into all usage of this assertion macro.
nuclear@0 593 // We should try to minimize the size of the expanded code to the extent possible.
nuclear@0 594 #define OVR_ASSERT_M(p, message) do \
nuclear@0 595 { \
nuclear@0 596 if (!(p)) \
nuclear@0 597 { \
nuclear@0 598 intptr_t ovrAssertUserParam; \
nuclear@0 599 OVRAssertionHandler ovrAssertUserHandler = OVR::GetAssertionHandler(&ovrAssertUserParam); \
nuclear@0 600 \
nuclear@0 601 if(ovrAssertUserHandler && !OVRIsDebuggerPresent()) \
nuclear@0 602 { \
nuclear@0 603 ovrAssertUserHandler(ovrAssertUserParam, "Assertion failure", message); \
nuclear@0 604 } \
nuclear@0 605 else \
nuclear@0 606 { \
nuclear@0 607 OVR_DEBUG_BREAK; \
nuclear@0 608 } \
nuclear@0 609 } \
nuclear@0 610 } while(0)
nuclear@0 611
nuclear@0 612 // void OVR_ASSERT(bool expression);
nuclear@0 613 #define OVR_ASSERT(p) OVR_ASSERT_M((p), (#p))
nuclear@0 614 #endif
nuclear@0 615
nuclear@0 616 // Acts the same as OVR_ASSERT in debug builds. Acts the same as OVR_UNUSED in release builds.
nuclear@0 617 // Example usage: OVR_ASSERT_AND_UNUSED(x < 30, x);
nuclear@0 618 #define OVR_ASSERT_AND_UNUSED(expression, value) OVR_ASSERT(expression); OVR_UNUSED(value)
nuclear@0 619
nuclear@0 620 #else
nuclear@0 621
nuclear@0 622 // The expresssion is defined only in debug builds. It is defined away in release builds.
nuclear@0 623 #define OVR_DEBUG_CODE(c)
nuclear@0 624
nuclear@0 625 // Causes a debugger breakpoint in debug builds. Has no effect in release builds.
nuclear@0 626 #define OVR_DEBUG_BREAK ((void)0)
nuclear@0 627
nuclear@0 628 // In debug builds this tests the given expression; if false then executes OVR_DEBUG_BREAK,
nuclear@0 629 // if true then no action. Has no effect in release builds.
nuclear@0 630 #define OVR_ASSERT(p) ((void)0)
nuclear@0 631 #define OVR_ASSERT_M(p, m) ((void)0)
nuclear@0 632
nuclear@0 633 // Acts the same as OVR_ASSERT in debug builds. Acts the same as OVR_UNUSED in release builds.
nuclear@0 634 // Example usage: OVR_ASSERT_AND_UNUSED(x < 30, x);
nuclear@0 635 #define OVR_ASSERT_AND_UNUSED(expression, value) OVR_UNUSED(value)
nuclear@0 636
nuclear@0 637 #endif // OVR_BUILD_DEBUG
nuclear@0 638
nuclear@0 639
nuclear@0 640
nuclear@0 641 // Assert handler
nuclear@0 642 // The user of this library can override the default assertion handler and provide their own.
nuclear@0 643 namespace OVR
nuclear@0 644 {
nuclear@0 645 // The return value meaning is reserved for future definition and currently has no effect.
nuclear@0 646 typedef intptr_t (*OVRAssertionHandler)(intptr_t userParameter, const char* title, const char* message);
nuclear@0 647
nuclear@0 648 // Returns the current assertion handler.
nuclear@0 649 OVRAssertionHandler GetAssertionHandler(intptr_t* userParameter = NULL);
nuclear@0 650
nuclear@0 651 // Sets the current assertion handler.
nuclear@0 652 // The default assertion handler if none is set simply issues a debug break.
nuclear@0 653 // Example usage:
nuclear@0 654 // intptr_t CustomAssertionHandler(intptr_t /*userParameter*/, const char* title, const char* message)) {
nuclear@0 655 // MessageBox(title, message);
nuclear@0 656 // OVR_DEBUG_BREAK;
nuclear@0 657 // }
nuclear@0 658 void SetAssertionHandler(OVRAssertionHandler assertionHandler, intptr_t userParameter = 0);
nuclear@0 659
nuclear@0 660 // Implements the default assertion handler.
nuclear@0 661 intptr_t DefaultAssertionHandler(intptr_t userParameter, const char* title, const char* message);
nuclear@0 662
nuclear@0 663 // Currently defined in OVR_DebugHelp.cpp
nuclear@0 664 bool OVRIsDebuggerPresent();
nuclear@0 665 }
nuclear@0 666
nuclear@0 667
nuclear@0 668 // ------------------------------------------------------------------------
nuclear@0 669 // ***** static_assert
nuclear@0 670 //
nuclear@0 671 // Portable support for C++11 static_assert.
nuclear@0 672 // Acts as if the following were declared:
nuclear@0 673 // void static_assert(bool const_expression, const char* msg);
nuclear@0 674 //
nuclear@0 675 // Example usage:
nuclear@0 676 // static_assert(sizeof(int32_t) == 4, "int32_t expected to be 4 bytes.");
nuclear@0 677
nuclear@0 678 #if defined(OVR_CPP_NO_STATIC_ASSERT) // If the compiler doesn't provide it intrinsically...
nuclear@0 679 #if !defined(OVR_SA_UNUSED)
nuclear@0 680 #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG)
nuclear@0 681 #define OVR_SA_UNUSED __attribute__((unused))
nuclear@0 682 #else
nuclear@0 683 #define OVR_SA_UNUSED
nuclear@0 684 #endif
nuclear@0 685 #define OVR_SA_PASTE(a,b) a##b
nuclear@0 686 #define OVR_SA_HELP(a,b) OVR_SA_PASTE(a,b)
nuclear@0 687 #endif
nuclear@0 688
nuclear@0 689 #if defined(__COUNTER__)
nuclear@0 690 #define static_assert(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __COUNTER__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED
nuclear@0 691 #else
nuclear@0 692 #define static_assert(expression, msg) typedef char OVR_SA_HELP(compileTimeAssert, __LINE__) [((expression) != 0) ? 1 : -1] OVR_SA_UNUSED
nuclear@0 693 #endif
nuclear@0 694 #endif
nuclear@0 695
nuclear@0 696
nuclear@0 697 // ------------------------------------------------------------------------
nuclear@0 698 // ***** OVR_COMPILER_ASSERT
nuclear@0 699 //
nuclear@0 700 // Compile-time assert; produces compiler error if condition is false.
nuclear@0 701 // The expression must be a compile-time constant expression.
nuclear@0 702 // This macro is deprecated in favor of static_assert, which provides better
nuclear@0 703 // compiler output and works in a broader range of contexts.
nuclear@0 704 //
nuclear@0 705 // Example usage:
nuclear@0 706 // OVR_COMPILER_ASSERT(sizeof(int32_t == 4));
nuclear@0 707
nuclear@0 708 #if !defined(OVR_COMPILER_ASSERT)
nuclear@0 709 #define OVR_COMPILER_ASSERT(expression) static_assert(expression, #expression)
nuclear@0 710 #define OVR_COMPILER_ASSERT_M(expression, msg) static_assert(expression, msg)
nuclear@0 711 #endif
nuclear@0 712
nuclear@0 713
nuclear@0 714 // ***** OVR_PROCESSOR_PAUSE
nuclear@0 715 //
nuclear@0 716 // Yields the processor for other hyperthreads, usually for the purpose of implementing spins and spin locks.
nuclear@0 717 //
nuclear@0 718 // Example usage:
nuclear@0 719 // while(!finished())
nuclear@0 720 // OVR_PROCESSOR_PAUSE();
nuclear@0 721
nuclear@0 722 #if defined(OVR_CPU_X86) || defined(OVR_CPU_X86_64)
nuclear@0 723 #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG)
nuclear@0 724 #define OVR_PROCESSOR_PAUSE() asm volatile("pause" ::: "memory") // Consumes 38-40 clocks on current Intel x86 and x64 hardware.
nuclear@0 725 #elif defined(OVR_CC_MSVC)
nuclear@0 726 #include <emmintrin.h>
nuclear@0 727 #pragma intrinsic(_mm_pause) // Maps to asm pause.
nuclear@0 728 #define OVR_PROCESSOR_PAUSE _mm_pause
nuclear@0 729 #else
nuclear@0 730 #define OVR_PROCESSOR_PAUSE()
nuclear@0 731 #endif
nuclear@0 732 #else
nuclear@0 733 #define OVR_PROCESSOR_PAUSE()
nuclear@0 734 #endif
nuclear@0 735
nuclear@0 736
nuclear@0 737 // ------------------------------------------------------------------------
nuclear@0 738 // ***** OVR_ARRAY_COUNT
nuclear@0 739 //
nuclear@0 740 // Returns the element count of a C array.
nuclear@0 741 //
nuclear@0 742 // Example usage:
nuclear@0 743 // float itemArray[16];
nuclear@0 744 // for(size_t i = 0; i < OVR_ARRAY_COUNT(itemArray); i++) { ... }
nuclear@0 745
nuclear@0 746 #if defined(OVR_CPP_NO_CONSTEXPR)
nuclear@0 747 #ifndef OVR_ARRAY_COUNT
nuclear@0 748 #define OVR_ARRAY_COUNT(x) (sizeof(x) / sizeof(x[0]))
nuclear@0 749 #endif
nuclear@0 750 #else
nuclear@0 751 // Smarter C++11 version which knows the difference between arrays and pointers.
nuclear@0 752 template <typename T, size_t N>
nuclear@0 753 char (&OVRArrayCountHelper(T (&x)[N]))[N];
nuclear@0 754 #define OVR_ARRAY_COUNT(x) (sizeof(OVRArrayCountHelper(x)))
nuclear@0 755 #endif
nuclear@0 756
nuclear@0 757
nuclear@0 758 // ------------------------------------------------------------------------
nuclear@0 759 // ***** OVR_CURRENT_FUNCTION
nuclear@0 760 //
nuclear@0 761 // Portable wrapper for __PRETTY_FUNCTION__, C99 __func__, __FUNCTION__.
nuclear@0 762 // This represents the most expressive version available.
nuclear@0 763 // Acts as if the following were declared:
nuclear@0 764 // static const char OVR_CURRENT_FUNCTION[] = "function-name";
nuclear@0 765 //
nuclear@0 766 // Example usage:
nuclear@0 767 // void Test() { printf("%s", OVR_CURRENT_FUNCTION); }
nuclear@0 768
nuclear@0 769 #if defined(OVR_CC_GNU) || defined(OVR_CC_CLANG) || (defined(__ICC) && (__ICC >= 600)) // GCC, clang, Intel
nuclear@0 770 #define OVR_CURRENT_FUNCTION __PRETTY_FUNCTION__
nuclear@0 771 #elif defined(__FUNCSIG__) // VC++
nuclear@0 772 #define OVR_CURRENT_FUNCTION __FUNCSIG__
nuclear@0 773 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901) // C99 compilers
nuclear@0 774 #define OVR_CURRENT_FUNCTION __func__
nuclear@0 775 #else
nuclear@0 776 #define OVR_CURRENT_FUNCTION __FUNCTION__
nuclear@0 777 #endif
nuclear@0 778
nuclear@0 779
nuclear@0 780 //-----------------------------------------------------------------------------------
nuclear@0 781 // ***** OVR_DEPRECATED / OVR_DEPRECATED_MSG
nuclear@0 782 //
nuclear@0 783 // Portably annotates a function or struct as deprecated.
nuclear@0 784 // Note that clang supports __deprecated_enum_msg, which may be useful to support.
nuclear@0 785 //
nuclear@0 786 // Example usage:
nuclear@0 787 // OVR_DEPRECATED void Test(); // Use on the function declaration, as opposed to definition.
nuclear@0 788 //
nuclear@0 789 // struct OVR_DEPRECATED Test{ ... };
nuclear@0 790 //
nuclear@0 791 // OVR_DEPRECATED_MSG("Test is deprecated")
nuclear@0 792 // void Test();
nuclear@0 793
nuclear@0 794 #if !defined(OVR_DEPRECATED)
nuclear@0 795 #if defined(OVR_CC_MSVC) && (OVR_CC_VERSION > 1400) // VS2005+
nuclear@0 796 #define OVR_DEPRECATED __declspec(deprecated)
nuclear@0 797 #define OVR_DEPRECATED_MSG(msg) __declspec(deprecated(msg))
nuclear@0 798 #elif defined(OVR_CC_CLANG) && OVR_CC_HAS_FEATURE(attribute_deprecated_with_message)
nuclear@0 799 #define OVR_DEPRECATED __declspec(deprecated)
nuclear@0 800 #define OVR_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
nuclear@0 801 #elif defined(OVR_CC_GNU) && (OVR_CC_VERSION >= 405)
nuclear@0 802 #define OVR_DEPRECATED __declspec(deprecated)
nuclear@0 803 #define OVR_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
nuclear@0 804 #elif !defined(OVR_CC_MSVC)
nuclear@0 805 #define OVR_DEPRECATED __attribute__((deprecated))
nuclear@0 806 #define OVR_DEPRECATED_MSG(msg) __attribute__((deprecated))
nuclear@0 807 #else
nuclear@0 808 #define OVR_DEPRECATED
nuclear@0 809 #define OVR_DEPRECATED_MSG(msg)
nuclear@0 810 #endif
nuclear@0 811 #endif
nuclear@0 812
nuclear@0 813
nuclear@0 814 //-----------------------------------------------------------------------------------
nuclear@0 815 // ***** OVR_UNUSED - Unused Argument handling
nuclear@0 816 // Macro to quiet compiler warnings about unused parameters/variables.
nuclear@0 817 //
nuclear@0 818 // Example usage:
nuclear@0 819 // void Test() {
nuclear@0 820 // int x = SomeFunction();
nuclear@0 821 // OVR_UNUSED(x);
nuclear@0 822 // }
nuclear@0 823 //
nuclear@0 824
nuclear@0 825 #if defined(OVR_CC_GNU)
nuclear@0 826 # define OVR_UNUSED(a) do {__typeof__ (&a) __attribute__ ((unused)) __tmp = &a; } while(0)
nuclear@0 827 #else
nuclear@0 828 # define OVR_UNUSED(a) (a)
nuclear@0 829 #endif
nuclear@0 830
nuclear@0 831 #define OVR_UNUSED1(a1) OVR_UNUSED(a1)
nuclear@0 832 #define OVR_UNUSED2(a1,a2) OVR_UNUSED(a1); OVR_UNUSED(a2)
nuclear@0 833 #define OVR_UNUSED3(a1,a2,a3) OVR_UNUSED2(a1,a2); OVR_UNUSED(a3)
nuclear@0 834 #define OVR_UNUSED4(a1,a2,a3,a4) OVR_UNUSED3(a1,a2,a3); OVR_UNUSED(a4)
nuclear@0 835 #define OVR_UNUSED5(a1,a2,a3,a4,a5) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED(a5)
nuclear@0 836 #define OVR_UNUSED6(a1,a2,a3,a4,a5,a6) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED2(a5,a6)
nuclear@0 837 #define OVR_UNUSED7(a1,a2,a3,a4,a5,a6,a7) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED3(a5,a6,a7)
nuclear@0 838 #define OVR_UNUSED8(a1,a2,a3,a4,a5,a6,a7,a8) OVR_UNUSED4(a1,a2,a3,a4); OVR_UNUSED4(a5,a6,a7,a8)
nuclear@0 839 #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)
nuclear@0 840
nuclear@0 841
nuclear@0 842 //-----------------------------------------------------------------------------------
nuclear@0 843 // ***** Configuration Macros
nuclear@0 844 //
nuclear@0 845 // Expands to the current build type as a const char string literal.
nuclear@0 846 // Acts as the following declaration: const char OVR_BUILD_STRING[];
nuclear@0 847
nuclear@0 848 #ifdef OVR_BUILD_DEBUG
nuclear@0 849 # define OVR_BUILD_STRING "Debug"
nuclear@0 850 #else
nuclear@0 851 # define OVR_BUILD_STRING "Release"
nuclear@0 852 #endif
nuclear@0 853
nuclear@0 854
nuclear@0 855 //// Enables SF Debugging information
nuclear@0 856 //# define OVR_BUILD_DEBUG
nuclear@0 857
nuclear@0 858 // OVR_DEBUG_STATEMENT injects a statement only in debug builds.
nuclear@0 859 // OVR_DEBUG_SELECT injects first argument in debug builds, second argument otherwise.
nuclear@0 860 #ifdef OVR_BUILD_DEBUG
nuclear@0 861 #define OVR_DEBUG_STATEMENT(s) s
nuclear@0 862 #define OVR_DEBUG_SELECT(d, nd) d
nuclear@0 863 #else
nuclear@0 864 #define OVR_DEBUG_STATEMENT(s)
nuclear@0 865 #define OVR_DEBUG_SELECT(d, nd) nd
nuclear@0 866 #endif
nuclear@0 867
nuclear@0 868
nuclear@0 869 #define OVR_ENABLE_THREADS
nuclear@0 870 //
nuclear@0 871 // Prevents OVR from defining new within
nuclear@0 872 // type macros, so developers can override
nuclear@0 873 // new using the #define new new(...) trick
nuclear@0 874 // - used with OVR_DEFINE_NEW macro
nuclear@0 875 //# define OVR_BUILD_DEFINE_NEW
nuclear@0 876 //
nuclear@0 877
nuclear@0 878
nuclear@0 879 //-----------------------------------------------------------------------------------
nuclear@0 880 // ***** Find normal allocations
nuclear@0 881 //
nuclear@0 882 // Our allocations are all supposed to go through the OVR System Allocator, so that
nuclear@0 883 // they can be run through a game's own preferred allocator. Occasionally we will
nuclear@0 884 // accidentally introduce new code that doesn't adhere to this contract. And it
nuclear@0 885 // then becomes difficult to track down these normal allocations. This piece of
nuclear@0 886 // code makes it easy to check for normal allocations by asserting whenever they
nuclear@0 887 // happen in our code.
nuclear@0 888
nuclear@0 889 //#define OVR_FIND_NORMAL_ALLOCATIONS
nuclear@0 890 #ifdef OVR_FIND_NORMAL_ALLOCATIONS
nuclear@0 891
nuclear@0 892 inline void* operator new (size_t size, const char* filename, int line)
nuclear@0 893 {
nuclear@0 894 void* ptr = new char[size];
nuclear@0 895 OVR_ASSERT(false);
nuclear@0 896 return ptr;
nuclear@0 897 }
nuclear@0 898
nuclear@0 899 #define new new(__FILE__, __LINE__)
nuclear@0 900
nuclear@0 901 #endif // OVR_FIND_NORMAL_ALLOCATIONS
nuclear@0 902
nuclear@0 903
nuclear@0 904 #include "OVR_Nullptr.h"
nuclear@0 905
nuclear@0 906
nuclear@0 907
nuclear@0 908
nuclear@0 909 #endif // OVR_Types_h