fix(libc): choose the acosf NaN bits instead of the host libm #5256

Merged
adriadam10 merged 1 commit from upstream-pr/5256 into main 2026-10-13 15:46:37 +00:00
adriadam10 commented 2026-10-13 15:46:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-13T15:46:33Z.


What

guest_math has failed on every main push build since #3688: CheckAcosfErrno pins acosf(2.0f) to 0xffc00000, and acosf handed the NaN to the host std::acos. Our glibc 2.44 returns 0xffc00000, but the runner's glibc 2.39 doesn't.

This change picks the bits explicitly, following FreeBSD msun e_acosf.c, which returns (x-x)/(x-x) for |x| > 1 and for NaN inputs:

  • When |x| > 1 (including ±inf), it returns the x86 default NaN 0xffc00000.
  • A NaN input comes back as that NaN with its quiet bit set.

In-domain inputs still go to std::acos, and errno stays untouched.

Tested

The change is a 6-line rewrite of the NaN path only. Merged without waiting for CI to unblock main; the next push build on main is the check.

  • Ran the full test suite locally: no
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4845789133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5256). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-13T15:46:33Z. --- ## What `guest_math` has failed on every `main` push build since #3688: `CheckAcosfErrno` pins `acosf(2.0f)` to `0xffc00000`, and `acosf` handed the NaN to the host `std::acos`. Our glibc 2.44 returns `0xffc00000`, but the runner's glibc 2.39 doesn't. This change picks the bits explicitly, following FreeBSD msun `e_acosf.c`, which returns `(x-x)/(x-x)` for `|x| > 1` and for NaN inputs: - When `|x| > 1` (including ±inf), it returns the x86 default NaN `0xffc00000`. - A NaN input comes back as that NaN with its quiet bit set. In-domain inputs still go to `std::acos`, and errno stays untouched. ## Tested The change is a 6-line rewrite of the NaN path only. Merged without waiting for CI to unblock `main`; the next push build on `main` is the check. - [ ] Ran the full test suite locally: no
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!5256
No description provided.