00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
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 #define PX_STRINGIZE_HELPER(X) #X
00042 #define PX_STRINGIZE(X) PX_STRINGIZE_HELPER(X)
00043
00044 #define PX_CONCAT_HELPER(X, Y) X##Y
00045 #define PX_CONCAT(X, Y) PX_CONCAT_HELPER(X, Y)
00046
00047
00048
00049
00050
00051
00055 #if defined(_MSC_VER)
00056 #if _MSC_VER >= 1910
00057 #define PX_VC 15
00058 #elif _MSC_VER >= 1900
00059 #define PX_VC 14
00060 #elif _MSC_VER >= 1800
00061 #define PX_VC 12
00062 #elif _MSC_VER >= 1700
00063 #define PX_VC 11
00064 #elif _MSC_VER >= 1600
00065 #define PX_VC 10
00066 #elif _MSC_VER >= 1500
00067 #define PX_VC 9
00068 #else
00069 #error "Unknown VC version"
00070 #endif
00071 #elif defined(__clang__)
00072 #define PX_CLANG 1
00073 #elif defined(__GNUC__) // note: __clang__ implies __GNUC__
00074 #define PX_GCC 1
00075 #else
00076 #error "Unknown compiler"
00077 #endif
00078
00082 #if defined(_XBOX_ONE)
00083 #define PX_XBOXONE 1
00084 #elif defined(_WIN64) // note: _XBOX_ONE implies _WIN64
00085 #define PX_WIN64 1
00086 #elif defined(_WIN32) // note: _M_PPC implies _WIN32
00087 #define PX_WIN32 1
00088 #elif defined(__ANDROID__)
00089 #define PX_ANDROID 1
00090 #elif defined(__linux__) || defined (__EMSCRIPTEN__) // note: __ANDROID__ implies __linux__
00091 #define PX_LINUX 1
00092 #elif defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
00093 #define PX_IOS 1
00094 #elif defined(__APPLE__)
00095 #define PX_OSX 1
00096 #elif defined(__ORBIS__)
00097 #define PX_PS4 1
00098 #elif defined(__NX__)
00099 #define PX_SWITCH 1
00100 #else
00101 #error "Unknown operating system"
00102 #endif
00103
00107 #if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value
00108 #define PX_X64 1
00109 #elif defined(__i386__) || defined(_M_IX86) || defined (__EMSCRIPTEN__)
00110 #define PX_X86 1
00111 #elif defined(__arm64__) || defined(__aarch64__)
00112 #define PX_A64 1
00113 #elif defined(__arm__) || defined(_M_ARM)
00114 #define PX_ARM 1
00115 #elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
00116 #define PX_PPC 1
00117 #else
00118 #error "Unknown architecture"
00119 #endif
00120
00124 #if !defined(PX_SIMD_DISABLED)
00125 #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || (defined (__EMSCRIPTEN__) && defined(__SSE2__))
00126 #define PX_SSE2 1
00127 #endif
00128 #if defined(_M_ARM) || defined(__ARM_NEON__) || defined(__ARM_NEON)
00129 #define PX_NEON 1
00130 #endif
00131 #if defined(_M_PPC) || defined(__CELLOS_LV2__)
00132 #define PX_VMX 1
00133 #endif
00134 #endif
00135
00139 #ifndef PX_VC
00140 #define PX_VC 0
00141 #endif
00142 #ifndef PX_CLANG
00143 #define PX_CLANG 0
00144 #endif
00145 #ifndef PX_GCC
00146 #define PX_GCC 0
00147 #endif
00148 #ifndef PX_XBOXONE
00149 #define PX_XBOXONE 0
00150 #endif
00151 #ifndef PX_WIN64
00152 #define PX_WIN64 0
00153 #endif
00154 #ifndef PX_WIN32
00155 #define PX_WIN32 0
00156 #endif
00157 #ifndef PX_ANDROID
00158 #define PX_ANDROID 0
00159 #endif
00160 #ifndef PX_LINUX
00161 #define PX_LINUX 0
00162 #endif
00163 #ifndef PX_IOS
00164 #define PX_IOS 0
00165 #endif
00166 #ifndef PX_OSX
00167 #define PX_OSX 0
00168 #endif
00169 #ifndef PX_PS4
00170 #define PX_PS4 0
00171 #endif
00172 #ifndef PX_SWITCH
00173 #define PX_SWITCH 0
00174 #endif
00175 #ifndef PX_X64
00176 #define PX_X64 0
00177 #endif
00178 #ifndef PX_X86
00179 #define PX_X86 0
00180 #endif
00181 #ifndef PX_A64
00182 #define PX_A64 0
00183 #endif
00184 #ifndef PX_ARM
00185 #define PX_ARM 0
00186 #endif
00187 #ifndef PX_PPC
00188 #define PX_PPC 0
00189 #endif
00190 #ifndef PX_SSE2
00191 #define PX_SSE2 0
00192 #endif
00193 #ifndef PX_NEON
00194 #define PX_NEON 0
00195 #endif
00196 #ifndef PX_VMX
00197 #define PX_VMX 0
00198 #endif
00199
00200
00201
00202
00203 #ifndef PX_DEBUG
00204 #define PX_DEBUG 0
00205 #endif
00206 #ifndef PX_CHECKED
00207 #define PX_CHECKED 0
00208 #endif
00209 #ifndef PX_PROFILE
00210 #define PX_PROFILE 0
00211 #endif
00212 #ifndef PX_NVTX
00213 #define PX_NVTX 0
00214 #endif
00215 #ifndef PX_DOXYGEN
00216 #define PX_DOXYGEN 0
00217 #endif
00218
00222
00223 #define PX_GCC_FAMILY (PX_CLANG || PX_GCC)
00224
00225 #define PX_WINDOWS_FAMILY (PX_WIN32 || PX_WIN64)
00226 #define PX_MICROSOFT_FAMILY (PX_XBOXONE || PX_WINDOWS_FAMILY)
00227 #define PX_LINUX_FAMILY (PX_LINUX || PX_ANDROID)
00228 #define PX_APPLE_FAMILY (PX_IOS || PX_OSX) // equivalent to #if __APPLE__
00229 #define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY) // shortcut for unix/posix platforms
00230 #if defined(__EMSCRIPTEN__)
00231 #define PX_EMSCRIPTEN 1
00232 #else
00233 #define PX_EMSCRIPTEN 0
00234 #endif
00235
00236 #define PX_INTEL_FAMILY (PX_X64 || PX_X86)
00237 #define PX_ARM_FAMILY (PX_ARM || PX_A64)
00238 #define PX_P64_FAMILY (PX_X64 || PX_A64) // shortcut for 64-bit architectures
00239
00243 #if defined(_LIBCPP_VERSION) || PX_WIN64 || PX_WIN32 || PX_PS4 || PX_XBOXONE || PX_EMSCRIPTEN
00244 #define PX_LIBCPP 1
00245 #else
00246 #define PX_LIBCPP 0
00247 #endif
00248
00249
00250 #define PX_WINDOWS (PX_WINDOWS_FAMILY && !PX_ARM_FAMILY)
00251
00255 #ifndef PX_ENABLE_ASSERTS
00256 #if PX_DEBUG && !defined(__CUDACC__)
00257 #define PX_ENABLE_ASSERTS 1
00258 #else
00259 #define PX_ENABLE_ASSERTS 0
00260 #endif
00261 #endif
00262
00266 #ifndef PX_C_EXPORT
00267 #if PX_WINDOWS_FAMILY || PX_LINUX
00268 #define PX_C_EXPORT extern "C"
00269 #else
00270 #define PX_C_EXPORT
00271 #endif
00272 #endif
00273
00274 #if PX_UNIX_FAMILY&& __GNUC__ >= 4
00275 #define PX_UNIX_EXPORT __attribute__((visibility("default")))
00276 #else
00277 #define PX_UNIX_EXPORT
00278 #endif
00279
00280 #if PX_WINDOWS_FAMILY
00281 #define PX_DLL_EXPORT __declspec(dllexport)
00282 #define PX_DLL_IMPORT __declspec(dllimport)
00283 #else
00284 #define PX_DLL_EXPORT PX_UNIX_EXPORT
00285 #define PX_DLL_IMPORT
00286 #endif
00287
00297 #if PX_WINDOWS_FAMILY && !PX_ARM_FAMILY
00298 #ifndef PX_FOUNDATION_DLL
00299 #define PX_FOUNDATION_API PX_DLL_IMPORT
00300 #elif PX_FOUNDATION_DLL
00301 #define PX_FOUNDATION_API PX_DLL_EXPORT
00302 #endif
00303 #elif PX_UNIX_FAMILY
00304 #ifdef PX_FOUNDATION_DLL
00305 #define PX_FOUNDATION_API PX_UNIX_EXPORT
00306 #endif
00307 #endif
00308
00309 #ifndef PX_FOUNDATION_API
00310 #define PX_FOUNDATION_API
00311 #endif
00312
00316 #ifndef PX_CALL_CONV
00317 #if PX_MICROSOFT_FAMILY
00318 #define PX_CALL_CONV __cdecl
00319 #else
00320 #define PX_CALL_CONV
00321 #endif
00322 #endif
00323
00327 #if PX_VC
00328 #define PX_PUSH_PACK_DEFAULT __pragma(pack(push, 8))
00329 #define PX_POP_PACK __pragma(pack(pop))
00330 #elif PX_GCC_FAMILY
00331 #define PX_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)")
00332 #define PX_POP_PACK _Pragma("pack(pop)")
00333 #else
00334 #define PX_PUSH_PACK_DEFAULT
00335 #define PX_POP_PACK
00336 #endif
00337
00341 #define PX_INLINE inline
00342 #if PX_MICROSOFT_FAMILY
00343 #pragma inline_depth(255)
00344 #endif
00345
00349 #if PX_VC
00350 #define PX_FORCE_INLINE __forceinline
00351 #elif PX_LINUX // Workaround; Fedora Core 3 do not agree with force inline and PxcPool
00352 #define PX_FORCE_INLINE inline
00353 #elif PX_GCC_FAMILY
00354 #define PX_FORCE_INLINE inline __attribute__((always_inline))
00355 #else
00356 #define PX_FORCE_INLINE inline
00357 #endif
00358
00362 #if PX_MICROSOFT_FAMILY
00363 #define PX_NOINLINE __declspec(noinline)
00364 #elif PX_GCC_FAMILY
00365 #define PX_NOINLINE __attribute__((noinline))
00366 #else
00367 #define PX_NOINLINE
00368 #endif
00369
00373 #if defined(__CUDACC__)
00374 #define PX_RESTRICT __restrict__
00375 #else
00376 #define PX_RESTRICT __restrict
00377 #endif
00378
00382 #if PX_MICROSOFT_FAMILY
00383 #define PX_NOALIAS __declspec(noalias)
00384 #else
00385 #define PX_NOALIAS
00386 #endif
00387
00399 #ifndef PX_ALIGN
00400 #if PX_MICROSOFT_FAMILY
00401 #define PX_ALIGN(alignment, decl) __declspec(align(alignment)) decl
00402 #define PX_ALIGN_PREFIX(alignment) __declspec(align(alignment))
00403 #define PX_ALIGN_SUFFIX(alignment)
00404 #elif PX_GCC_FAMILY
00405 #define PX_ALIGN(alignment, decl) decl __attribute__((aligned(alignment)))
00406 #define PX_ALIGN_PREFIX(alignment)
00407 #define PX_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment)))
00408 #elif defined __CUDACC__
00409 #define PX_ALIGN(alignment, decl) __align__(alignment) decl
00410 #define PX_ALIGN_PREFIX(alignment)
00411 #define PX_ALIGN_SUFFIX(alignment) __align__(alignment))
00412 #else
00413 #define PX_ALIGN(alignment, decl)
00414 #define PX_ALIGN_PREFIX(alignment)
00415 #define PX_ALIGN_SUFFIX(alignment)
00416 #endif
00417 #endif
00418
00429 #define PX_DEPRECATED
00430
00435
00436 #if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (PX_PS4) || (PX_APPLE_FAMILY) || (PX_SWITCH) || (PX_CLANG && PX_ARM)
00437 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PX_CONCAT(PxCompileTimeAssert_Dummy, __COUNTER__)[(exp) ? 1 : -1] __attribute__((unused))
00438 #else
00439 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1]
00440 #endif
00441
00442 #if PX_GCC_FAMILY
00443 #define PX_OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
00444 #else
00445 #define PX_OFFSET_OF(X, Y) offsetof(X, Y)
00446 #endif
00447
00448 #define PX_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want
00449 #define PX_OFFSET_OF_RT(Class, Member) \
00450 (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(PX_OFFSETOF_BASE)->Member) - size_t(PX_OFFSETOF_BASE))
00451
00452
00453 #if !defined(NDEBUG) ^ defined(_DEBUG)
00454 #error Exactly one of NDEBUG and _DEBUG needs to be defined!
00455 #endif
00456
00457
00458 #if !PX_CHECKED && PX_DEBUG
00459 #error PX_CHECKED must be defined when PX_DEBUG is defined
00460 #endif
00461
00462 #ifdef __CUDACC__
00463 #define PX_CUDA_CALLABLE __host__ __device__
00464 #else
00465 #define PX_CUDA_CALLABLE
00466 #endif
00467
00468
00469
00470 template <class T>
00471 PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const&)
00472 {
00473 }
00474
00475
00476
00477
00478
00479
00480 #if PX_PS4 || PX_APPLE_FAMILY || (PX_CLANG && !PX_ARM)
00481 struct PxPackValidation
00482 {
00483 char _;
00484 long a;
00485 };
00486 #elif PX_ANDROID || (PX_CLANG && PX_ARM)
00487 struct PxPackValidation
00488 {
00489 char _;
00490 double a;
00491 };
00492 #else
00493 struct PxPackValidation
00494 {
00495 char _;
00496 long long a;
00497 };
00498 #endif
00499
00500 #if !PX_APPLE_FAMILY && !PX_EMSCRIPTEN && !(PX_CLANG && PX_X86)
00501 PX_COMPILE_TIME_ASSERT(PX_OFFSET_OF(PxPackValidation, a) == 8);
00502 #endif
00503
00504
00505 #if PX_VC
00506 #define PX_DUMMY_SYMBOL \
00507 namespace \
00508 { \
00509 char PxDummySymbol; \
00510 }
00511 #else
00512 #define PX_DUMMY_SYMBOL
00513 #endif
00514
00515 #if PX_GCC_FAMILY
00516 #define PX_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization
00517 #else
00518 #define PX_WEAK_SYMBOL
00519 #endif
00520
00521
00522
00523 #define PX_NOCOPY(Class) \
00524 \
00525 protected: \
00526 Class(const Class&); \
00527 Class& operator=(const Class&);
00528
00529 #ifndef DISABLE_CUDA_PHYSX
00530
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