fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9771"
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 JJenkx on 2026-10-22T14:05:37Z.
What
asinfreturned the host'sasin, so its last bit depended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 5,413,834 of the floats in (-1, 1). Examples, console thenmain:0x3b3a82da→0x3b3a82ea,maingives0x3b3a82eb;0x3f0008fb→0x3f0614f1,maingives0x3f0614f0.The titles'
asinf(NIDGZWjF-YIFFk) is FreeBSD msun'se_asinf.c.asinfnow computes it the same way:pS0..pS2/qS1(AsinfRational);0.5 <= |x| < 1,sqrtand the final step in double, as msun has them.The build targets baseline x86-64, so nothing is contracted into FMA.
errno: for|x| > 1, the infinities and NaN this storesEDOMbefore returning(x - x) / (x - x), as thelibc.prxbundled with eleven titles does, PPSA13934's included. That reverses #3693'serrno == 0expectation inCheckAsinfErrno, which now checksEDOMfor ±2, ±infand a NaN, and an untouchederrnofor ±1, 0.5 and 0 (cc @CouchRiv). Tiny arguments returnxwithout raisingFE_INEXACT.asinfis imported by 21 of the 22 titles whose relinker registries I audited, for example PPSA01528, PPSA02630, PPSA04158 and PPSA09614. This is theasinfcounterpart of #9668 (acosf).Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main8b3e39832a.libc.prxof PPSA07923 and PPSA05916 natively and supplies__error. Theirasinfand this build'sasinf_nid_postfixgive the same bits for all 2^32 arguments, NaN payloads included. This build storesEDOMexactly where they do: for those eleven titles,asinfstoresEDOMfor ±2,infand a quiet NaN and leaveserrnoalone for 1 and 0.5, and the-O3libc.prxDLL of this branch matches PPSA07923'sasinfbits anderrnoon 400,012 sampled inputs.acosfin #9668).guest_math: the newCheckAsinfConsoleBitshas 13 cases with the console's outputs: both ranges, ±1, the last float below 1, tiny, -0, the smallest subnormal,2.0and a NaN payload.guest_mathand the libc tests (8) pass in three runs out of three. Withmain'sMath.cppand this test,guest_mathaborts in aRequire.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.tools/pr_overlap.py --branch: adjacency conflicts only. #9643 rewritesfmodf, the line aboveasinf; #9668 adds itsacosfdebt entry near this one. Keeping both sides resolves each.e4b95a92dmerged cleanly ontomainfcd455870: Ubuntu 26.04 in Docker on Windows, GCC 15, glibc 2.43, WSL2 kernel 6.6, Release,BUILD_TESTING=ON. The reviewer reports five passingguest_mathruns (--repeat until-fail:5). Keeping this PR's test while restoring main's changed production sources makes the test fail on Linux as well. This supplies a Linux regression comparison in addition to the Windows evidence above; it is reviewer-supplied evidence for those revisions, not a local rerun or a latest-main claim.Overlap coordination
#9643 changes the adjacent
fmodfwrapper; #9668 adds the adjacentacosfdebt entry. From this PR's side either landing order is acceptable: retain both functions, both test additions and both debt entries, then rerunguest_mathafter resolving any adjacency conflict. No functional dependency is proposed. Both authors have confirmed either order: @Noxy-HNR for #9643 and @rooklz for #9668. Whichever lands second retains both implementations and test additions, plus both debt entries (acosfthenasinf), and reruns the focused math tests.Depends onremains none.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)sinhfentry didAI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T14:41:35Z.
Review: DISMISSED
The
asinfimplementation follows the cited FreeBSD msun three-range algorithm, and the reported exhaustive comparison against two console libc builds is strong evidence. I compiled a temporary harness from the exactAsinfRational/asinf_nid_postfixsource in this head and ran the 13 added bit-pattern cases; all passed and a preseterrnoremained unchanged. This was not the fullguest_mathtarget. Current-main merge-tree, diff-check and conventions are clean, and the intervening main commits do not touch the changed Math.cpp, GuestMath.cpp or debt paths. Hosted product Linux/Windows tests are skipped; the register-context CI job is a separate suite.Please resolve the repository's required overlap coordination before merge. Pairwise merges of this head with open #9643 conflict in
Math.cppat the adjacentfmodf/asinfhunk, and with #9668 in the adjacent libc debt entries. Both pairs compose by retaining both changes, butCONTRIBUTING.mdrequires the authors to agree an order and record any neededDepends onentry. I asked each author to confirm whether either order works. Please record the agreements on this PR and update the checklist if one must land first. I found no duplicateasinfimplementation.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T14:45:23Z.
@MarcZX10 thanks. On order: either works from my side, and
Depends onstays none unless one of the other authors needs a fixed order.fmodfone-liner just aboveasinf, and this PR replacesasinfand addsAsinfRationalbefore it. The resolution keeps #9643'sfmodfblock, thenAsinfRationaland thisasinf. InGuestMath.cpp, #9643'sRestoreFloatingPointStateand itsacosfchecks sit away fromCheckAsinfConsoleBits.docs/dev/debt/libc.md. The resolution keeps both entries,acosfand thenasinf, with neither text changed. InMath.cppthe two functions are separate, so there is no overlap there.If either of you merges first, I'll rebase this onto it with that resolution and rerun
guest_mathand the exhaustiveasinfcomparison. @Noxy-HNR, @rooklz, please say whether either order works for you too.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T15:01:05Z.
@Noxy-HNR @rooklz — following the overlap review, either landing order is acceptable from #9771's side.
I checked heads
3cd4f5cac270(#9771),43c42031a0cf(#9643) and4951eee5ed87(#9668). #9643 changes the adjacentfmodfwrapper, while #9771 insertsAsinfRationaland replacesasinf; the resolution must retain both implementations and both test additions. #9668 implementsacosf; its adjacent debt entry and #9771'sasinfentry must both remain.Neither is a functional prerequisite for this change. If either lands first, I will refresh #9771, retain both changes and rerun
guest_mathbefore it lands. Please confirm whether either order works for you, or name a preferred order. The description records this as a proposal pending your confirmations; it does not claim an agreement yet.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T16:59:09Z.
Review: COMMENTED
The author has now rebased #9771 onto
499b1cf9fcand reports three passing Windowsguest_math/libc runs, including the exhaustive comparison against the two cited title libc.prx builds. The head has a clean merge tree with currentmain; conventions and diff-check pass. The earlier overlap note remains explicit: merge resolution must retain adjacent #9643fmodfand thisasinfimplementation/tests, and keep both #9668acosfand this debt entry. The author has offered either order but the other authors have not confirmed in the visible conversation, so please record their confirmation or coordinate before merging. The branch is eight commits behind current main; please refresh the stack and rerunguest_mathon the new head. I withdraw the queue-based request to keep this in draft. It is fine to keep submitting PRs; maintainers will handle them in due course. The branch-freshness and overlap requests above remain separate.