Skip to content

feat(libc): implement _LCosh and _LSinh - #10742

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
00xDisaster:feat/libc-lcosh
Oct 26, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
00xDisaster:feat/libc-lcosh

Conversation

@00xDisaster

@00xDisaster 00xDisaster commented Oct 24, 2026 •

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Progress report (3d2b7c0 → f4d5420)

📈 System libraries: 50.57% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libc _LCosh_nid_postfix
libc _LSinh_nid_postfix

Changed libraries (implemented exports)

Library Before After Change
libc 1371/1382 (99.20%) 1373/1384 (99.21%) +0.00 pp

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 10345 docs/dev/debt/libc.md L77
PR 11139 docs/dev/debt/libc.md L77

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libc.md
PR 5303 docs/dev/debt/libc.md
PR 6295 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
PR 6713 docs/dev/debt/libc.md
PR 7081 docs/dev/debt/libc.md
PR 7201 core/libs/prx/libc/src/Math.cpp
PR 7386 docs/dev/debt/libc.md
PR 7447 docs/dev/debt/libc.md
PR 7544 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 7648 docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 7851 core/libs/prx/libc/include/Api.hpp
PR 8150 docs/dev/debt/libc.md
PR 9371 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9772 core/libs/prx/libc/include/Api.hpp
docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md
PR 10002 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 10007 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 10405 docs/dev/debt/libc.md
PR 10467 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md

@00xDisaster

Copy link
Copy Markdown
Author

@adriadam10 all checks are green and this PR is CLEAN at 59d3e69221fb7dc593176205796b7709749ef38c. @MarcZX10 approved this exact head. Could you merge it when convenient? No further changes are needed.

@00xDisaster

Copy link
Copy Markdown
Author

Rebased onto current main after #10706 (f26434afa3). #10706 removed the local extern "C" blocks, so _LCosh/_LSinh now live in Api.hpp; the new head is 11ef50d502 (4 files, +86/-0). guest_math + guest_math_exact pass 2/2, conventions and git diff --check are clean, and the PR is MERGEABLE with checks running. @MarcZX10 the earlier approval was on 59d3e692; could you review this head when the checks finish? No further changes are planned.

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@00xDisaster

Copy link
Copy Markdown
Author

@boykopovar #10742 is approved at 11ef50d502, all checks pass, and it is MERGEABLE/CLEAN against current main f26434afa3. Could you merge it when convenient? It is my only open PR; the next libc change is ready to follow one at a time.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
Add the long-double siblings of _Cosh and _Sinh with the same scaled finite-input path, signed-zero handling and Dinkumware two-argument contracts. The reductions use a long-double ln2 split, and the scaled-range tests pin 64-bit results instead of the intermediate writer's output. Cover known values, signs and non-finite inputs in guest_math; record the unverified console results and exception behavior in the libc debt list.
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@00xDisaster

Copy link
Copy Markdown
Author

@MarcZX10 I rebased this onto current main bd8e13428a after #10129 landed. #10129 added a measured _FSinh/_FCosh entry at the same place in the libc debt file; that entry was the only conflict. I preserved both it and this PR’s _LCosh/_LSinh entry, and no code changed. guest_math and guest_math_exact pass 2/2, and conventions plus git diff --check are clean at head e0547ee7c5. The earlier approval was at 11ef50d502; could you re-approve this head?

@oneandonlydean oneandonlydean self-assigned this Oct 25, 2026

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@babyhuey

Copy link
Copy Markdown
Contributor

Windows run of this head e0547ee7c53, merged onto main a7a2eece499 (clean merge, local only), with the selection CI's skipped Windows product job uses: Windows 11, Ryzen 7 5800X, RTX 3080, WinLibs GCC 15.2, Release, BUILD_TESTING=ON. The tree was configured fresh after the merge, then select_tests.py select / ninja -f select.ninja selected / --target libs / select_tests.py ctest --parallel 4 --timeout 120.

AI-assisted: yes (Claude Code)

@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 25, 2026
@oneandonlydean

Copy link
Copy Markdown
Collaborator

@00xDisaster this conflicted with main in GuestMath.cpp, so I merged main into the branch (f4d5420). Main's CheckAcosfMsun and your CheckLongDoubleHyperbolic are independent and both kept; your code is unchanged. Next is CI on this head.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 26, 2026
@00xDisaster

Copy link
Copy Markdown
Author

@MarcZX10 oneandonlydean merged current main into the branch at f4d5420b4b after #9668 added CheckAcosfMsun. The merge kept both independent tests; the _LCosh/_LSinh implementation and its tests are otherwise unchanged.

I reran guest_math and guest_math_exact at this head: 2/2 pass. tools/check_conventions.py --base upstream/main --head HEAD and git diff --check upstream/main...HEAD are clean, and all current checks pass. Could you re-approve this documentation-and-test-merge head?

@oneandonlydean
oneandonlydean merged commit bf77a9e into boykopovar:main Oct 26, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants