fix(libc): follow msun for log1pf #10007
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10007"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T03:52:47Z.
What
Implement FreeBSD msun's
log1pffor finite inputs above -1 with its own port ofs_log1pf.c, including its negative-input branches; invalid-domain and non-finite inputs retain the host fallback. Update the libc debt entry to record the implementation and remaining console-specific uncertainty.Issue #9707 reports roughly 1.4 million result-bit differences against a Windows host implementation across 20 million samples. This is evidence of host-vs-title variation, not direct verification against
libSceLibcInternal.Tested
Linux, GCC 12.2: built and ran
guest_math_testssuccessfully, including signed zero, tiny inputs, representative positive/negative values, values near -1, and domain/special values.python3 tools/check_conventions.py --base origin/main,git diff --check, andpython3 tools/pr_overlap.py --branch codex/libc-log1pf-msunpassed. No PS5 title or homebrew was used; exact console behavior and title-build FMA behavior remain unverified.Current head
780fa4b76a: compared with the pinneds_log1pf.c(compiled in a harness with-ffp-contract=off) over every finitefloatfrom -1 (exclusive) to infinity, the port has no differing result bit; the previous mapping-log1p(-x/(1+x))differed on about 82 million inputs in the same harness, the first at0xb3000001.guest_mathpasses on this head, including a new table of bit-exact cases at the small-negative, range-reduction and large-input boundaries whose expected bits come from the pinned source. This host fails the startup CPU-feature gate, soguest_mathwas run in a throwaway build copy with that check disabled. Windows was not run.Checklist
main; no other open PR implements the same functionImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T08:00:54Z.
Review: COMMENTED
macOS build failure on head
89b9820fee:guest_math_testsdoes not compile with Apple clang / libc++.GuestMath.cppdoes not include<algorithm>; libstdc++ pulls it in transitively through the other headers, libc++ does not. This is the firststd::maxin the file, somainis not affected. Adding#include <algorithm>fixes it.Setup: Apple M2 Max, macOS 27.2, Apple clang 21.0.0 (Xcode 27), x86_64 under Rosetta, Release. Base is #8658 @
37a9a6b4be(main plus the macOS port;mainalone does not build the guest libs on macOS), with this PR's diff applied.With the include added:
guest_mathpasses 3/3.main'sMath.cppand the new test,guest_mathalso passes on this host. macOS's libmlog1pfstays within themax(1e-45, |expected| * 2e-7)bound for these cases, so here the test does not tell the msun path from the host fallback. Comparing exact result bits, as #10001 does forcoshf, would catch a host that differs from msun on these inputs.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-02T04:57:11Z.
Review: COMMENTED
Reviewed — docs contradiction confirmed, requested sentence matches the code
The
atanhfentry still says the exportedlog1pfis the host's, which contradicts thelog1pfentry and the code at head780fa4b76a.What I ran
Head
780fa4b76a6fb769a20ba2cf6ccc7859e00baef1(live, OPEN). Read-only:gh pr view,gh apiGET on comments and reviews,git show <head>:docs/dev/debt/libc.mdandgit show <head>:core/libs/prx/libc/src/Math.cpp,git grepat the head. Nothing was built or run.Results
libc.mdcontradictionlog1pfdispatchMath.cpp:681-682Findings
atanhfentry) to stop saying the exportedlog1pfis still the host's, since line 133 says it follows msun. Confirmed: line 132 contains "the exportedlog1pfis still the host's". The code atMath.cpp:681-682sends non-finite inputs andx <= -1tostd::log1p, and everything else toLog1pfMsun. The requested sentence matches that.libc.prx: value matches, with someerrnoand NaN-bit differences and an FMA-build difference. Those comments ask for no change. Their two comments give differenterrnocounts (304 and 102). The msun branch-order claims were not checked against the pinned source here.Sources
github.com/boykopovar/AnyPS5@780fa4b76a/docs/dev/debt/libc.md (L132-L133)github.com/boykopovar/AnyPS5@780fa4b76a/core/libs/prx/libc/src/Math.cpp (L680-L682)Not verified
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:25:10Z.
Review: COMMENTED
Built the focused checks against the existing Linux runtime.
GuestMathpassed.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.