1//
2// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions
4// are met:
5// * Redistributions of source code must retain the above copyright
6// notice, this list of conditions and the following disclaimer.
7// * Redistributions in binary form must reproduce the above copyright
8// notice, this list of conditions and the following disclaimer in the
9// documentation and/or other materials provided with the distribution.
10// * Neither the name of NVIDIA CORPORATION nor the names of its
11// contributors may be used to endorse or promote products derived
12// from this software without specific prior written permission.
13//
14// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25//
26// Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29
30#ifndef PXFOUNDATION_PXPREPROCESSOR_H
31#define PXFOUNDATION_PXPREPROCESSOR_H
32
33#include <stddef.h>
34#if !defined(PX_GENERATE_META_DATA)
35#include <ciso646>
36#endif
37/** \addtogroup foundation
38 @{
39*/
40
41#define PX_STRINGIZE_HELPER(X) #X
42#define PX_STRINGIZE(X) PX_STRINGIZE_HELPER(X)
43
44#define PX_CONCAT_HELPER(X, Y) X##Y
45#define PX_CONCAT(X, Y) PX_CONCAT_HELPER(X, Y)
46
47/*
48The following preprocessor identifiers specify compiler, OS, and architecture.
49All definitions have a value of 1 or 0, use '#if' instead of '#ifdef'.
50*/
51
52/**
53Compiler defines, see http://sourceforge.net/p/predef/wiki/Compilers/
54*/
55#if defined(_MSC_VER)
56#if _MSC_VER >= 1910
57#define PX_VC 15
58#elif _MSC_VER >= 1900
59#define PX_VC 14
60#elif _MSC_VER >= 1800
61#define PX_VC 12
62#elif _MSC_VER >= 1700
63#define PX_VC 11
64#elif _MSC_VER >= 1600
65#define PX_VC 10
66#elif _MSC_VER >= 1500
67#define PX_VC 9
68#else
69#error "Unknown VC version"
70#endif
71#elif defined(__clang__)
72#define PX_CLANG 1
73 #if defined (__clang_major__)
74 #define PX_CLANG_MAJOR __clang_major__
75 #elif defined (_clang_major)
76 #define PX_CLANG_MAJOR _clang_major
77 #else
78 #define PX_CLANG_MAJOR 0
79 #endif
80#elif defined(__GNUC__) // note: __clang__ implies __GNUC__
81#define PX_GCC 1
82#else
83#error "Unknown compiler"
84#endif
85
86/**
87Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSystems/
88*/
89#if defined(_XBOX_ONE)
90#define PX_XBOXONE 1
91#elif defined(_GAMING_XBOX) || defined (_GAMING_XBOX_SCARLETT)
92#define PX_XBOX_SERIES_X 1
93#elif defined(WINAPI_FAMILY) && WINAPI_FAMILY == WINAPI_FAMILY_APP
94#define PX_UWP 1
95#elif defined(_WIN64) // note: _XBOX_ONE implies _WIN64
96#define PX_WIN64 1
97#elif defined(_WIN32) // note: _M_PPC implies _WIN32
98#define PX_WIN32 1
99#elif defined(__ANDROID__)
100#define PX_ANDROID 1
101#elif defined(__linux__) || defined (__EMSCRIPTEN__) // note: __ANDROID__ implies __linux__
102#define PX_LINUX 1
103#elif defined(TARGET_OS_IOS) && TARGET_OS_IOS && defined(__APPLE__) && (defined(__arm__) || defined(__arm64__))
104#define PX_IOS 1
105#elif defined(__APPLE__)
106#define PX_OSX 1
107#elif defined(__ORBIS__)
108#define PX_PS4 1
109#elif defined(__NX__)
110#define PX_SWITCH 1
111#else
112#error "Unknown operating system"
113#endif
114
115/**
116Architecture defines, see http://sourceforge.net/p/predef/wiki/Architectures/
117*/
118#if defined(__x86_64__) || defined(_M_X64) // ps4 compiler defines _M_X64 without value
119#define PX_X64 1
120#elif defined(__i386__) || defined(_M_IX86)
121#define PX_X86 1
122#elif defined(__arm64__) || defined(__aarch64__) || defined(_M_ARM64)
123#define PX_A64 1
124#elif defined(__arm__) || defined(_M_ARM)
125#define PX_ARM 1
126#elif defined(__ppc__) || defined(_M_PPC) || defined(__CELLOS_LV2__)
127#define PX_PPC 1
128#elif defined(__mips__)
129#define PX_X64 1
130#elif defined(__EMSCRIPTEN__)
131#define PX_WASM
132 #if defined(__LP64__)
133 #define PX_WASM_64 1
134 #else
135 #define PX_WASM_32 1
136 #endif
137#else
138#error "Unknown architecture"
139#endif
140
141/**
142SIMD defines
143*/
144#if !defined(PX_SIMD_DISABLED)
145#if defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64) || (defined (__EMSCRIPTEN__) && defined(__SSE2__))
146#define PX_SSE2 1
147#endif
148#if defined(_M_ARM) || defined(__ARM_NEON__) || defined(__ARM_NEON)
149#define PX_NEON 1
150#endif
151#if defined(_M_PPC) || defined(__CELLOS_LV2__)
152#define PX_VMX 1
153#endif
154#endif
155
156/** Disable SIMD for webassembly, mips and arm64 */
157#if defined(__EMSCRIPTEN__) || defined(__mips__) || defined(_M_ARM64) || defined(_M_ARM)
158#define PX_SIMD_DISABLED 1
159#endif
160
161/**
162define anything not defined on this platform to 0
163*/
164#ifndef PX_VC
165#define PX_VC 0
166#endif
167#ifndef PX_CLANG
168#define PX_CLANG 0
169#endif
170#ifndef PX_GCC
171#define PX_GCC 0
172#endif
173#ifndef PX_XBOXONE
174#define PX_XBOXONE 0
175#endif
176#ifndef PX_XBOX_SERIES_X
177#define PX_XBOX_SERIES_X 0
178#endif
179#ifndef PX_WIN64
180#define PX_WIN64 0
181#endif
182#ifndef PX_WIN32
183#define PX_WIN32 0
184#endif
185#ifndef PX_ANDROID
186#define PX_ANDROID 0
187#endif
188#ifndef PX_LINUX
189#define PX_LINUX 0
190#endif
191#ifndef PX_IOS
192#define PX_IOS 0
193#endif
194#ifndef PX_OSX
195#define PX_OSX 0
196#endif
197#ifndef PX_PS4
198#define PX_PS4 0
199#endif
200#ifndef PX_SWITCH
201#define PX_SWITCH 0
202#endif
203#ifndef PX_UWP
204#define PX_UWP 0
205#endif
206#ifndef PX_X64
207#define PX_X64 0
208#endif
209#ifndef PX_X86
210#define PX_X86 0
211#endif
212#ifndef PX_A64
213#define PX_A64 0
214#endif
215#ifndef PX_ARM
216#define PX_ARM 0
217#endif
218#ifndef PX_WASM
219#define PX_WASM 0
220#endif
221#ifndef PX_WASM_64
222#define PX_WASM_64 0
223#endif
224#ifndef PX_WASM_32
225#define PX_WASM_32 0
226#endif
227#ifndef PX_PPC
228#define PX_PPC 0
229#endif
230#ifndef PX_SSE2
231#define PX_SSE2 0
232#endif
233#ifndef PX_NEON
234#define PX_NEON 0
235#endif
236#ifndef PX_VMX
237#define PX_VMX 0
238#endif
239
240/*
241define anything not defined through the command line to 0
242*/
243#ifndef PX_DEBUG
244#define PX_DEBUG 0
245#endif
246#ifndef PX_CHECKED
247#define PX_CHECKED 0
248#endif
249#ifndef PX_PROFILE
250#define PX_PROFILE 0
251#endif
252#ifndef PX_DEBUG_CRT
253#define PX_DEBUG_CRT 0
254#endif
255#ifndef PX_NVTX
256#define PX_NVTX 0
257#endif
258#ifndef PX_DOXYGEN
259#define PX_DOXYGEN 0
260#endif
261
262/**
263family shortcuts
264*/
265// compiler
266#define PX_GCC_FAMILY (PX_CLANG || PX_GCC)
267// os
268#define PX_WINDOWS_FAMILY (PX_WIN32 || PX_WIN64 || PX_UWP)
269#define PX_MICROSOFT_FAMILY (PX_XBOXONE || PX_WINDOWS_FAMILY || PX_XBOX_SERIES_X)
270#define PX_LINUX_FAMILY (PX_LINUX || PX_ANDROID)
271#define PX_APPLE_FAMILY (PX_IOS || PX_OSX) // equivalent to #if __APPLE__
272#define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY) // shortcut for unix/posix platforms
273#if defined(__EMSCRIPTEN__)
274#define PX_EMSCRIPTEN 1
275#else
276#define PX_EMSCRIPTEN 0
277#endif
278// architecture
279#define PX_INTEL_FAMILY (PX_X64 || PX_X86)
280#define PX_ARM_FAMILY (PX_ARM || PX_A64)
281#define PX_P64_FAMILY (PX_X64 || PX_A64 || PX_WASM_64) // shortcut for 64-bit architectures
282
283/**
284C++ standard library defines
285*/
286#if defined(_LIBCPP_VERSION) || PX_WIN64 || PX_WIN32 || PX_PS4 || PX_XBOXONE || PX_UWP || PX_EMSCRIPTEN || PX_XBOX_SERIES_X
287#define PX_LIBCPP 1
288#else
289#define PX_LIBCPP 0
290#endif
291
292// legacy define for PhysX
293#define PX_WINDOWS (PX_WINDOWS_FAMILY && !PX_ARM_FAMILY)
294
295/**
296Assert macro
297*/
298#ifndef PX_ENABLE_ASSERTS
299#if PX_DEBUG && !defined(__CUDACC__)
300#define PX_ENABLE_ASSERTS 1
301#else
302#define PX_ENABLE_ASSERTS 0
303#endif
304#endif
305
306/**
307DLL export macros
308*/
309#ifndef PX_C_EXPORT
310#if PX_WINDOWS_FAMILY || PX_LINUX
311#define PX_C_EXPORT extern "C"
312#else
313#define PX_C_EXPORT
314#endif
315#endif
316
317#if PX_UNIX_FAMILY&& __GNUC__ >= 4
318#define PX_UNIX_EXPORT __attribute__((visibility("default")))
319#else
320#define PX_UNIX_EXPORT
321#endif
322
323#if (PX_WINDOWS_FAMILY || PX_XBOXONE || PX_PS4 || PX_XBOX_SERIES_X)
324#define PX_DLL_EXPORT __declspec(dllexport)
325#define PX_DLL_IMPORT __declspec(dllimport)
326#else
327#define PX_DLL_EXPORT PX_UNIX_EXPORT
328#define PX_DLL_IMPORT
329#endif
330
331/**
332Calling convention
333*/
334#ifndef PX_CALL_CONV
335#if PX_MICROSOFT_FAMILY
336#define PX_CALL_CONV __cdecl
337#else
338#define PX_CALL_CONV
339#endif
340#endif
341
342/**
343Pack macros - disabled on SPU because they are not supported
344*/
345#if PX_VC
346#define PX_PUSH_PACK_DEFAULT __pragma(pack(push, 8))
347#define PX_POP_PACK __pragma(pack(pop))
348#elif PX_GCC_FAMILY
349#define PX_PUSH_PACK_DEFAULT _Pragma("pack(push, 8)")
350#define PX_POP_PACK _Pragma("pack(pop)")
351#else
352#define PX_PUSH_PACK_DEFAULT
353#define PX_POP_PACK
354#endif
355
356/**
357Inline macro
358*/
359#define PX_INLINE inline
360#if PX_MICROSOFT_FAMILY
361#pragma inline_depth(255)
362#endif
363
364/**
365Force inline macro
366*/
367#if PX_VC
368#define PX_FORCE_INLINE __forceinline
369#elif PX_LINUX // Workaround; Fedora Core 3 do not agree with force inline and PxcPool
370#define PX_FORCE_INLINE inline
371#elif PX_GCC_FAMILY
372#define PX_FORCE_INLINE inline __attribute__((always_inline))
373#else
374#define PX_FORCE_INLINE inline
375#endif
376
377/**
378Noinline macro
379*/
380#if PX_MICROSOFT_FAMILY
381#define PX_NOINLINE __declspec(noinline)
382#elif PX_GCC_FAMILY
383#define PX_NOINLINE __attribute__((noinline))
384#else
385#define PX_NOINLINE
386#endif
387
388/**
389Restrict macro
390*/
391#if defined(__CUDACC__)
392#define PX_RESTRICT __restrict__
393#else
394#define PX_RESTRICT __restrict
395#endif
396
397/**
398Noalias macro
399*/
400#if PX_MICROSOFT_FAMILY
401#define PX_NOALIAS __declspec(noalias)
402#else
403#define PX_NOALIAS
404#endif
405
406/**
407Alignment macros
408
409PX_ALIGN_PREFIX and PX_ALIGN_SUFFIX can be used for type alignment instead of aligning individual variables as follows:
410PX_ALIGN_PREFIX(16)
411struct A {
412...
413} PX_ALIGN_SUFFIX(16);
414This declaration style is parsed correctly by Visual Assist.
415
416*/
417#ifndef PX_ALIGN
418#if PX_MICROSOFT_FAMILY
419#define PX_ALIGN(alignment, decl) __declspec(align(alignment)) decl
420#define PX_ALIGN_PREFIX(alignment) __declspec(align(alignment))
421#define PX_ALIGN_SUFFIX(alignment)
422#elif PX_GCC_FAMILY
423#define PX_ALIGN(alignment, decl) decl __attribute__((aligned(alignment)))
424#define PX_ALIGN_PREFIX(alignment)
425#define PX_ALIGN_SUFFIX(alignment) __attribute__((aligned(alignment)))
426#elif defined __CUDACC__
427#define PX_ALIGN(alignment, decl) __align__(alignment) decl
428#define PX_ALIGN_PREFIX(alignment)
429#define PX_ALIGN_SUFFIX(alignment) __align__(alignment))
430#else
431#define PX_ALIGN(alignment, decl)
432#define PX_ALIGN_PREFIX(alignment)
433#define PX_ALIGN_SUFFIX(alignment)
434#endif
435#endif
436
437/**
438Deprecated macro
439- To deprecate a function: Place PX_DEPRECATED at the start of the function header (leftmost word).
440- To deprecate a 'typedef', a 'struct' or a 'class': Place PX_DEPRECATED directly after the keywords ('typdef',
441'struct', 'class').
442
443Use these macro definitions to create warnings for deprecated functions
444\#define PX_DEPRECATED __declspec(deprecated) // Microsoft
445\#define PX_DEPRECATED __attribute__((deprecated())) // GCC
446*/
447#define PX_DEPRECATED
448
449/**
450General defines
451*/
452
453// static assert
454#if(defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7))) || (PX_PS4) || (PX_APPLE_FAMILY) || (PX_SWITCH) || (PX_CLANG && PX_ARM)
455#define PX_COMPILE_TIME_ASSERT(exp) typedef char PX_CONCAT(PxCompileTimeAssert_Dummy, __COUNTER__)[(exp) ? 1 : -1] __attribute__((unused))
456#else
457#define PX_COMPILE_TIME_ASSERT(exp) typedef char PxCompileTimeAssert_Dummy[(exp) ? 1 : -1]
458#endif
459
460#if PX_GCC_FAMILY
461#define PX_OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
462#else
463#define PX_OFFSET_OF(X, Y) offsetof(X, Y)
464#endif
465
466#define PX_OFFSETOF_BASE 0x100 // casting the null ptr takes a special-case code path, which we don't want
467#define PX_OFFSET_OF_RT(Class, Member) \
468 (reinterpret_cast<size_t>(&reinterpret_cast<Class*>(PX_OFFSETOF_BASE)->Member) - size_t(PX_OFFSETOF_BASE))
469
470// check that exactly one of NDEBUG and _DEBUG is defined
471#if !defined(NDEBUG) ^ defined(_DEBUG)
472#error Exactly one of NDEBUG and _DEBUG needs to be defined!
473#endif
474
475// make sure PX_CHECKED is defined in all _DEBUG configurations as well
476#if !PX_CHECKED && PX_DEBUG
477#error PX_CHECKED must be defined when PX_DEBUG is defined
478#endif
479
480#ifdef __CUDACC__
481#define PX_CUDA_CALLABLE __host__ __device__
482#else
483#define PX_CUDA_CALLABLE
484#endif
485
486// avoid unreferenced parameter warning
487// preferred solution: omit the parameter's name from the declaration
488template <class T>
489PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const&)
490{
491}
492
493// use in a cpp file to suppress LNK4221
494#if PX_VC
495#define PX_DUMMY_SYMBOL \
496 namespace \
497 { \
498 char PxDummySymbol; \
499 }
500#else
501#define PX_DUMMY_SYMBOL
502#endif
503
504#if PX_GCC_FAMILY
505#define PX_WEAK_SYMBOL __attribute__((weak)) // this is to support SIMD constant merging in template specialization
506#else
507#define PX_WEAK_SYMBOL
508#endif
509
510// Macro for avoiding default assignment and copy, because doing this by inheritance can increase class size on some
511// platforms.
512#define PX_NOCOPY(Class) \
513 \
514protected: \
515 Class(const Class&); \
516 Class& operator=(const Class&);
517
518#ifndef DISABLE_CUDA_PHYSX
519//CUDA is currently supported only on windows
520#define PX_SUPPORT_GPU_PHYSX ((PX_WINDOWS_FAMILY) || (PX_LINUX && PX_X64))
521#else
522#define PX_SUPPORT_GPU_PHYSX 0
523#endif
524
525#define PX_SUPPORT_COMPUTE_PHYSX 0
526
527#ifndef PX_SUPPORT_EXTERN_TEMPLATE
528#define PX_SUPPORT_EXTERN_TEMPLATE ((!PX_ANDROID) && (PX_VC != 11))
529#else
530#define PX_SUPPORT_EXTERN_TEMPLATE 0
531#endif
532
533/** @} */
534#endif // #ifndef PXFOUNDATION_PXPREPROCESSOR_H
535

source code of qtquick3dphysics/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h