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 >= 1900
00051 #define PX_VC 14
00052 #elif _MSC_VER >= 1800
00053 #define PX_VC 12
00054 #elif _MSC_VER >= 1700
00055 #define PX_VC 11
00056 #elif _MSC_VER >= 1600
00057 #define PX_VC 10
00058 #elif _MSC_VER >= 1500
00059 #define PX_VC 9
00060 #else
00061 #error "Unknown VC version"
00062 #endif
00063 #elif defined(__clang__)
00064 #define PX_CLANG 1
00065 #elif defined(__GNUC__) // note: __clang__ implies __GNUC__
00066 #define PX_GCC 1
00067 #else
00068 #error "Unknown compiler"
00069 #endif
00070 
00074 #if defined(_XBOX_ONE)
00075 #define PX_XBOXONE 1
00076 #elif defined(_WIN64) // note: _XBOX_ONE implies _WIN64
00077 #define PX_WIN64 1
00078 #elif defined(_WIN32) // note: _M_PPC implies _WIN32
00079 #define PX_WIN32 1
00080 #elif defined(__ANDROID__)
00081 #define PX_ANDROID 1
00082 #elif defined(__linux__) || defined (__EMSCRIPTEN__) // note: __ANDROID__ implies __linux__
00083 #define PX_LINUX 1
00084 #elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
00085 #define PX_IOS 1
00086 #elif defined(__APPLE__)
00087 #define PX_OSX 1
00088 #elif defined(__ORBIS__)
00089 #define PX_PS4 1
00090 #elif defined(__NX__)
00091 #define PX_NX 1
00092 #else
00093 #error "Unknown operating system"
00094 #endif
00095 
00099 #if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value
00100 #define PX_X64 1
00101 #elif defined(__i386__) || defined(_M_IX86) || defined (__EMSCRIPTEN__)
00102 #define PX_X86 1
00103 #elif defined(__arm64__) || defined(__aarch64__)
00104 #define PX_A64 1
00105 #elif defined(__arm__) || defined(_M_ARM)
00106 #define PX_ARM 1
00107 #elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
00108 #define PX_PPC 1
00109 #else
00110 #error "Unknown architecture"
00111 #endif
00112 
00116 #if !defined(PX_SIMD_DISABLED)
00117 #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || (defined (__EMSCRIPTEN__) && defined(__SSE2__))
00118 #define PX_SSE2 1
00119 #endif
00120 #if defined(_M_ARM) || defined(__ARM_NEON__) || defined(__ARM_NEON)
00121 #define PX_NEON 1
00122 #endif
00123 #if defined(_M_PPC) || defined(__CELLOS_LV2__)
00124 #define PX_VMX 1
00125 #endif
00126 #endif
00127 
00131 #ifndef PX_VC
00132 #define PX_VC 0
00133 #endif
00134 #ifndef PX_CLANG
00135 #define PX_CLANG 0
00136 #endif
00137 #ifndef PX_GCC
00138 #define PX_GCC 0
00139 #endif
00140 #ifndef PX_XBOXONE
00141 #define PX_XBOXONE 0
00142 #endif
00143 #ifndef PX_WIN64
00144 #define PX_WIN64 0
00145 #endif
00146 #ifndef PX_WIN32
00147 #define PX_WIN32 0
00148 #endif
00149 #ifndef PX_ANDROID
00150 #define PX_ANDROID 0
00151 #endif
00152 #ifndef PX_LINUX
00153 #define PX_LINUX 0
00154 #endif
00155 #ifndef PX_IOS
00156 #define PX_IOS 0
00157 #endif
00158 #ifndef PX_OSX
00159 #define PX_OSX 0
00160 #endif
00161 #ifndef PX_PS4
00162 #define PX_PS4 0
00163 #endif
00164 #ifndef PX_NX
00165 #define PX_NX 0
00166 #endif
00167 #ifndef PX_X64
00168 #define PX_X64 0
00169 #endif
00170 #ifndef PX_X86
00171 #define PX_X86 0
00172 #endif
00173 #ifndef PX_A64
00174 #define PX_A64 0
00175 #endif
00176 #ifndef PX_ARM
00177 #define PX_ARM 0
00178 #endif
00179 #ifndef PX_PPC
00180 #define PX_PPC 0
00181 #endif
00182 #ifndef PX_SSE2
00183 #define PX_SSE2 0
00184 #endif
00185 #ifndef PX_NEON
00186 #define PX_NEON 0
00187 #endif
00188 #ifndef PX_VMX
00189 #define PX_VMX 0
00190 #endif
00191 
00192 /*
00193 define anything not defined through the command line to 0
00194 */
00195 #ifndef PX_DEBUG
00196 #define PX_DEBUG 0
00197 #endif
00198 #ifndef PX_CHECKED
00199 #define PX_CHECKED 0
00200 #endif
00201 #ifndef PX_PROFILE
00202 #define PX_PROFILE 0
00203 #endif
00204 #ifndef PX_NVTX
00205 #define PX_NVTX 0
00206 #endif
00207 #ifndef PX_DOXYGEN
00208 #define PX_DOXYGEN 0
00209 #endif
00210 
00214 // compiler
00215 #define PX_GCC_FAMILY (PX_CLANG || PX_GCC)
00216 // os
00217 #define PX_WINDOWS_FAMILY (PX_WIN32 || PX_WIN64)
00218 #define PX_MICROSOFT_FAMILY (PX_XBOXONE || PX_WINDOWS_FAMILY)
00219 #define PX_LINUX_FAMILY (PX_LINUX || PX_ANDROID)
00220 #define PX_APPLE_FAMILY (PX_IOS || PX_OSX)                  // equivalent to #if __APPLE__
00221 #define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY) // shortcut for unix/posix platforms
00222 #if defined(__EMSCRIPTEN__)
00223 #define PX_EMSCRIPTEN 1
00224 #else
00225 #define PX_EMSCRIPTEN 0
00226 #endif
00227 // architecture
00228 #define PX_INTEL_FAMILY (PX_X64 || PX_X86)
00229 #define PX_ARM_FAMILY (PX_ARM || PX_A64)
00230 #define PX_P64_FAMILY (PX_X64 || PX_A64) // shortcut for 64-bit architectures
00231 
00235 #if defined(_LIBCPP_VERSION) || PX_WIN64 || PX_WIN32 || PX_PS4 || PX_XBOXONE || PX_EMSCRIPTEN
00236 #define PX_LIBCPP 1
00237 #else
00238 #define PX_LIBCPP 0
00239 #endif
00240 
00241 // legacy define for PhysX
00242 #define PX_WINDOWS (PX_WINDOWS_FAMILY && !PX_ARM_FAMILY)
00243 
00247 #ifndef PX_ENABLE_ASSERTS
00248 #if PX_DEBUG && !defined(__CUDACC__)
00249 #define PX_ENABLE_ASSERTS 1
00250 #else
00251 #define PX_ENABLE_ASSERTS 0
00252 #endif
00253 #endif
00254 
00258 #ifndef PX_C_EXPORT
00259 #if PX_WINDOWS_FAMILY || PX_LINUX
00260 #define PX_C_EXPORT extern "C"
00261 #else
00262 #define PX_C_EXPORT
00263 #endif
00264 #endif
00265 
00266 #if PX_UNIX_FAMILY&& __GNUC__ >= 4
00267 #define PX_UNIX_EXPORT __attribute__((visibility("default")))
00268 #else
00269 #define PX_UNIX_EXPORT
00270 #endif
00271 
00272 #if PX_WINDOWS_FAMILY
00273 #define PX_DLL_EXPORT __declspec(dllexport)
00274 #define PX_DLL_IMPORT __declspec(dllimport)
00275 #else
00276 #define PX_DLL_EXPORT PX_UNIX_EXPORT
00277 #define PX_DLL_IMPORT
00278 #endif
00279 
00289 #if PX_WINDOWS_FAMILY && !PX_ARM_FAMILY
00290 #ifndef PX_FOUNDATION_DLL
00291 #define PX_FOUNDATION_API PX_DLL_IMPORT
00292 #elif PX_FOUNDATION_DLL
00293 #define PX_FOUNDATION_API PX_DLL_EXPORT
00294 #endif
00295 #elif PX_UNIX_FAMILY
00296 #ifdef PX_FOUNDATION_DLL
00297 #define PX_FOUNDATION_API PX_UNIX_EXPORT
00298 #endif
00299 #endif
00300 
00301 #ifndef PX_FOUNDATION_API
00302 #define PX_FOUNDATION_API
00303 #endif
00304 
00308 #ifndef PX_CALL_CONV
00309 #if PX_MICROSOFT_FAMILY
00310 #define PX_CALL_CONV __cdecl
00311 #else
00312 #define PX_CALL_CONV
00313 #endif
00314 #endif
00315 
00319 #if PX_VC
00320 #define PX_PUSH_PACK_DEFAULT __pragma(pack(push, 8))
00321 #define PX_POP_PACK __pragma(pack(pop))
00322 #elif PX_GCC_FAMILY
00323 #define PX_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)")
00324 #define PX_POP_PACK _Pragma("pack(pop)")
00325 #else
00326 #define PX_PUSH_PACK_DEFAULT
00327 #define PX_POP_PACK
00328 #endif
00329 
00333 #define PX_INLINE inline
00334 #if PX_MICROSOFT_FAMILY
00335 #pragma inline_depth(255)
00336 #endif
00337 
00341 #if PX_VC
00342 #define PX_FORCE_INLINE __forceinline
00343 #elif PX_LINUX // Workaround; Fedora Core 3 do not agree with force inline and PxcPool
00344 #define PX_FORCE_INLINE inline
00345 #elif PX_GCC_FAMILY
00346 #define PX_FORCE_INLINE inline __attribute__((always_inline))
00347 #else
00348 #define PX_FORCE_INLINE inline
00349 #endif
00350 
00354 #if PX_MICROSOFT_FAMILY
00355 #define PX_NOINLINE __declspec(noinline)
00356 #elif PX_GCC_FAMILY
00357 #define PX_NOINLINE __attribute__((noinline))
00358 #else
00359 #define PX_NOINLINE
00360 #endif
00361 
00365 #if defined(__CUDACC__)
00366 #define PX_RESTRICT __restrict__
00367 #else
00368 #define PX_RESTRICT __restrict
00369 #endif
00370 
00374 #if PX_MICROSOFT_FAMILY
00375 #define PX_NOALIAS __declspec(noalias)
00376 #else
00377 #define PX_NOALIAS
00378 #endif
00379 
00391 #ifndef PX_ALIGN
00392 #if PX_MICROSOFT_FAMILY
00393 #define PX_ALIGN(alignment, decl) __declspec(align(alignment)) decl
00394 #define PX_ALIGN_PREFIX(alignment) __declspec(align(alignment))
00395 #define PX_ALIGN_SUFFIX(alignment)
00396 #elif PX_GCC_FAMILY
00397 #define PX_ALIGN(alignment, decl) decl __attribute__((aligned(alignment)))
00398 #define PX_ALIGN_PREFIX(alignment)
00399 #define PX_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment)))
00400 #elif defined __CUDACC__
00401 #define PX_ALIGN(alignment, decl) __align__(alignment) decl
00402 #define PX_ALIGN_PREFIX(alignment)
00403 #define PX_ALIGN_SUFFIX(alignment) __align__(alignment))
00404 #else
00405 #define PX_ALIGN(alignment, decl)
00406 #define PX_ALIGN_PREFIX(alignment)
00407 #define PX_ALIGN_SUFFIX(alignment)
00408 #endif
00409 #endif
00410 
00421 #define PX_DEPRECATED
00422 
00427 // static assert
00428 #if(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (PX_PS4) || (PX_APPLE_FAMILY) || (PX_NX) || (PX_CLANG && PX_ARM)
00429 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1] __attribute__((unused))
00430 #else
00431 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1]
00432 #endif
00433 
00434 #if PX_GCC_FAMILY
00435 #define PX_OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
00436 #else
00437 #define PX_OFFSET_OF(X, Y) offsetof(X, Y)
00438 #endif
00439 
00440 #define PX_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want
00441 #define PX_OFFSET_OF_RT(Class, Member)                                                                                 \
00442     (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(PX_OFFSETOF_BASE)->Member) - size_t(PX_OFFSETOF_BASE))
00443 
00444 // check that exactly one of NDEBUG and _DEBUG is defined
00445 #if !defined(NDEBUG) ^ defined(_DEBUG)
00446 #error Exactly one of NDEBUG and _DEBUG needs to be defined!
00447 #endif
00448 
00449 // make sure PX_CHECKED is defined in all _DEBUG configurations as well
00450 #if !PX_CHECKED && PX_DEBUG
00451 #error PX_CHECKED must be defined when PX_DEBUG is defined
00452 #endif
00453 
00454 #ifdef __CUDACC__
00455 #define PX_CUDA_CALLABLE __host__ __device__
00456 #else
00457 #define PX_CUDA_CALLABLE
00458 #endif
00459 
00460 // avoid unreferenced parameter warning
00461 // preferred solution: omit the parameter's name from the declaration
00462 template <class T>
00463 PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const&)
00464 {
00465 }
00466 
00467 // Ensure that the application hasn't tweaked the pack value to less than 8, which would break
00468 // matching between the API headers and the binaries
00469 // This assert works on win32/win64, but may need further specialization on other platforms.
00470 // Some GCC compilers need the compiler flag -malign-double to be set.
00471 // Apparently the apple-clang-llvm compiler doesn't support malign-double.
00472 #if PX_PS4 || PX_APPLE_FAMILY || (PX_CLANG && !PX_ARM)
00473 struct PxPackValidation
00474 {
00475     char _;
00476     long a;
00477 };
00478 #elif PX_ANDROID || (PX_CLANG && PX_ARM)
00479 struct PxPackValidation
00480 {
00481     char _;
00482     double a;
00483 };
00484 #else
00485 struct PxPackValidation
00486 {
00487     char _;
00488     long long a;
00489 };
00490 #endif
00491 #if !PX_APPLE_FAMILY && !PX_EMSCRIPTEN
00492 PX_COMPILE_TIME_ASSERT(PX_OFFSET_OF(PxPackValidation, a) == 8);
00493 #endif
00494 
00495 // use in a cpp file to suppress LNK4221
00496 #if PX_VC
00497 #define PX_DUMMY_SYMBOL                                                                                                \
00498     namespace                                                                                                          \
00499     {                                                                                                                  \
00500     char PxDummySymbol;                                                                                                \
00501     }
00502 #else
00503 #define PX_DUMMY_SYMBOL
00504 #endif
00505 
00506 #if PX_GCC_FAMILY
00507 #define PX_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization
00508 #else
00509 #define PX_WEAK_SYMBOL
00510 #endif
00511 
00512 // Macro for avoiding default assignment and copy, because doing this by inheritance can increase class size on some
00513 // platforms.
00514 #define PX_NOCOPY(Class)                                                                                               \
00515     \
00516 protected:                                                                                                             \
00517     Class(const Class&);                                                                                               \
00518     Class& operator=(const Class&);
00519 
00520 #define PX_STRINGIZE_HELPER(X) #X
00521 #define PX_STRINGIZE(X) PX_STRINGIZE_HELPER(X)
00522 
00523 #define PX_CONCAT_HELPER(X, Y) X##Y
00524 #define PX_CONCAT(X, Y) PX_CONCAT_HELPER(X, Y)
00525 
00526 #ifndef DISABLE_CUDA_PHYSX
00527 //CUDA is currently supported only on windows 
00528 #define PX_SUPPORT_GPU_PHYSX ((PX_WINDOWS_FAMILY) || (PX_LINUX && PX_X64))
00529 #else
00530 #define PX_SUPPORT_GPU_PHYSX 0
00531 #endif
00532 
00533 #define PX_SUPPORT_COMPUTE_PHYSX 0
00534 
00535 #ifndef PX_SUPPORT_EXTERN_TEMPLATE
00536 #define PX_SUPPORT_EXTERN_TEMPLATE ((!PX_ANDROID) && (PX_VC != 11))
00537 #else
00538 #define PX_SUPPORT_EXTERN_TEMPLATE 0
00539 #endif
00540 
00542 #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