From 0265f33636899388a5a88f47b58098e1f01c9269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Tue, 13 Oct 2026 17:46:18 +0200 Subject: [PATCH] fix(libc): choose the acosf NaN bits instead of the host libm FreeBSD msun e_acosf.c returns (x-x)/(x-x) for |x| > 1 and NaN inputs: the x86 default NaN 0xffc00000, or the quieted input NaN. std::acos left it to the host libm, and guest_math failed on the runner's glibc 2.39. Co-Authored-By: Claude --- core/libs/prx/libc/src/Math.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/libs/prx/libc/src/Math.cpp b/core/libs/prx/libc/src/Math.cpp index ee7322cf1..1a835e2fe 100644 --- a/core/libs/prx/libc/src/Math.cpp +++ b/core/libs/prx/libc/src/Math.cpp @@ -183,6 +183,12 @@ float APS5_VABI asinf_nid_postfix(float x) { return result; } float APS5_VABI acosf_nid_postfix(float x) { + if (std::isnan(x)) { + return std::bit_cast(std::bit_cast(x) | 0x00400000u); + } + if (std::fabs(x) > 1.0f) { + return std::bit_cast(0xffc00000u); + } const int saved_errno = errno; const float result = std::acos(x); errno = saved_errno;