fix(libc): follow msun for coshf #10001

Merged
MarcZX10 merged 2 commits from upstream-pr/10001 into main 2026-10-23 23:52:24 +00:00
MarcZX10 commented 2026-10-23 03:36:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T03:36:37Z.


What

coshf currently forwards to the Windows host library. The #9707 survey reports 500,554 and 500,614 result-bit differences from the two bundled libc.prx builds over 20 million inputs. This ports FreeBSD msun's e_coshf.c range handling and reuses the existing expf and expm1f paths used by sinhf. It covers small inputs, the finite ranges, overflow, infinities and NaNs.

The survey establishes host-versus-title differences, not the exact implementation used by every console library. This change follows the cited msun algorithm; the exact system libSceLibcInternal behavior and FMA-contracted libc.prx results remain unverified, as recorded in the debt entry.

Tested

  • Linux, GCC 12.2: compiled Math.cpp and GuestMath.cpp.
  • A focused Linux harness passed the committed boundary vectors and 1,000,000 random finite inputs, comparing with double-precision std::cosh rounded to float (within 2 ULP).
  • MinGW GCC: GuestMath.cpp compiled. A standalone Math.cpp cross-compile is blocked by existing Bessel wrappers calling j0, j1, jn, y0, y1 and yn, which MinGW does not declare.
  • The complete guest_math target was not run.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4977427590 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10001). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T03:36:37Z. --- ### What `coshf` currently forwards to the Windows host library. The #9707 survey reports 500,554 and 500,614 result-bit differences from the two bundled `libc.prx` builds over 20 million inputs. This ports FreeBSD msun's `e_coshf.c` range handling and reuses the existing `expf` and `expm1f` paths used by `sinhf`. It covers small inputs, the finite ranges, overflow, infinities and NaNs. The survey establishes host-versus-title differences, not the exact implementation used by every console library. This change follows the cited msun algorithm; the exact system `libSceLibcInternal` behavior and FMA-contracted `libc.prx` results remain unverified, as recorded in the debt entry. ### Tested - Linux, GCC 12.2: compiled `Math.cpp` and `GuestMath.cpp`. - A focused Linux harness passed the committed boundary vectors and 1,000,000 random finite inputs, comparing with double-precision `std::cosh` rounded to float (within 2 ULP). - MinGW GCC: `GuestMath.cpp` compiled. A standalone `Math.cpp` cross-compile is blocked by existing Bessel wrappers calling `j0`, `j1`, `jn`, `y0`, `y1` and `yn`, which MinGW does not declare. - The complete `guest_math` target was not run. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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 under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!10001
No description provided.