fix(libc): compute logb and logbf with FreeBSD msun's algorithm, as titles' libc.prx does #10346
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10346"
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-23T18:31:54Z.
What
logbandlogbfreturned the host'slogb, which differs from thelibc.prxthat titles ship in two ways on Windows (UCRT):errnotoERANGE, while the titles' copies return-infand leaveerrnoalone;logb(0x7ff0000000000001)is0x7ff8000000000001there.The titles' copies (NIDs
owKuegZU4ewandRWqyr1OKuw4) are FreeBSD msun'ss_logb.cands_logbf.c. Both functions now compute them:-1 / |x|for ±0;x * xfor infinities and NaNs;Tested
Rebased as
0f7056d67bde93eec09453764c5b5ead5c5a98b1, one topic commit directly on main5b85225ef39b9321d8f5c251ecb391b8331e8aea, without merge commits. Only the additive debt append conflicted; all main entries and this PR's logb/logbf entry are retained. The added and removed line multisets in implementation, tests and debt are unchanged from previous public heada9a153ac2b2493a53929855d86b9f401c19f70cd.Fresh Linux x86-64 Release builds of libc and the three math executables pass.
guest_math,guest_math_exact,guest_dinkumware_internalsandpublic_headerseach pass three consecutive runs on main and on the change (12 passes per arm, no skips). Conventions and whitespace checks pass. This establishes Linux compatibility; it does not demonstrate a Linux defect fixed. Windows, title-library comparisons and floating-point exception flags were not rerun for this rebase.Exact-head refresh patch, preservation proof and build/test logs — SHA256
d080877ea94697087a0faab38d7de212d72bf059be3d2f1ded1a7b1c2d2b0c8a; uploaded archive downloaded and hash-verified.Earlier Windows report, retained from public head
d7bf9b3772; Windows was not rerun for this Linux refresh:Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main65ac1d3b50.Comparison: a scratch loader runs the decrypted
libc.prxof eleven titles natively and supplies__error: PPSA04158, PPSA05916, PPSA07923, PPSA09614, PPSA13934, PPSA20423, PPSA25636, PPSA26528, PPSA33655, PPSA34008 and PPSA35169. It compared theirlogbandlogbfwith this PR's code, checking result bits (NaN payloads included) anderrno, on 4,032,768 inputs per title:All eleven give identical bits on all of them, and none sets
errno. Against the host'slogbwitherrnoignored, 997 double and 7,957 float inputs differ, all signalling NaNs.guest_math: the newCheckLogbConsoleBitshas 15 double and 15 float cases with the console's results:inf, a signalling NaN of each sign and a quiet NaN.Each case also checks that
errnostays unchanged.main's existinglogbchecks still pass.guest_mathandguest_dinkumware_internalspass in three runs out of three on the exact head.Negative control: with
main'sMath.cppand these tests,guest_mathaborts in aRequire, whileguest_dinkumware_internalsstill passes.A standalone
-O0and-O3build of the new code with the new vectors passes.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Order: this PR adds a test and a debt entry at the same anchors as my other libc PRs, so it conflicts with them textually only and lands in any order.
Not tested: macOS, a physical console, the floating-point exception flags, and
logbl.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-23T18:59:18Z.
Review: APPROVED
Reviewed the bit-level implementation and the subnormal scaling paths for both precisions. The zero case produces negative infinity without setting
errno, and thex * xpath quiets signaling NaNs while retaining the payload as the reported title copies do. The added vectors cover signed zero, subnormal boundaries, finite extremes, infinities, signaling NaNs and quiet NaNs.The PR reports matching output bits and
errnoagainst eleven bundled titlelibc.prxcopies over 4,032,768 inputs per function, plus three passingguest_mathruns and a negative control. Hosted conventions, eligibility, intake, labels, report and relinker checks pass; full Linux/Windows product jobs are skipped by repository policy. I did not run a local product test because this host fails the project's CPU feature guard. I found no blocking issue in the inspected changes.