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(__clang__) && (defined(_WIN32) || defined(_WIN64)))
00035 #include <ciso646>
00036 #endif
00037
00041
00042
00043
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 #else
00091 #error "Unknown operating system"
00092 #endif
00093
00097 #if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value
00098 #define PX_X64 1
00099 #elif defined(__i386__) || defined(_M_IX86) || defined (__EMSCRIPTEN__)
00100 #define PX_X86 1
00101 #elif defined(__arm64__) || defined(__aarch64__)
00102 #define PX_A64 1
00103 #elif defined(__arm__) || defined(_M_ARM)
00104 #define PX_ARM 1
00105 #elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
00106 #define PX_PPC 1
00107 #else
00108 #error "Unknown architecture"
00109 #endif
00110
00114 #if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || defined (__EMSCRIPTEN__)
00115 #define PX_SSE2 1
00116 #endif
00117 #if defined(_M_ARM) || defined(__ARM_NEON__)
00118 #define PX_NEON 1
00119 #endif
00120 #if defined(_M_PPC) || defined(__CELLOS_LV2__)
00121 #define PX_VMX 1
00122 #endif
00123
00127 #ifndef PX_VC
00128 #define PX_VC 0
00129 #endif
00130 #ifndef PX_CLANG
00131 #define PX_CLANG 0
00132 #endif
00133 #ifndef PX_GCC
00134 #define PX_GCC 0
00135 #endif
00136 #ifndef PX_XBOXONE
00137 #define PX_XBOXONE 0
00138 #endif
00139 #ifndef PX_WIN64
00140 #define PX_WIN64 0
00141 #endif
00142 #ifndef PX_WIN32
00143 #define PX_WIN32 0
00144 #endif
00145 #ifndef PX_ANDROID
00146 #define PX_ANDROID 0
00147 #endif
00148 #ifndef PX_LINUX
00149 #define PX_LINUX 0
00150 #endif
00151 #ifndef PX_IOS
00152 #define PX_IOS 0
00153 #endif
00154 #ifndef PX_OSX
00155 #define PX_OSX 0
00156 #endif
00157 #ifndef PX_PS4
00158 #define PX_PS4 0
00159 #endif
00160 #ifndef PX_X64
00161 #define PX_X64 0
00162 #endif
00163 #ifndef PX_X86
00164 #define PX_X86 0
00165 #endif
00166 #ifndef PX_A64
00167 #define PX_A64 0
00168 #endif
00169 #ifndef PX_ARM
00170 #define PX_ARM 0
00171 #endif
00172 #ifndef PX_PPC
00173 #define PX_PPC 0
00174 #endif
00175 #ifndef PX_SSE2
00176 #define PX_SSE2 0
00177 #endif
00178 #ifndef PX_NEON
00179 #define PX_NEON 0
00180 #endif
00181 #ifndef PX_VMX
00182 #define PX_VMX 0
00183 #endif
00184
00185
00186
00187
00188 #ifndef PX_DEBUG
00189 #define PX_DEBUG 0
00190 #endif
00191 #ifndef PX_CHECKED
00192 #define PX_CHECKED 0
00193 #endif
00194 #ifndef PX_PROFILE
00195 #define PX_PROFILE 0
00196 #endif
00197 #ifndef PX_NVTX
00198 #define PX_NVTX 0
00199 #endif
00200 #ifndef PX_DOXYGEN
00201 #define PX_DOXYGEN 0
00202 #endif
00203
00207
00208 #define PX_GCC_FAMILY (PX_CLANG || PX_GCC)
00209
00210 #define PX_WINDOWS_FAMILY (PX_WIN32 || PX_WIN64)
00211 #define PX_MICROSOFT_FAMILY (PX_XBOXONE || PX_WINDOWS_FAMILY)
00212 #define PX_LINUX_FAMILY (PX_LINUX || PX_ANDROID)
00213 #define PX_APPLE_FAMILY (PX_IOS || PX_OSX) // equivalent to #if __APPLE__
00214 #define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY) // shortcut for unix/posix platforms
00215 #if defined(__EMSCRIPTEN__)
00216 #define PX_EMSCRIPTEN 1
00217 #else
00218 #define PX_EMSCRIPTEN 0
00219 #endif
00220
00221 #define PX_INTEL_FAMILY (PX_X64 || PX_X86)
00222 #define PX_ARM_FAMILY (PX_ARM || PX_A64)
00223 #define PX_P64_FAMILY (PX_X64 || PX_A64) // shortcut for 64-bit architectures
00224
00228 #if defined(_LIBCPP_VERSION) || PX_WIN64 || PX_WIN32 || PX_PS4 || PX_XBOXONE || PX_EMSCRIPTEN
00229 #define PX_LIBCPP 1
00230 #else
00231 #define PX_LIBCPP 0
00232 #endif
00233
00234
00235 #define PX_WINDOWS (PX_WINDOWS_FAMILY && !PX_ARM_FAMILY)
00236
00240 #ifndef PX_ENABLE_ASSERTS
00241 #if PX_DEBUG && !defined(__CUDACC__)
00242 #define PX_ENABLE_ASSERTS 1
00243 #else
00244 #define PX_ENABLE_ASSERTS 0
00245 #endif
00246 #endif
00247
00251 #ifndef PX_C_EXPORT
00252 #if PX_WINDOWS_FAMILY || PX_LINUX
00253 #define PX_C_EXPORT extern "C"
00254 #else
00255 #define PX_C_EXPORT
00256 #endif
00257 #endif
00258
00259 #if PX_UNIX_FAMILY&& __GNUC__ >= 4
00260 #define PX_UNIX_EXPORT __attribute__((visibility("default")))
00261 #else
00262 #define PX_UNIX_EXPORT
00263 #endif
00264
00265 #if PX_WINDOWS_FAMILY
00266 #define PX_DLL_EXPORT __declspec(dllexport)
00267 #define PX_DLL_IMPORT __declspec(dllimport)
00268 #else
00269 #define PX_DLL_EXPORT PX_UNIX_EXPORT
00270 #define PX_DLL_IMPORT
00271 #endif
00272
00282 #if PX_WINDOWS_FAMILY && !PX_ARM_FAMILY
00283 #ifndef PX_FOUNDATION_DLL
00284 #define PX_FOUNDATION_API PX_DLL_IMPORT
00285 #elif PX_FOUNDATION_DLL
00286 #define PX_FOUNDATION_API PX_DLL_EXPORT
00287 #endif
00288 #elif PX_UNIX_FAMILY
00289 #ifdef PX_FOUNDATION_DLL
00290 #define PX_FOUNDATION_API PX_UNIX_EXPORT
00291 #endif
00292 #endif
00293
00294 #ifndef PX_FOUNDATION_API
00295 #define PX_FOUNDATION_API
00296 #endif
00297
00301 #ifndef PX_CALL_CONV
00302 #if PX_MICROSOFT_FAMILY
00303 #define PX_CALL_CONV __cdecl
00304 #else
00305 #define PX_CALL_CONV
00306 #endif
00307 #endif
00308
00312 #if PX_VC
00313 #define PX_PUSH_PACK_DEFAULT __pragma(pack(push, 8))
00314 #define PX_POP_PACK __pragma(pack(pop))
00315 #elif PX_GCC_FAMILY
00316 #define PX_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)")
00317 #define PX_POP_PACK _Pragma("pack(pop)")
00318 #else
00319 #define PX_PUSH_PACK_DEFAULT
00320 #define PX_POP_PACK
00321 #endif
00322
00326 #define PX_INLINE inline
00327 #if PX_MICROSOFT_FAMILY
00328 #pragma inline_depth(255)
00329 #endif
00330
00334 #if PX_VC
00335 #define PX_FORCE_INLINE __forceinline
00336 #elif PX_LINUX // Workaround; Fedora Core 3 do not agree with force inline and PxcPool
00337 #define PX_FORCE_INLINE inline
00338 #elif PX_GCC_FAMILY
00339 #define PX_FORCE_INLINE inline __attribute__((always_inline))
00340 #else
00341 #define PX_FORCE_INLINE inline
00342 #endif
00343
00347 #if PX_MICROSOFT_FAMILY
00348 #define PX_NOINLINE __declspec(noinline)
00349 #elif PX_GCC_FAMILY
00350 #define PX_NOINLINE __attribute__((noinline))
00351 #else
00352 #define PX_NOINLINE
00353 #endif
00354
00358 #if defined(__CUDACC__)
00359 #define PX_RESTRICT __restrict__
00360 #else
00361 #define PX_RESTRICT __restrict
00362 #endif
00363
00367 #if PX_MICROSOFT_FAMILY
00368 #define PX_NOALIAS __declspec(noalias)
00369 #else
00370 #define PX_NOALIAS
00371 #endif
00372
00384 #ifndef PX_ALIGN
00385 #if PX_MICROSOFT_FAMILY
00386 #define PX_ALIGN(alignment, decl) __declspec(align(alignment)) decl
00387 #define PX_ALIGN_PREFIX(alignment) __declspec(align(alignment))
00388 #define PX_ALIGN_SUFFIX(alignment)
00389 #elif PX_GCC_FAMILY
00390 #define PX_ALIGN(alignment, decl) decl __attribute__((aligned(alignment)))
00391 #define PX_ALIGN_PREFIX(alignment)
00392 #define PX_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment)))
00393 #elif defined __CUDACC__
00394 #define PX_ALIGN(alignment, decl) __align__(alignment) decl
00395 #define PX_ALIGN_PREFIX(alignment)
00396 #define PX_ALIGN_SUFFIX(alignment) __align__(alignment))
00397 #else
00398 #define PX_ALIGN(alignment, decl)
00399 #define PX_ALIGN_PREFIX(alignment)
00400 #define PX_ALIGN_SUFFIX(alignment)
00401 #endif
00402 #endif
00403
00414 #define PX_DEPRECATED
00415
00420
00421 #if(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (PX_PS4) || (PX_APPLE_FAMILY)
00422 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1] __attribute__((unused))
00423 #else
00424 #define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1]
00425 #endif
00426
00427 #if PX_GCC_FAMILY
00428 #define PX_OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
00429 #else
00430 #define PX_OFFSET_OF(X, Y) offsetof(X, Y)
00431 #endif
00432
00433 #define PX_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want
00434 #define PX_OFFSET_OF_RT(Class, Member) \
00435 (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(PX_OFFSETOF_BASE)->Member) - size_t(PX_OFFSETOF_BASE))
00436
00437
00438 #if !defined(NDEBUG) ^ defined(_DEBUG)
00439 #error Exactly one of NDEBUG and _DEBUG needs to be defined!
00440 #endif
00441
00442
00443 #if !PX_CHECKED && PX_DEBUG
00444 #error PX_CHECKED must be defined when PX_DEBUG is defined
00445 #endif
00446
00447 #ifdef __CUDACC__
00448 #define PX_CUDA_CALLABLE __host__ __device__
00449 #else
00450 #define PX_CUDA_CALLABLE
00451 #endif
00452
00453
00454
00455 template <class T>
00456 PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const&)
00457 {
00458 }
00459
00460
00461
00462
00463
00464
00465 #if PX_PS4 || PX_APPLE_FAMILY
00466 struct PxPackValidation
00467 {
00468 char _;
00469 long a;
00470 };
00471 #elif PX_ANDROID
00472 struct PxPackValidation
00473 {
00474 char _;
00475 double a;
00476 };
00477 #else
00478 struct PxPackValidation
00479 {
00480 char _;
00481 long long a;
00482 };
00483 #endif
00484 #if !PX_APPLE_FAMILY
00485 PX_COMPILE_TIME_ASSERT(PX_OFFSET_OF(PxPackValidation, a) == 8);
00486 #endif
00487
00488
00489 #if PX_VC
00490 #define PX_DUMMY_SYMBOL \
00491 namespace \
00492 { \
00493 char PxDummySymbol; \
00494 }
00495 #else
00496 #define PX_DUMMY_SYMBOL
00497 #endif
00498
00499 #if PX_GCC_FAMILY
00500 #define PX_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization
00501 #else
00502 #define PX_WEAK_SYMBOL
00503 #endif
00504
00505
00506
00507 #define PX_NOCOPY(Class) \
00508 \
00509 protected: \
00510 Class(const Class&); \
00511 Class& operator=(const Class&);
00512
00513 #define PX_STRINGIZE_HELPER(X) #X
00514 #define PX_STRINGIZE(X) PX_STRINGIZE_HELPER(X)
00515
00516 #define PX_CONCAT_HELPER(X, Y) X##Y
00517 #define PX_CONCAT(X, Y) PX_CONCAT_HELPER(X, Y)
00518
00519 #ifndef DISABLE_CUDA_PHYSX
00520
00521 #define PX_SUPPORT_GPU_PHYSX ((PX_WINDOWS_FAMILY) || (PX_LINUX && PX_X64))
00522 #else
00523 #define PX_SUPPORT_GPU_PHYSX 0
00524 #endif
00525
00526 #define PX_SUPPORT_COMPUTE_PHYSX 0
00527
00529 #endif // #ifndef PXFOUNDATION_PXPREPROCESSOR_H