NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxPreprocessor.h Source File

NVIDIA PhysX SDK 3.4 API

PxPreprocessor.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2017 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
00029 
00030 #ifndef PXFOUNDATION_PXPREPROCESSOR_H
00031 #define PXFOUNDATION_PXPREPROCESSOR_H
00032 
00033 #include <stddef.h>
00034 #if !defined(PX_GENERATE_META_DATA)
00035 #include <ciso646>  
00036 #endif
00037 
00041 /*
00042 The following preprocessor identifiers specify compiler, OS, and architecture.
00043 All definitions have a value of 1 or 0, use '#if' instead of '#ifdef'.
00044 */
00045 
00049 #if defined(_MSC_VER)
00050 #if _MSC_VER >= 1910
00051 #define PX_VC 15
00052 #elif _MSC_VER >= 1900
00053 #define PX_VC 14
00054 #elif _MSC_VER >= 1800
00055 #define PX_VC 12
00056 #elif _MSC_VER >= 1700
00057 #define PX_VC 11
00058 #elif _MSC_VER >= 1600
00059 #define PX_VC 10
00060 #elif _MSC_VER >= 1500
00061 #define PX_VC 9
00062 #else
00063 #error "Unknown VC version"
00064 #endif
00065 #elif defined(__clang__)
00066 #define PX_CLANG 1
00067 #elif defined(__GNUC__) // note: __clang__ implies __GNUC__
00068 #define PX_GCC 1
00069 #else
00070 #error "Unknown compiler"
00071 #endif
00072 
00076 #if defined(_XBOX_ONE)
00077 #define PX_XBOXONE 1
00078 #elif defined(_WIN64) // note: _XBOX_ONE implies _WIN64
00079 #define PX_WIN64 1
00080 #elif defined(_WIN32) // note: _M_PPC implies _WIN32
00081 #define PX_WIN32 1
00082 #elif defined(__ANDROID__)
00083 #define PX_ANDROID 1
00084 #elif defined(__linux__) || defined (__EMSCRIPTEN__) // note: __ANDROID__ implies __linux__
00085 #define PX_LINUX 1
00086 #elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
00087 #define PX_IOS 1
00088 #elif defined(__APPLE__)
00089 #define PX_OSX 1
00090 #elif defined(__ORBIS__)
00091 #define PX_PS4 1
00092 #elif defined(__NX__)
00093 #define PX_SWITCH 1
00094 #else
00095 #error "Unknown operating system"
00096 #endif
00097 
00101 #if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value
00102 #define PX_X64 1
00103 #elif defined(__i386__) || defined(_M_IX86) || defined (__EMSCRIPTEN__)
00104 #define PX_X86 1
00105 #elif defined(__arm64__) || defined(__aarch64__)
00106 #define PX_A64 1
00107 #elif defined(__arm__) || defined(_M_ARM)
00108 #define PX_ARM 1
00109 #elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
00110 #define PX_PPC 1
00111 #else
00112 #error "Unknown architecture"
00113 #endif
00114 
00118 #if !defined(PX_SIMD_DISABLED)
00119 #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || (defined (__EMSCRIPTEN__) && defined(__SSE2__))
00120 #define PX_SSE2 1
00121 #endif
00122 #if defined(_M_ARM) || defined(__ARM_NEON__) || defined(__ARM_NEON)
00123 #define PX_NEON 1
00124 #endif
00125 #if defined(_M_PPC) || defined(__CELLOS_LV2__)
00126 #define PX_VMX 1
00127 #endif
00128 #endif
00129 
00133 #ifndef PX_VC
00134 #define PX_VC 0
00135 #endif
00136 #ifndef PX_CLANG
00137 #define PX_CLANG 0
00138 #endif
00139 #ifndef PX_GCC
00140 #define PX_GCC 0
00141 #endif
00142 #ifndef PX_XBOXONE
00143 #define PX_XBOXONE 0
00144 #endif
00145 #ifndef PX_WIN64
00146 #define PX_WIN64 0
00147 #endif
00148 #ifndef PX_WIN32
00149 #define PX_WIN32 0
00150 #endif
00151 #ifndef PX_ANDROID
00152 #define PX_ANDROID 0
00153 #endif
00154 #ifndef PX_LINUX
00155 #define PX_LINUX 0
00156 #endif
00157 #ifndef PX_IOS
00158 #define PX_IOS 0
00159 #endif
00160 #ifndef PX_OSX
00161 #define PX_OSX 0
00162 #endif
00163 #ifndef PX_PS4
00164 #define PX_PS4 0
00165 #endif
00166 #ifndef PX_SWITCH
00167 #define PX_SWITCH 0
00168 #endif
00169 #ifndef PX_X64
00170 #define PX_X64 0
00171 #endif
00172 #ifndef PX_X86
00173 #define PX_X86 0
00174 #endif
00175 #ifndef PX_A64
00176 #define PX_A64 0
00177 #endif
00178 #ifndef PX_ARM
00179 #define PX_ARM 0
00180 #endif
00181 #ifndef PX_PPC
00182 #define PX_PPC 0
00183 #endif
00184 #ifndef PX_SSE2
00185 #define PX_SSE2 0
00186 #endif
00187 #ifndef PX_NEON
00188 #define PX_NEON 0
00189 #endif
00190 #ifndef PX_VMX
00191 #define PX_VMX 0
00192 #endif
00193 
00194 /*
00195 define anything not defined through the command line to 0
00196 */
00197 #ifndef PX_DEBUG
00198 #define PX_DEBUG 0
00199 #endif
00200 #ifndef PX_CHECKED
00201 #define PX_CHECKED 0
00202 #endif
00203 #ifndef PX_PROFILE
00204 #define PX_PROFILE 0
00205 #endif
00206 #ifndef PX_NVTX
00207 #define PX_NVTX 0
00208 #endif
00209 #ifndef PX_DOXYGEN
00210 #define PX_DOXYGEN 0
00211 #endif
00212 
00216 // compiler
00217 #define PX_GCC_FAMILY (PX_CLANG || PX_GCC)
00218 // os
00219 #define PX_WINDOWS_FAMILY (PX_WIN32 || PX_WIN64)
00220 #define PX_MICROSOFT_FAMILY (PX_XBOXONE || PX_WINDOWS_FAMILY)
00221 #define PX_LINUX_FAMILY (PX_LINUX || PX_ANDROID)
00222 #define PX_APPLE_FAMILY (PX_IOS || PX_OSX)                  // equivalent to #if __APPLE__
00223 #define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY) // shortcut for unix/posix platforms
00224 #if defined(__EMSCRIPTEN__)
00225 #define PX_EMSCRIPTEN 1
00226 #else
00227 #define PX_EMSCRIPTEN 0
00228 #endif
00229 // architecture
00230 #define PX_INTEL_FAMILY (PX_X64 || PX_X86)
00231 #define PX_ARM_FAMILY (PX_ARM || PX_A64)
00232 #define PX_P64_FAMILY (PX_X64 || PX_A64) // shortcut for 64-bit architectures
00233 
00237 #if defined(_LIBCPP_VERSION) || PX_WIN64 || PX_WIN32 || PX_PS4 || PX_XBOXONE || PX_EMSCRIPTEN
00238 #define PX_LIBCPP 1
00239 #else
00240 #define PX_LIBCPP 0
00241 #endif
00242 
00243 // legacy define for PhysX
00244 #define PX_WINDOWS (PX_WINDOWS_FAMILY && !PX_ARM_FAMILY)
00245 
00249 #ifndef PX_ENABLE_ASSERTS
00250 #if PX_DEBUG && !defined(__CUDACC__)
00251 #define PX_ENABLE_ASSERTS 1
00252 #else
00253 #define PX_ENABLE_ASSERTS 0
00254 #endif
00255 #endif
00256 
00260 #ifndef PX_C_EXPORT
00261 #if PX_WINDOWS_FAMILY || PX_LINUX
00262 #define PX_C_EXPORT extern "C"
00263 #else
00264 #define PX_C_EXPORT
00265 #endif
00266 #endif
00267 
00268 #if PX_UNIX_FAMILY&& __GNUC__ >= 4
00269 #define PX_UNIX_EXPORT __attribute__((visibility("default")))
00270 #else
00271 #define PX_UNIX_EXPORT
00272 #endif
00273 
00274 #if PX_WINDOWS_FAMILY
00275 #define PX_DLL_EXPORT __declspec(dllexport)
00276 #define PX_DLL_IMPORT __declspec(dllimport)
00277 #else
00278 #define PX_DLL_EXPORT PX_UNIX_EXPORT
00279 #define PX_DLL_IMPORT
00280 #endif
00281 
00291 #if PX_WINDOWS_FAMILY && !PX_ARM_FAMILY
00292 #ifndef PX_FOUNDATION_DLL
00293 #define PX_FOUNDATION_API PX_DLL_IMPORT
00294 #elif PX_FOUNDATION_DLL
00295 #define PX_FOUNDATION_API PX_DLL_EXPORT
00296 #endif
00297 #elif PX_UNIX_FAMILY
00298 #ifdef PX_FOUNDATION_DLL
00299 #define PX_FOUNDATION_API PX_UNIX_EXPORT
00300 #endif
00301 #endif
00302 
00303 #ifndef PX_FOUNDATION_API
00304 #define PX_FOUNDATION_API
00305 #endif
00306 
00310 #ifndef PX_CALL_CONV
00311 #if PX_MICROSOFT_FAMILY
00312 #define PX_CALL_CONV __cdecl
00313 #else
00314 #define PX_CALL_CONV
00315 #endif
00316 #endif
00317 
00321 #if PX_VC
00322 #define PX_PUSH_PACK_DEFAULT __pragma(pack(push, 8))
00323 #define PX_POP_PACK __pragma(pack(pop))
00324 #elif PX_GCC_FAMILY
00325 #define PX_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)")
00326 #define PX_POP_PACK _Pragma("pack(pop)")
00327 #else
00328 #define PX_PUSH_PACK_DEFAULT
00329 #define PX_POP_PACK
00330 #endif
00331 
00335 #define PX_INLINE inline
00336 #if PX_MICROSOFT_FAMILY
00337 #pragma inline_depth(255)
00338 #endif
00339 
00343 #if PX_VC
00344 #define PX_FORCE_INLINE __forceinline
00345 #elif PX_LINUX // Workaround; Fedora Core 3 do not agree with force inline and PxcPool
00346 #define PX_FORCE_INLINE inline
00347 #elif PX_GCC_FAMILY
00348 #define PX_FORCE_INLINE inline __attribute__((always_inline))
00349 #else
00350 #define PX_FORCE_INLINE inline
00351 #endif
00352 
00356 #if PX_MICROSOFT_FAMILY
00357 #define PX_NOINLINE __declspec(noinline)
00358 #elif PX_GCC_FAMILY
00359 #define PX_NOINLINE __attribute__((noinline))
00360 #else
00361 #define PX_NOINLINE
00362 #endif
00363 
00367 #if defined(__CUDACC__)
00368 #define PX_RESTRICT __restrict__
00369 #else
00370 #define PX_RESTRICT __restrict
00371 #endif
00372 
00376 #if PX_MICROSOFT_FAMILY
00377 #define PX_NOALIAS __declspec(noalias)
00378 #else
00379 #define PX_NOALIAS
00380 #endif
00381 
00393 #ifndef PX_ALIGN
00394 #if PX_MICROSOFT_FAMILY
00395 #define PX_ALIGN(alignment, decl) __declspec(align(alignment)) decl
00396 #define PX_ALIGN_PREFIX(alignment) __declspec(align(alignment))
00397 #define PX_ALIGN_SUFFIX(alignment)
00398 #elif PX_GCC_FAMILY
00399 #define PX_ALIGN(alignment, decl) decl __attribute__((aligned(alignment)))
00400 #define PX_ALIGN_PREFIX(alignment)
00401 #define PX_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment)))
00402 #elif defined __CUDACC__
00403 #define PX_ALIGN(alignment, decl) __align__(alignment) decl
00404 #define PX_ALIGN_PREFIX(alignment)
00405 #define PX_ALIGN_SUFFIX(alignment) __align__(alignment))
00406 #else
00407 #define PX_ALIGN(alignment, decl)
00408 #define PX_ALIGN_PREFIX(alignment)
00409 #define PX_ALIGN_SUFFIX(alignment)
00410 #endif
00411 #endif
00412 
00423 #define PX_DEPRECATED
00424 
00429 // static assert
00430 #if(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (PX_PS4) || (PX_APPLE_FAMILY) || (PX_SWITCH) || (PX_CLANG && PX_ARM)
00431 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1] __attribute__((unused))
00432 #else
00433 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1]
00434 #endif
00435 
00436 #if PX_GCC_FAMILY
00437 #define PX_OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
00438 #else
00439 #define PX_OFFSET_OF(X, Y) offsetof(X, Y)
00440 #endif
00441 
00442 #define PX_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want
00443 #define PX_OFFSET_OF_RT(Class, Member)                                                                                 \
00444     (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(PX_OFFSETOF_BASE)->Member) - size_t(PX_OFFSETOF_BASE))
00445 
00446 // check that exactly one of NDEBUG and _DEBUG is defined
00447 #if !defined(NDEBUG) ^ defined(_DEBUG)
00448 #error Exactly one of NDEBUG and _DEBUG needs to be defined!
00449 #endif
00450 
00451 // make sure PX_CHECKED is defined in all _DEBUG configurations as well
00452 #if !PX_CHECKED && PX_DEBUG
00453 #error PX_CHECKED must be defined when PX_DEBUG is defined
00454 #endif
00455 
00456 #ifdef __CUDACC__
00457 #define PX_CUDA_CALLABLE __host__ __device__
00458 #else
00459 #define PX_CUDA_CALLABLE
00460 #endif
00461 
00462 // avoid unreferenced parameter warning
00463 // preferred solution: omit the parameter's name from the declaration
00464 template <class T>
00465 PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const&)
00466 {
00467 }
00468 
00469 // Ensure that the application hasn't tweaked the pack value to less than 8, which would break
00470 // matching between the API headers and the binaries
00471 // This assert works on win32/win64, but may need further specialization on other platforms.
00472 // Some GCC compilers need the compiler flag -malign-double to be set.
00473 // Apparently the apple-clang-llvm compiler doesn't support malign-double.
00474 #if PX_PS4 || PX_APPLE_FAMILY || (PX_CLANG && !PX_ARM)
00475 struct PxPackValidation
00476 {
00477     char _;
00478     long a;
00479 };
00480 #elif PX_ANDROID || (PX_CLANG && PX_ARM)
00481 struct PxPackValidation
00482 {
00483     char _;
00484     double a;
00485 };
00486 #else
00487 struct PxPackValidation
00488 {
00489     char _;
00490     long long a;
00491 };
00492 #endif
00493 // clang (as of version 3.9) cannot align doubles on 8 byte boundary  when compiling for Intel 32 bit target
00494 #if !PX_APPLE_FAMILY && !PX_EMSCRIPTEN && !(PX_CLANG && PX_X86)
00495 PX_COMPILE_TIME_ASSERT(PX_OFFSET_OF(PxPackValidation, a) == 8);
00496 #endif
00497 
00498 // use in a cpp file to suppress LNK4221
00499 #if PX_VC
00500 #define PX_DUMMY_SYMBOL                                                                                                \
00501     namespace                                                                                                          \
00502     {                                                                                                                  \
00503     char PxDummySymbol;                                                                                                \
00504     }
00505 #else
00506 #define PX_DUMMY_SYMBOL
00507 #endif
00508 
00509 #if PX_GCC_FAMILY
00510 #define PX_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization
00511 #else
00512 #define PX_WEAK_SYMBOL
00513 #endif
00514 
00515 // Macro for avoiding default assignment and copy, because doing this by inheritance can increase class size on some
00516 // platforms.
00517 #define PX_NOCOPY(Class)                                                                                               \
00518     \
00519 protected:                                                                                                             \
00520     Class(const Class&);                                                                                               \
00521     Class& operator=(const Class&);
00522 
00523 #define PX_STRINGIZE_HELPER(X) #X
00524 #define PX_STRINGIZE(X) PX_STRINGIZE_HELPER(X)
00525 
00526 #define PX_CONCAT_HELPER(X, Y) X##Y
00527 #define PX_CONCAT(X, Y) PX_CONCAT_HELPER(X, Y)
00528 
00529 #ifndef DISABLE_CUDA_PHYSX
00530 //CUDA is currently supported only on windows 
00531 #define PX_SUPPORT_GPU_PHYSX ((PX_WINDOWS_FAMILY) || (PX_LINUX && PX_X64))
00532 #else
00533 #define PX_SUPPORT_GPU_PHYSX 0
00534 #endif
00535 
00536 #define PX_SUPPORT_COMPUTE_PHYSX 0
00537 
00538 #ifndef PX_SUPPORT_EXTERN_TEMPLATE
00539 #define PX_SUPPORT_EXTERN_TEMPLATE ((!PX_ANDROID) && (PX_VC != 11))
00540 #else
00541 #define PX_SUPPORT_EXTERN_TEMPLATE 0
00542 #endif
00543 
00545 #endif // #ifndef PXFOUNDATION_PXPREPROCESSOR_H


Copyright © 2008-2017 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com