From 3901d7a5cb7a9d90f188f3632fd5e2f6a7614b40 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 7 Aug 2023 23:43:38 -0700
Subject: [PATCH 2/3] Do not use feenableexcept/fedisableexcept on musl

musl does not provice feenableexcept and fedisableexcept. Those calls have
only been used on linux so far. This patch extends the #ifdef logic to only use
them on Linux if additionally glibc is used.

Fixes
src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp:65:2: error: use of undeclared identifier 'fedisableexcept'; did you mean 'feraiseexcept'?
   65 |         fedisableexcept(FE_ALL_EXCEPT);
      |         ^~~~~~~~~~~~~~~
      |         feraiseexcept

Change-Id: I035acb62e91e3719a966f223e1a398531cd00ad1
---
 src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp b/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp
index f245f7a..2d56766 100644
--- a/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp
+++ b/src/3rdparty/PhysX/source/foundation/src/unix/PsUnixFPU.cpp
@@ -59,7 +59,7 @@ physx::shdfnd::FPUGuard::FPUGuard()
 	fegetenv(reinterpret_cast<fenv_t*>(mControlWords));
 	fesetenv(FE_DFL_ENV);
 
-#if PX_LINUX
+#if PX_LINUX && __GLIBC__
 	// need to explicitly disable exceptions because fesetenv does not modify
 	// the sse control word on 32bit linux (64bit is fine, but do it here just be sure)
 	fedisableexcept(FE_ALL_EXCEPT);
@@ -89,7 +89,7 @@ physx::shdfnd::FPUGuard::~FPUGuard()
 
 PX_FOUNDATION_API void physx::shdfnd::enableFPExceptions()
 {
-#if PX_LINUX && !defined(__EMSCRIPTEN__)
+#if (PX_LINUX && __GLIBC__) && !defined(__EMSCRIPTEN__)
 	feclearexcept(FE_ALL_EXCEPT);
 	feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
 #elif PX_OSX && !defined(PX_ARM_FAMILY)
@@ -106,7 +106,7 @@ PX_FOUNDATION_API void physx::shdfnd::enableFPExceptions()
 
 PX_FOUNDATION_API void physx::shdfnd::disableFPExceptions()
 {
-#if PX_LINUX && !defined(__EMSCRIPTEN__)
+#if (PX_LINUX && __GLIBC__) && !defined(__EMSCRIPTEN__)
 	fedisableexcept(FE_ALL_EXCEPT);
 #elif PX_OSX && !defined(PX_ARM_FAMILY)
 	// clear any pending exceptions
-- 
2.41.0

