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

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