fix(libc): compute cbrtf with FreeBSD msun's algorithm, as titles' libc.prx does #9862
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9862"
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-22T19:29:26Z.
What
cbrtfreturned the host'scbrt, so its result depended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 1,303,357,444 of the 2^32 floats (30 %). For example, the console givescbrtf(0x3f000555)=0x3f4b32c7andcbrtf(0x7f7fffff)=0x54cb2ff5.The titles'
cbrtf(NIDGlelR9EEeck) is FreeBSD msun'ss_cbrtf.c, andcbrtfnow computes it the same way:B1/B2, and subnormals scaled by2^24first;The titles' copies set no
errno, and neither does this.cbrtfis imported by 4 of the 22 titles whose relinker registries I audited: PPSA02630, PPSA19591, PPSA25872 and PPSA27616. The core is in double precision, so the FMA-contracted copy of PPSA13934 gives the same bits too.Tested
Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,maind6e7ab42df.libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. Theircbrtfand this build'scbrtf_nid_postfixgive the same bits for all 2^32 arguments, and none of them setserrno.guest_math: the newCheckCbrtfConsoleBitshas 21 cases with the console's results, each also checking thaterrnois untouched: subnormals and normals where UCRT differs, of both signs, ±0, the smallest subnormal, the largest subnormal and smallest normal, 1, ±8,FLT_MAX, the infinities and NaN payloads of both signs.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 --branchfinds no conflicting pull request, and the branch merges cleanly with my other math PRs (#9771, #9777, #9784, #9839, #9841, #9844, #9850, #9857).ac92cc628merged cleanly ontomainfcd455870: Ubuntu 26.04 in Docker on Windows, GCC 15, glibc 2.43, WSL2 kernel 6.6, Release,BUILD_TESTING=ON. The reviewer reportsguest_mathpassing five runs (--repeat until-fail:5). All 21 new cases also pass with main'sMath.cppon this Linux setup, so these cases demonstrate a Windows regression fix and Linux compatibility; they do not establish a Linux result change. An input that distinguishes glibc from the console remains unestablished. This is reviewer-supplied evidence for those revisions, not a local rerun or a latest-main claim.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-23T03:44:32Z.
Review: APPROVED
Reviewed exact head
ac92cc6281131d8499a23c2d1f6ae47296027230. The implementation follows FreeBSD 11.4 msun'scbrtfbit-level seed, subnormal scaling and two double-precision Newton steps; special values and signed zero are covered. The production and test files are unchanged since the tested base; the only current-main change among the PR paths is the adjacent debt index.I locally built the exact PR
Math.cppand test source and ran the isolated 21-caseCheckCbrtfConsoleBitson Linux; it passed. The available fullguest_mathCTest uses an older source snapshot and aborts first at itsstrtolcheck, so this is not a full-suite pass. The author reports exhaustive Windows comparisons and repeated focused tests; independent Linux testing reports five passingguest_mathruns and notes the 21 cases also pass with Linux main's implementation. Hosted policy checks pass; product jobs are skipped.