fix(libc): compute hypot with FreeBSD msun's algorithm, as titles' libc.prx does #10325
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10325"
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-23T17:53:25Z.
What
hypotreturned the host'shypotafter an infinity check, so its last bit and its NaN results depended on the host. For example:hypot(0x4093ddc11a2e2b93, 0xc0095f93495aa618)is0x4093ddc527348f7fin the bundledlibc.prxcomparison and0x4093ddc527348f80on Windows (UCRT);hypot(-NaN(2), NaN(1))is0x7ff8000000000002in the bundledlibc.prxcomparison and0xfff8000000000002on Windows.On 4 million random pairs, UCRT's
hypotdiffers from the titles' copy on 182,931.The titles' copy (NID
YFoOw5GkkK0) is FreeBSD msun'se_hypot.c.hypotnow computes it:a + breturn when the ratio exceeds 2^60;sqrtforms with the operands split at their low words.The older fdlibm version gives the same bits on the same 4 million pairs.
main's existinghypottests still pass. They include an infinity with a signalling NaN in both orders, which msun's ordering already returns as infinity, so the separate infinity check goes away.hypot3calls thishypot, and its existing tests still pass too.errno: neither msun nor the titles' copy sets it, even when a finite pair overflows to infinity (hypot(DBL_MAX, DBL_MAX)), and this port sets none either.Tested
Current-main integration — 2026-11-03. Head
9079b1e8c3d4d1b9b650d52813454a00a9f078e4includes main4f41f4c375f5abb487dbd184fbc150f31994d762and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic.Linux x86-64 Release, GCC 16.2.1, Ninja, BUILD_TESTING=ON: rebuilt actual libc and math executables.
guest_math,guest_math_exact, andguest_dinkumware_internalseach pass 3/3 (9 passes, zero skips);public_headersand conventions pass. The same three groups pass 3/3 plus headers on pinned main. All 34 recursive dependency trees and 31,551 tracked blobs verify with zero errors; the update=none QuickJS test262 corpus is excluded from these library inputs.git diff --checkreports the preserved verbatim licence trailing-space line; no other whitespace warnings occur.Source/parent/gitlink proofs, exact library/test hashes, raw logs/JUnit, and head-leased push receipts: qualification archive, SHA-256
e6a50522bc28e30871fdc2c12a88d2537515914239e8166f6237f48895126a06(download verified). Older platform/reference reports retain their original pins; no new Windows/macOS, SDK-module, console, title/GPU or performance claim. AI-assisted: yes (Codex).Earlier dated qualifications below retain their recorded source/platform pins.
Current-main refresh — 2026-11-02. Published head
0d0d95368df2b1377eb17106fc9ec11ff4da750eincludes pinned maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8. The hypot production body and CheckHypotConsoleBits fixture remain unchanged. Main’s log10/log2/atan functions and test calls are retained. The refreshed topic is linear on pinned main with original authorship.Rebuilt actual libc/Ampr and selected tests from the final input tree.
guest_math,guest_math_exact,guest_dinkumware_internalseach pass three consecutive runs: 9 runtime passes, zero skips, plus public_headers. Conventions and whitespace pass. Source/input manifests, exact dependencies, library/test hashes, logs/JUnit and head-leased push receipts are attached. The same pinned main passes 18 selected groups three times (54 runtime passes) plus headers. All 34 recursive dependency trees/31,551 tracked blobs verify with zero errors; QuickJS’s update=none test262 corpus is explicitly excluded because it is not a library build input.Linux-7.2.11-arch1-1-x86_64-with-glibc2.44, Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON. Focused Linux CPU qualification only. Older Windows/module/reference reports retain their original pins; no fresh Windows/macOS, SDK-module, console, title/GPU or speed claim. AI-assisted: yes (Codex).
Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/math-six-main-a4eca-linux-extra10321-20261102.tar.gz; SHA-256 525ccb31a5d3d0f5adced5fda58818d8432f06c0afa7290139adb60ae6664b54.
Earlier dated qualifications below retain their recorded source/platform pins.
Rebased without merge commits onto main
73f4f7e06e4f210a8c6570e335fd654dc0a86134. Tested exact head7f566e9afe54d53f9271d0f0de275f1023e9d991on Linux x86-64 (AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON, bundled dependencies).Rebuilt
libc,guest_math_tests,guest_math_exact_testsandguest_dinkumware_internals_tests.guest_math,guest_math_exact,guest_dinkumware_internalsandpublic_headerseach pass three consecutive times on both pinned main and this exact head: 12 passes per side, zero skips. Conventions and whitespace checks pass. GitHub current-main integration is now backed by these local tests; the latest fetched main also has a clean merge preview.Original authored executable code and tests are preserved. The exp parent retains its FreeBSD notice; trailing whitespace was removed from three copyright-notice lines. No new Windows, macOS, bundled-SDK/console reference, GPU/title, performance or full-suite execution is claimed. Earlier reference comparisons retain their original source pins.
Source patches, source-preservation proof, exact pins, build logs, raw CTest logs, JUnit and binary hashes; SHA-256
46b6a1579d909a279510564f346f32b61073cc5d090decd6acc0684bfe6d706c. Uploaded copy downloaded and verified. AI-assisted: yes (Codex).Checklist
main; no other open PR implements the same functions. #10321 and #10328 add their test functions and debt entries at the same places incore/libs/tests/GuestMath.cppanddocs/dev/debt/libc.md, so whichever of these PRs lands later needs those lines mergedNotImplemented_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 didImported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T05:36:49Z.
Review: APPROVED
Checked against main
7c2400d29band FreeBSD msune_hypot.cat release/9.0.0, 10.0.0, 11.4.0 and 12.0.0:(1023+k)<<20final scale, so the link is right. 9.0.0 and 10.0.0 differ only in ways that give the same bits.CheckHypotConsoleBitsvectors, in both argument orders, through a Python emulation of the same operations in plain IEEE double, and every one matches. Main's infinity/signalling-NaN tests (GuestMath.cpp:548-551) also still return +inf with this code.fabsl(x+0.0L)-fabs(y+0), which on x86-64 should pick the NaN with the larger payload rather than the first argument. I couldn't run that; it comes from Intel's documented NaN rules. The current vector (NaN(2), NaN(1)) gives the same answer under both, and the swap check skips NaNs. If your title harness confirms it, a case like{0x7ff8000000000001, 0xfff8000000000002, 0x7ff8000000000001}would pin the 11.4.0 behaviour.main()and the debt line aftercoshf), which is easy to resolve whichever lands first.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T21:05:41Z.
Review: CHANGES_REQUESTED
The PR now includes the reversed quiet-NaN regression, and the author reports repeated
guest_math/guest_dinkumware_internalsruns on Linux and Windows. After refreshingupstream/main, this branch's merge base is1e20650e8458, with 6,822 current-main commits since it.CONTRIBUTING.mdasks contributors to keep branches up to date with main, and current hosted product jobs are skipped. The current-base conventions and diff checks pass, and the merge is clean, but the math tests are still on the older base. Please update to current main and rerun both math suites on the resulting tree. I will revisit approval when current-base integration is validated.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T12:55:38Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The new Linux qualification is valid evidence for
d08fdf47159ca7e888e212baf49e5a3393aeb233, but that head is still based on2227f136…, not currentmain.What I ran
Reviewed PR head
d08fdf47159ca7e888e212baf49e5a3393aeb233against its base2227f1366188cda5699dd20e2e756a18006a5d4b. Currentmainis60bdb061356db736928eee431cd8bd4c9ba68036, 3,334 commits ahead of that base. I downloaded the author-provided Linux qualification archive and verified its SHA-256 and the10325result and test logs.Results
guest_dinkumware_internalsartifact2227f136…, 3,334 commits behind current mainUnedited Linux test-log excerpt
Negative control
Not run for this re-check. The supplemental report adds positive tests and does not claim a new negative control.
Findings
Blocking
CONTRIBUTING.mdrequires branches to stay up to date withmain; current main has advanced by 3,334 commits. Please refresh this branch onto current main and rerun the focused tests on the resulting head before approval. For #10321, refresh its open prerequisite #10234 first, then update the dependent branch.Non-blocking
Sources
Not verified
I did not rebuild or rerun the C++ tests locally. Windows evidence is author-reported. No console, SDK, title, GPU, or full-suite testing was performed in this re-check.
To get this to a good state
Rebase onto current
main, preserving declared dependency order, then provide exact-head results for the focused math and Dinkumware tests. I will re-run the same source and integration checks on the refreshed heads.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T12:57:05Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The supplemental Linux evidence is pinned to the current PR head, but it does not test the combination with current
main, which has since changed the same source, test, and debt files.What I ran
Reviewed PR head
d08fdf47159ca7e888e212baf49e5a3393aeb233(base2227f1366188cda5699dd20e2e756a18006a5d4b) and currentmain60bdb061356db736928eee431cd8bd4c9ba68036. Compared the changed-path lists and fetched file identities forcore/libs/prx/libc/src/Math.cpp,core/libs/tests/GuestMath.cpp, anddocs/dev/debt/libc.md. Downloaded the author-provided Linux evidence archive and verified its SHA-256 and10325test log.Results
guest_dinkumware_internalsguest_math/guest_math_exactruns2227f136…Unedited test-log excerpt from the supplied archive
Negative control
Not run in this re-check. The new report supplies positive runs and makes no new negative-control claim.
Findings
Blocking
Math.cpp,GuestMath.cpp, anddocs/dev/debt/libc.mdall changed on currentmainafter the PR's base. For example, currentMath.cppstill has the host-backedhypotpath and currentGuestMath.cpphas newer math/environment test changes; the supplied archive was built from the older tree. A passing old-base run does not establish the result when these changes are combined. Please refresh this branch onto currentmainand rerun the focused math and Dinkumware tests on the resulting head. For #10321, update its open prerequisite #10234 first, then refresh the dependent branch.Non-blocking
Sources
Math.cppat mainGuestMath.cppat mainNot verified
I did not rebuild or rerun C++ tests locally, and did not test the combined tree on current
main. Console, SDK, title, GPU, and full-suite behavior were not verified in this re-check.To get this to a good state
Refresh onto current
main(respecting dependency order), then provide exact-head results forguest_math,guest_math_exact, andguest_dinkumware_internals. I will rerun the relevant source, test, and integration checks on that head.