Skip to content

fix(libc): follow msun for acoshf - #10003

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/libc-acoshf-msun
Oct 24, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
MarcZX10:codex/libc-acoshf-msun

Conversation

@MarcZX10

Copy link
Copy Markdown
Contributor

What

acoshf currently forwards to the Windows host library. The #9707 survey reports 216,017 and 216,024 result-bit differences from the two bundled libc.prx builds over 20 million inputs. This ports FreeBSD msun's e_acoshf.c range handling and reuses the existing log1pf path for inputs near 1. The invalid-domain path raises FE_INVALID without setting errno, as the source does.

The survey establishes host-versus-title differences, not the exact implementation used by every console library. 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 boundary and special-value cases, including invalid-domain FE_INVALID and unchanged errno; 1,000,000 random finite inputs stayed within 2 ULP of double-precision std::acosh rounded to float.
  • MinGW GCC: GuestMath.cpp compiled.
  • The complete guest_math target was not run.
  • check_conventions.py, pr_overlap.py and git diff --check passed.

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

@github-actions

github-actions Bot commented Oct 23, 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 10315 core/libs/prx/libc/src/Math.cpp L908-909
PR 10565 core/libs/prx/libc/src/Math.cpp L908-909

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 6044 core/libs/tests/GuestMath.cpp
PR 7201 core/libs/prx/libc/src/Math.cpp
PR 7544 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 7715 docs/dev/debt/libc.md
PR 8150 docs/dev/debt/libc.md
PR 8417 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 9360 docs/dev/debt/libc.md
PR 9408 docs/dev/debt/libc.md
PR 9447 docs/dev/debt/libc.md
PR 9526 docs/dev/debt/libc.md
PR 9527 docs/dev/debt/libc.md
PR 9552 docs/dev/debt/libc.md
PR 9669 docs/dev/debt/libc.md
PR 9863 docs/dev/debt/libc.md
PR 9873 core/libs/prx/libc/src/Math.cpp
core/libs/tests/GuestMath.cpp
docs/dev/debt/libc.md
PR 9929 docs/dev/debt/libc.md

@MarcZX10

Copy link
Copy Markdown
Contributor Author

Review pass on the exact current head: the function follows the cited FreeBSD msun range handling, special values and boundary cases are covered in GuestMath, and the remaining console/FMA uncertainty is recorded in technical debt. The focused Linux numerical checks and MinGW compilation reported in the PR are useful evidence; the full target was not reported as run for these three PRs. I checked whitespace, conventions and current-main merge status locally; all pass cleanly except #10007 has an inherited debt-length warning and 0 errors. I could not rerun guest_math locally because CMake configuration is blocked by the missing SDL2 development package. Hosted intake/conventions/relinker matrices pass; full Linux/Windows jobs are skipped under repository policy.

@JJenkx

JJenkx commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Overlap note under the repository's overlap rule: git merge-tree of this head against #9844 and #9873 (core/libs/tests/GuestMath.cpp) reports content conflicts. They are separate functions added at the same place. Those PRs are older (10-22) and already reviewed, so I propose they land first and this one is rebased after them, keeping both sides; #10113 (expf) is already stacked to land after #10007. If you'd rather land this one first, say so and I'll restack mine and add Depends on instead.

@oneandonlydean oneandonlydean self-assigned this Oct 23, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 24, 2026
@oneandonlydean
oneandonlydean merged commit 9018bc4 into boykopovar:main Oct 24, 2026
17 checks passed
@harisibrar1 harisibrar1 mentioned this pull request Oct 24, 2026
12 tasks done
@JJenkx

JJenkx commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

I measured a follow-up domain-error gap in both supplied bundled copies (FAR PPSA03766 and Tetris PPSA07923). They agree on all12,960 sampled observations; the current acoshf path leaves errno untouched and misses x87 invalid, with negative quiet NaNs also missing SSE invalid. #10610 calls the existing helper and sets EDOM in the existing domain branch, retaining all numerical range handling. The same-test main control fails the named regression, candidate math/exact/Dinkumware3/3 passes, and errno/SSE/x87 fields match both supplied copies after the fix. No result bits change.36 preexisting finite directed-rounding bit differences at0x40000002/0x40000003 remain documented, with no claim this fixes those. Exact hashes, matrices, logs and limitations are attached to #10610. No SDK binaries or code bytes are posted.

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.

3 participants