feat(libc): implement _LCosh and _LSinh #10742

Merged
00xDisaster merged 2 commits from upstream-pr/10742 into main 2026-10-26 13:28:15 +00:00
00xDisaster commented 2026-10-24 20:25:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by 00xDisaster on 2026-10-24T20:25:49Z.


What

Add _LCosh and _LSinh, the long-double Dinkumware helpers y * cosh(x) and y * sinh(x). The finite large-input path scales through frexp/scalbn and an ln2 split, preserving signed zero and the non-finite behavior of the existing _Cosh/_Sinh helpers. The public Dinkumware ymath.h confirms the two-argument signatures. Exact console results, range-error thresholds and floating-point exception behavior remain unverified and are recorded in the libc debt entry.

Following #10706, the canonical declarations are in core/libs/prx/libc/include/Api.hpp; this PR no longer adds local extern "C" declarations. It changes four files: Api.hpp, Math.cpp, GuestMath.cpp and the libc debt entry.

Tested

Linux CachyOS 7.3.0-2-cachyos, GCC 16.2.1. Base upstream/main 5b5d24cb22; head f4d5420b4b.

oneandonlydean merged current main after #9668 added CheckAcosfMsun; main's independent check and this PR's CheckLongDoubleHyperbolic are both preserved, and the implementation and tests are otherwise unchanged.

  • cmake --build build --target guest_math_tests guest_math_exact_tests --parallel 2: passed.
  • ctest --test-dir build -R '^guest_math(_exact)?$' --output-on-failure: 2/2 passed in 0.04 s.
  • guest_math covers known values, signs, signed zero, infinities/NaN and scaled large-finite inputs for both helpers.
  • guest_math_exact is the neighboring long-double suite and passes unchanged.
  • tools/check_conventions.py --base upstream/main --head HEAD and git diff --check: clean.
  • GPUs tested: n/a.

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: no
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4998850210 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10742). Originally posted by [00xDisaster](https://github.com/00xDisaster) on 2026-10-24T20:25:49Z. --- ### What Add `_LCosh` and `_LSinh`, the long-double Dinkumware helpers `y * cosh(x)` and `y * sinh(x)`. The finite large-input path scales through `frexp`/`scalbn` and an ln2 split, preserving signed zero and the non-finite behavior of the existing `_Cosh`/`_Sinh` helpers. The public Dinkumware `ymath.h` confirms the two-argument signatures. Exact console results, range-error thresholds and floating-point exception behavior remain unverified and are recorded in the libc debt entry. Following #10706, the canonical declarations are in `core/libs/prx/libc/include/Api.hpp`; this PR no longer adds local `extern "C"` declarations. It changes four files: `Api.hpp`, `Math.cpp`, `GuestMath.cpp` and the libc debt entry. ### Tested Linux CachyOS 7.3.0-2-cachyos, GCC 16.2.1. Base `upstream/main` `5b5d24cb22`; head `f4d5420b4b`. oneandonlydean merged current `main` after #9668 added `CheckAcosfMsun`; main's independent check and this PR's `CheckLongDoubleHyperbolic` are both preserved, and the implementation and tests are otherwise unchanged. - `cmake --build build --target guest_math_tests guest_math_exact_tests --parallel 2`: passed. - `ctest --test-dir build -R '^guest_math(_exact)?$' --output-on-failure`: 2/2 passed in 0.04 s. - `guest_math` covers known values, signs, signed zero, infinities/NaN and scaled large-finite inputs for both helpers. - `guest_math_exact` is the neighboring long-double suite and passes unchanged. - `tools/check_conventions.py --base upstream/main --head HEAD` and `git diff --check`: clean. - GPUs tested: n/a. ### 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 - [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: no
MarcZX10 commented 2026-10-24 20:34:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T20:34:03Z.

Review: APPROVED


Reviewed exact head 59d3e69221fb7dc593176205796b7709749ef38c. The scaled finite-input paths in _LCosh and _LSinh preserve the sign behavior around zero and avoid overflowing the intermediate hyperbolic value for the large finite vectors covered by the new test. I compiled the changed Math.cpp, GuestMath.cpp, and GuestLibc.cpp translation units with GCC 12.2, then linked and ran a small harness against the PR implementations for representative finite inputs, signed zero, infinities, NaN, and the reported 11357/11360 large-input vectors; all passed. This is a focused local check, not the full project build or CTest suite. The PR reports the Linux guest_math and guest_math_exact tests passing under GCC 16, and hosted Linux, Windows relinker, ASan, conventions, and policy checks pass. macOS relinker/register-context/write-watch jobs are still pending; the hosted Linux and Windows product jobs are skipped. Exact console thresholds and floating-point exception behavior remain explicitly unverified in the PR description, so this approval covers the implemented helper behavior and available evidence, not those console-specific details.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5639862353 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10742#pullrequestreview-5639862353). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T20:34:03Z. **Review:** APPROVED --- Reviewed exact head `59d3e69221fb7dc593176205796b7709749ef38c`. The scaled finite-input paths in `_LCosh` and `_LSinh` preserve the sign behavior around zero and avoid overflowing the intermediate hyperbolic value for the large finite vectors covered by the new test. I compiled the changed `Math.cpp`, `GuestMath.cpp`, and `GuestLibc.cpp` translation units with GCC 12.2, then linked and ran a small harness against the PR implementations for representative finite inputs, signed zero, infinities, NaN, and the reported 11357/11360 large-input vectors; all passed. This is a focused local check, not the full project build or CTest suite. The PR reports the Linux `guest_math` and `guest_math_exact` tests passing under GCC 16, and hosted Linux, Windows relinker, ASan, conventions, and policy checks pass. macOS relinker/register-context/write-watch jobs are still pending; the hosted Linux and Windows product jobs are skipped. Exact console thresholds and floating-point exception behavior remain explicitly unverified in the PR description, so this approval covers the implemented helper behavior and available evidence, not those console-specific details.
MarcZX10 commented 2026-10-24 22:58:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T22:58:05Z.

Review: APPROVED


Reviewed exact rebased head 11ef50d50285c7b7d32946bc5739ea899d9a7286 against current main f26434afa36e58778a9ff4b948aea52dff19eb0c. The rebase moves the two declarations into libc's canonical Api.hpp; the implementation, boundary vectors, and debt statement remain focused and consistent. I compiled the exact Math.cpp translation unit with GCC 12.2 under -Wall -Wextra -Werror, then linked and ran a focused harness against that object for ordinary signed values, infinities, signed zero, and the large scaled inputs; it passed. git diff --check passed. The refreshed hosted relinker matrix, ASan, conventions, eligibility, labels, and other applicable checks pass. Hosted Linux and Windows product jobs are skipped by path policy; the author reports guest_math and guest_math_exact passing 2/2 after the rebase. The console-specific thresholds and floating-point exception behavior remain explicitly unverified as recorded in the PR. I found no blocker in the current diff.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5640456195 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10742#pullrequestreview-5640456195). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T22:58:05Z. **Review:** APPROVED --- Reviewed exact rebased head `11ef50d50285c7b7d32946bc5739ea899d9a7286` against current `main` `f26434afa36e58778a9ff4b948aea52dff19eb0c`. The rebase moves the two declarations into libc's canonical `Api.hpp`; the implementation, boundary vectors, and debt statement remain focused and consistent. I compiled the exact `Math.cpp` translation unit with GCC 12.2 under `-Wall -Wextra -Werror`, then linked and ran a focused harness against that object for ordinary signed values, infinities, signed zero, and the large scaled inputs; it passed. `git diff --check` passed. The refreshed hosted relinker matrix, ASan, conventions, eligibility, labels, and other applicable checks pass. Hosted Linux and Windows product jobs are skipped by path policy; the author reports `guest_math` and `guest_math_exact` passing 2/2 after the rebase. The console-specific thresholds and floating-point exception behavior remain explicitly unverified as recorded in the PR. I found no blocker in the current diff.
MarcZX10 commented 2026-10-25 04:22:24 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T04:22:24Z.

Review: APPROVED


Re-reviewed exact head e0547ee7c53024d41d75217e0f61380174c8a4cc. Compared with the previous reviewed head, the implementation and tests are unchanged; the rebase only reconciles the libc debt entry with the new _FSinh/_FCosh evidence on main. I compiled the exact Math.cpp and ran a focused host harness covering normal values, signs, signed zero, NaN/infinity, large finite scaling, and overflow for both functions; it passed. The hosted conventions, eligibility, labels, Linux/Windows/macOS relinker matrix, ASan, register-context and write-watch checks pass. Product Linux/Windows test jobs are skipped by workflow policy. Console-specific results and exception behavior remain explicitly documented as unverified.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5641476040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10742#pullrequestreview-5641476040). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T04:22:24Z. **Review:** APPROVED --- Re-reviewed exact head `e0547ee7c53024d41d75217e0f61380174c8a4cc`. Compared with the previous reviewed head, the implementation and tests are unchanged; the rebase only reconciles the libc debt entry with the new `_FSinh`/`_FCosh` evidence on main. I compiled the exact `Math.cpp` and ran a focused host harness covering normal values, signs, signed zero, NaN/infinity, large finite scaling, and overflow for both functions; it passed. The hosted conventions, eligibility, labels, Linux/Windows/macOS relinker matrix, ASan, register-context and write-watch checks pass. Product Linux/Windows test jobs are skipped by workflow policy. Console-specific results and exception behavior remain explicitly documented as unverified.
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!10742
No description provided.