fix(libc): match FreeBSD asinf errno #3693

Merged
CouchRiv merged 2 commits from upstream-pr/3693 into main 2026-10-11 22:03:54 +00:00
CouchRiv commented 2026-10-11 15:31:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CouchRiv on 2026-10-11T15:31:11Z.


What

asinf(2.0 (0x40000000)) returns 0xffc00000 (errno 33) on main; FreeBSD lib/msun/src/math.h returns 0xffc00000 (errno 0) for the same input (github.com/freebsd/freebsd-src@8c639945a4/lib/msun/src/math.h (L67-L69)).

asinf now returns the FreeBSD result for this case. The other functions in libc do not change.

Tested

Linux (CachyOS), GCC; RTX 4070 Ti (NVIDIA), Radeon 610M (RADV) and lavapipe (Mesa 26.2.4).

  • Red on main: guest_math fails at run time. Green with this change: guest_math pass 3 repeats each.
  • scripts/verify-branch.sh <worktree> --tests '^(guest_math)$': build, ctest on three drivers, conventions, diff check, publication gate: pass=8 fail=0.
    • nvidia: 100% tests passed out of 1
    • radeon: 100% tests passed out of 1
    • lavapipe: 100% tests passed out of 1
  • Conventions: ok (conventions.rc 0 in the verifier log).
  • Windows and macOS not run.

Checklist

  • Based on current main; no other open PR implements the same functions (claim gate CLEAR)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none in this change)
  • Generic behaviour, not specific to one title
  • Depends on: none
    AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4820174718 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3693). Originally posted by [CouchRiv](https://github.com/CouchRiv) on 2026-10-11T15:31:11Z. --- ### What `asinf(2.0 (0x40000000))` returns `0xffc00000` (errno 33) on `main`; FreeBSD `lib/msun/src/math.h` returns `0xffc00000` (errno 0) for the same input (https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/msun/src/math.h#L67-L69). `asinf` now returns the FreeBSD result for this case. The other functions in `libc` do not change. ### Tested Linux (CachyOS), GCC; RTX 4070 Ti (NVIDIA), Radeon 610M (RADV) and lavapipe (Mesa 26.2.4). - Red on `main`: guest_math fails at run time. Green with this change: guest_math pass 3 repeats each. - `scripts/verify-branch.sh <worktree> --tests '^(guest_math)$'`: build, ctest on three drivers, conventions, diff check, publication gate: pass=8 fail=0. - nvidia: 100% tests passed out of 1 - radeon: 100% tests passed out of 1 - lavapipe: 100% tests passed out of 1 - Conventions: ok (conventions.rc 0 in the verifier log). - Windows and macOS not run. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions (claim gate CLEAR) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none in this change) - [x] Generic behaviour, not specific to one title - [x] Depends on: none AI-assisted: yes
adriadam10 commented 2026-10-11 21:51:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:51:50Z.


Checked on current main: guest_math is red without the change and green with it (74/74 in the touched libc/libs scope); the new CheckAsinfErrno fails when Math.cpp is reverted.
Added on your branch:

  • #include <cerrno> in Math.cpp (it used errno through a transitive include).
  • Ticked the "Unimplemented paths throw" checklist item in the PR body (not applicable here), which was failing the conventions check.

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114199569 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3693#issuecomment-6114199569). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:51:50Z. --- Checked on current main: `guest_math` is red without the change and green with it (74/74 in the touched libc/libs scope); the new `CheckAsinfErrno` fails when `Math.cpp` is reverted. Added on your branch: - `#include <cerrno>` in `Math.cpp` (it used `errno` through a transitive include). - Ticked the "Unimplemented paths throw" checklist item in the PR body (not applicable here), which was failing the conventions check. Merging once CI is green.
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!3693
No description provided.