From 84ff93429db5b9a6ce04e56f298c55a464b477d2 Mon Sep 17 00:00:00 2001 From: Gerasim Troeglazov <3dEyes@gmail.com> Date: Wed, 4 Sep 2024 22:58:42 +1000 Subject: Add Haiku support diff --git a/src/3rdparty/PhysX/CMakeLists.txt b/src/3rdparty/PhysX/CMakeLists.txt index 1fb4923..5c1a6ab 100644 --- a/src/3rdparty/PhysX/CMakeLists.txt +++ b/src/3rdparty/PhysX/CMakeLists.txt @@ -1341,7 +1341,7 @@ if (WIN32) endif() ## MSYS -if (MSYS OR MINGW) +if (MSYS OR MINGW OR HAIKU) qt_internal_extend_target(BundledPhysX DEFINES PX_SIMD_DISABLED PX_GCC_FAMILY) endif() diff --git a/src/3rdparty/PhysX/pxshared/include/foundation/PxIntrinsics.h b/src/3rdparty/PhysX/pxshared/include/foundation/PxIntrinsics.h index 4b75756..9054315 100644 --- a/src/3rdparty/PhysX/pxshared/include/foundation/PxIntrinsics.h +++ b/src/3rdparty/PhysX/pxshared/include/foundation/PxIntrinsics.h @@ -34,7 +34,7 @@ #if PX_WINDOWS_FAMILY #include "foundation/windows/PxWindowsIntrinsics.h" -#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4) +#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4 || PX_HAIKU) #include "foundation/unix/PxUnixIntrinsics.h" #elif PX_XBOXONE #include "foundation/XboxOne/PxXboxOneIntrinsics.h" diff --git a/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h b/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h index 105e96f..6a8a7e6 100644 --- a/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h +++ b/src/3rdparty/PhysX/pxshared/include/foundation/PxPreprocessor.h @@ -101,6 +101,8 @@ Operating system defines, see http://sourceforge.net/p/predef/wiki/OperatingSyst #define PX_IOS 1 #elif defined(__APPLE__) #define PX_OSX 1 +#elif defined(__HAIKU__) +#define PX_HAIKU 1 #elif defined(__ORBIS__) #define PX_PS4 1 #elif defined(__NX__) @@ -191,6 +193,9 @@ define anything not defined on this platform to 0 #ifndef PX_OSX #define PX_OSX 0 #endif +#ifndef PX_HAIKU +#define PX_HAIKU 0 +#endif #ifndef PX_PS4 #define PX_PS4 0 #endif @@ -266,7 +271,7 @@ family shortcuts #define PX_MICROSOFT_FAMILY (PX_XBOXONE || PX_WINDOWS_FAMILY || PX_XBOX_SERIES_X) #define PX_LINUX_FAMILY (PX_LINUX || PX_ANDROID) #define PX_APPLE_FAMILY (PX_IOS || PX_OSX) // equivalent to #if __APPLE__ -#define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY) // shortcut for unix/posix platforms +#define PX_UNIX_FAMILY (PX_LINUX_FAMILY || PX_APPLE_FAMILY || PX_HAIKU) // shortcut for unix/posix platforms #if defined(__EMSCRIPTEN__) #define PX_EMSCRIPTEN 1 #else @@ -304,7 +309,7 @@ Assert macro DLL export macros */ #ifndef PX_C_EXPORT -#if PX_WINDOWS_FAMILY || PX_LINUX +#if PX_WINDOWS_FAMILY || PX_LINUX || PX_HAIKU #define PX_C_EXPORT extern "C" #else #define PX_C_EXPORT diff --git a/src/3rdparty/PhysX/pxshared/include/foundation/unix/PxUnixIntrinsics.h b/src/3rdparty/PhysX/pxshared/include/foundation/unix/PxUnixIntrinsics.h index 175f7fd..3620cac 100644 --- a/src/3rdparty/PhysX/pxshared/include/foundation/unix/PxUnixIntrinsics.h +++ b/src/3rdparty/PhysX/pxshared/include/foundation/unix/PxUnixIntrinsics.h @@ -33,7 +33,7 @@ #include "foundation/Px.h" #include "foundation/PxSharedAssert.h" -#if !(PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY) +#if !(PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY || PX_HAIKU) #error "This file should only be included by Unix builds!!" #endif diff --git a/src/3rdparty/PhysX/source/foundation/include/PsAllocator.h b/src/3rdparty/PhysX/source/foundation/include/PsAllocator.h index a1480b2..7f04f00 100644 --- a/src/3rdparty/PhysX/source/foundation/include/PsAllocator.h +++ b/src/3rdparty/PhysX/source/foundation/include/PsAllocator.h @@ -118,6 +118,9 @@ #elif PX_SWITCH #include #define PxAlloca(x) alloca(x) +#elif PX_HAIKU + #include + #define PxAlloca(x) alloca(x) #endif #define PxAllocaAligned(x, alignment) ((size_t(PxAlloca(x + alignment)) + (alignment - 1)) & ~size_t(alignment - 1)) diff --git a/src/3rdparty/PhysX/source/foundation/include/PsIntrinsics.h b/src/3rdparty/PhysX/source/foundation/include/PsIntrinsics.h index f08af7f..8d72734 100644 --- a/src/3rdparty/PhysX/source/foundation/include/PsIntrinsics.h +++ b/src/3rdparty/PhysX/source/foundation/include/PsIntrinsics.h @@ -34,7 +34,7 @@ #if PX_WINDOWS_FAMILY #include "windows/PsWindowsIntrinsics.h" -#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4) +#elif(PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4 || PX_HAIKU) #include "unix/PsUnixIntrinsics.h" #elif PX_XBOXONE #include "XboxOne/PsXboxOneIntrinsics.h" diff --git a/src/3rdparty/PhysX/source/foundation/include/PsThread.h b/src/3rdparty/PhysX/source/foundation/include/PsThread.h index d0ec8d9..d88c0d4 100644 --- a/src/3rdparty/PhysX/source/foundation/include/PsThread.h +++ b/src/3rdparty/PhysX/source/foundation/include/PsThread.h @@ -41,7 +41,7 @@ #if PX_WINDOWS_FAMILY || PX_XBOXONE || PX_XBOX_SERIES_X #define PxSpinLockPause() __asm pause -#elif PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY || PX_SWITCH +#elif PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY || PX_SWITCH || PX_HAIKU #define PxSpinLockPause() asm("nop") #else #error "Platform not supported!" diff --git a/src/3rdparty/PhysX/source/foundation/include/PsTime.h b/src/3rdparty/PhysX/source/foundation/include/PsTime.h index 4d5eedb..38f23a7 100644 --- a/src/3rdparty/PhysX/source/foundation/include/PsTime.h +++ b/src/3rdparty/PhysX/source/foundation/include/PsTime.h @@ -84,7 +84,7 @@ class PX_FOUNDATION_API Time Second getLastTime() const; private: -#if PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4 +#if PX_LINUX || PX_ANDROID || PX_APPLE_FAMILY || PX_PS4 || PX_HAIKU Second mLastTime; #else int64_t mTickCount; diff --git a/src/3rdparty/PhysX/source/foundation/include/unix/PsUnixIntrinsics.h b/src/3rdparty/PhysX/source/foundation/include/unix/PsUnixIntrinsics.h index e6165e8..57fdb2d 100644 --- a/src/3rdparty/PhysX/source/foundation/include/unix/PsUnixIntrinsics.h +++ b/src/3rdparty/PhysX/source/foundation/include/unix/PsUnixIntrinsics.h @@ -45,7 +45,7 @@ // this file is for internal intrinsics - that is, intrinsics that are used in // cross platform code but do not appear in the API -#if !(PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY) +#if !(PX_LINUX || PX_ANDROID || PX_PS4 || PX_APPLE_FAMILY || PX_HAIKU) #error "This file should only be included by unix builds!!" #endif diff --git a/src/3rdparty/PhysX/source/foundation/include/unix/sse2/PsUnixSse2AoS.h b/src/3rdparty/PhysX/source/foundation/include/unix/sse2/PsUnixSse2AoS.h index 9a4fbb8..f6cf9d6 100644 --- a/src/3rdparty/PhysX/source/foundation/include/unix/sse2/PsUnixSse2AoS.h +++ b/src/3rdparty/PhysX/source/foundation/include/unix/sse2/PsUnixSse2AoS.h @@ -43,7 +43,11 @@ namespace shdfnd namespace aos { -#if PX_EMSCRIPTEN || PX_SSE2 +#if PX_HAIKU +#include +#endif + +#if PX_EMSCRIPTEN || PX_SSE2 || PX_HAIKU typedef int8_t __int8_t; typedef int16_t __int16_t; typedef int32_t __int32_t; diff --git a/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixThread.cpp b/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixThread.cpp index 0fb6851..159e36a 100644 --- a/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixThread.cpp +++ b/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixThread.cpp @@ -36,13 +36,13 @@ #include "PsThread.h" #include -#if !PX_APPLE_FAMILY && !defined(ANDROID) && !defined(__CYGWIN__) && !PX_PS4 && !PX_EMSCRIPTEN && __GLIBC__ +#if !PX_APPLE_FAMILY && !defined(ANDROID) && !defined(__CYGWIN__) && !PX_PS4 && !PX_EMSCRIPTEN && !PX_HAIKU && __GLIBC__ #include // PTHREAD_STACK_MIN #endif #include #include #include -#if !PX_PS4 +#if !PX_PS4 && !PX_HAIKU #include #if !PX_APPLE_FAMILY && !PX_EMSCRIPTEN #include @@ -57,6 +57,10 @@ #include #endif +#if PX_HAIKU +#include +#endif + // fwd #if defined(ANDROID) extern "C" { @@ -114,6 +118,8 @@ static void setTid(_ThreadImpl& threadImpl) // AM: TODO: neither of the below are implemented #elif PX_APPLE_FAMILY threadImpl.tid = syscall(SYS_gettid); +#elif PX_HAIKU + threadImpl.tid = find_thread(NULL); #elif PX_EMSCRIPTEN // No thread id for emscripten #else @@ -324,7 +330,7 @@ uint32_t ThreadImpl::setAffinityMask(uint32_t mask) { #if PX_PS4 prevMask = setAffinityMaskPS4(getThread(this)->thread, mask); -#elif PX_EMSCRIPTEN +#elif PX_EMSCRIPTEN || PX_HAIKU // not supported #elif !PX_APPLE_FAMILY // Apple doesn't support syscall with getaffinity and setaffinity int32_t errGet = syscall(__NR_sched_getaffinity, getThread(this)->tid, sizeof(prevMask), &prevMask); @@ -433,6 +439,10 @@ uint32_t ThreadImpl::getNbPhysicalCores() int count; size_t size = sizeof(count); return sysctlbyname("hw.physicalcpu", &count, &size, NULL, 0) ? 0 : count; +#elif PX_HAIKU + system_info info; + status_t result = get_system_info(&info); + return (result != B_OK) ? 0 : info.cpu_count; #elif defined(ANDROID) return android_getCpuCount(); #else diff --git a/src/3rdparty/PhysX/source/pvd/include/PxProfileAllocatorWrapper.h b/src/3rdparty/PhysX/source/pvd/include/PxProfileAllocatorWrapper.h index 46034b0..58b4059 100644 --- a/src/3rdparty/PhysX/source/pvd/include/PxProfileAllocatorWrapper.h +++ b/src/3rdparty/PhysX/source/pvd/include/PxProfileAllocatorWrapper.h @@ -74,7 +74,7 @@ namespace physx { namespace profile { { static const char* getName() { -#if PX_LINUX || PX_ANDROID || PX_PS4 || PX_IOS || PX_OSX || PX_EMSCRIPTEN || PX_SWITCH +#if PX_LINUX || PX_ANDROID || PX_PS4 || PX_IOS || PX_OSX || PX_EMSCRIPTEN || PX_SWITCH || PX_HAIKU return __PRETTY_FUNCTION__; #else return typeid(T).name(); -- 2.52.0