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 <noreply@anthropic.com>
This commit is contained in:
Adrià Franch 2026-10-13 17:46:18 +02:00
parent 091c136ba6
commit 0265f33636
1 changed files with 6 additions and 0 deletions

View File

@ -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<float>(std::bit_cast<std::uint32_t>(x) | 0x00400000u);
}
if (std::fabs(x) > 1.0f) {
return std::bit_cast<float>(0xffc00000u);
}
const int saved_errno = errno;
const float result = std::acos(x);
errno = saved_errno;