Repository navigation
fix(libc): compute asin and acos with FreeBSD msun's algorithm, as titles' libc.prx does - #10253
Conversation
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Linux run at this PR's exact head Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release,
This is the focused test only; no title, console or floating-point exception flags were checked. AI-assisted: yes (Claude Code). |
|
Linux run at this PR's exact head Arch Linux, kernel 7.2.9, Ryzen 9 7950X, g++ (GCC) 16.2.1 20260810, glibc 2.44, x86-64. Release,
This is the focused test only; no title, console or floating-point exception flags were checked. AI-assisted: yes (Claude Code). |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 39a36bb and FreeBSD release/11.4.0 lib/msun/src/e_asin.c and e_acos.c:
- It merges cleanly into current main, and main's
asin/acos(Math.cpp:359-366) haven't changed since your base. - I compared both functions line by line with e_asin.c and e_acos.c. The branches, the cutoffs (0x3e500000, 0x3c600000, 0x3FEF3333), the low-word
sqrtsplit and acos's volatilepio2_loall match, andAsinRationalis exactly msun'sp/q. - All the constants match the source literals, and each one round-trips to the hex in msun's comments.
- I ran a separate Python transcription of the two FreeBSD files on all 19 finite cases in
CheckAsinConsoleBits. It gives the expected asin and acos bits for every one, including the three UCRT-differing arguments. So the expectations agree with the cited source, not only with the port. - Small note: this PR and #10247 both add their test function and call at the same place in GuestMath.cpp (just before
CheckExpm1ConsoleBits), so they conflict textually and whichever lands second needs a trivial rebase. You've already listed the order.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
66039c0 to
57b6d20
Compare
|
Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head Linux Release focused rebuild: Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256: AI-assisted: yes. |
… main merge The merge commit 1ccf0b9 removed CheckTrigConsoleBits and its call from GuestMath.cpp, so this branch carried the sin, cos and tan implementation from boykopovar#10250 but no longer tested it. The function and its call are restored verbatim from the commit that added them (4d98e81 by JJenkx); nothing else changes. Fix-up on the author's branch, credited to JJenkx. Co-Authored-By: JJenkx <31495916+JJenkx@users.noreply.github.com>
|
Windows check for the scheduled cross-platform review, at head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run this test on pull requests.
AI-assisted: yes. |
…s-msun # Conflicts: # core/libs/tests/GuestMath.cpp
|
Merged current Windows, exact head (Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release):
AI-assisted: yes. |
…s-msun # Conflicts: # core/libs/tests/GuestMath.cpp
|
Refreshed onto Windows, WinLibs GCC 15.2 UCRT, Release:
AI-assisted: yes. |
✅ AMD GPU test: passedPR head
Unstable on main (3, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (12, not counted against this PR)Validated but not compared (2, not in the main baseline's validation pass)Validation IDs already present on main (4 IDs in 808 tests)Skipped (68)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
…s-msun # Conflicts: # core/libs/tests/GuestMath.cpp
|
Refreshed onto Windows, WinLibs GCC 15.2 UCRT, Release:
AI-assisted: yes. |
|
Linux check of exact head
AI-assisted: yes |
✅ AMD GPU test: passedPR head
Unstable on main (7, these also failed in recent main runs on this machine; not counted against this PR)Failing on main too (10, not counted against this PR)Passed on retry (1, failed in the parallel run, passed when re-run with a 360 s timeout; not counted against this PR)Validation IDs already present on main (4 IDs in 805 tests)Skipped (71)ReproduceAutomated build and test on a contributor's AMD machine; it does not replace upstream CI. A new comment is posted for each new push. Full logs. |
The e_acos.c licence block lacked the trailing space after "notice" that upstream FreeBSD release/11.4.0 has. Co-authored-by: JJenkx <31495916+JJenkx@users.noreply.github.com>
|
Linux check of exact head
AI-assisted: yes |
|
Windows check of head Setup: Windows 11 Enterprise 22621, WinLibs GCC 15.2 UCRT, Release. The hosted Windows check does not run these tests on pull requests.
AI-assisted: yes. |
|
Hi @JJenkx, I merged |
What
asinandacosreturned the host's functions, so their last bit and theirerrnodepended on the host. For example,asin(0x3fef4102aaf38ef0)is0x3ff5abc7e3600d9don the console and0x3ff5abc7e3600d9con Windows (UCRT). Likewiseacos(0x3fde7903ac7bb90a)is0x3ff13151a8ce8628there and0x3ff13151a8ce8629here.For arguments outside [-1, 1],
main'sasinreturns a negative NaN and raisesFE_INVALID, but leaveserrnoalone (#3605, which followed FreeBSD's source). The titles' copy setsEDOMthere.acosonmainis the host's.The titles' copies (NIDs
7Ly52zaL44QandJBcgYuW8lPU) are FreeBSD msun'se_asin.cande_acos.c. Both now compute them:|x| == 1and|x| > 1cases;pS/qSrational, written once asAsinRationalbecause both files use the same coefficients;|x| < 0.5,0.5 <= |x| < 0.975and|x| >= 0.975paths ofasin, and thex < -0.5andx > 0.5paths ofacos, with theirsqrtsplit at the low word;acos'spio2_lo, read at run time as msun'svolatileread does.errno: msun sets none, but the titles' copies setEDOMfor every argument outside [-1, 1]: finite ones, the infinities, and every NaN. That is exactly msun's(x - x) / (x - x)return, which both ports now take. It gives the default negative NaN for non-NaN arguments, asmain'sasintests expect, keeps a NaN argument's payload, and raisesFE_INVALIDitself. Arguments in [-1, 1] never set it.Tested
Current-main refresh — 2026-11-04. Head
3135ae25861c85b24139896b133e7cbca68c9718merges main9ab6a281ea61c9e62a7eb07eb4cef8f19ede1c5cwhile retaining the prior public head as an ancestor. Main’s newer code, regression fixtures and debt entries are preserved alongside this topic.Linux x86-64, GCC16.2.1, Ninja Release: actual libc, libkernel and libSceAmpr CMake owners rebuilt coherently.
guest_math,guest_math_exact,guest_dinkumware_internalseach pass three consecutive runs (9 passes, zero skips). The same groups pass three times on pinned main. Public-header audit and conventions pass. Original licence-notice trailing whitespace is retained where present. The scoped recipe reuses frozen ZArchive/zstd providers; this is not a whole-project build. No new Windows, bundled-SDK, physical-console, title/GPU or FPS measurement is claimed; earlier reports retain their original pins.Exact source/parent proofs, per-branch patches/input manifests, build and CTest logs/JUnit, library/executable hashes and scoped CMake recipe, SHA-256
97a2377bc996be1690e8853e1ea090a98b5ed808bcc37a15a5cdada5c2e00845(download verified). AI-assisted: yes (Codex).Review follow-up —
7e375f18d465586d4e50d2893d4d2a9a840702e2. Restored main's float-trig debt wording: the existingTrigfKernelRemPio2remains a separate one-word/precision-0 port, not shared with the new double reduction. Movedtan_nid_postfixand its complete s_tan.c notice together above the e_sinh.c notice, which again directly precedessinh_nid_postfix. Trimmed the four notice-line trailing spaces. Executable tokens are unchanged except for the order of the tan definition; notice wording is retained.Linux x86-64/GCC16.2.1 Release: rebuilt actual libc,
guest_math_tests, andguest_math_exact_tests; both test groups pass three repetitions each (6 passes, zero skips). Conventions andgit diff --check 4f41f4c375fpass. No new Windows, console, title or performance run is claimed. Review-fix patch, logs and source hashes, SHA-2564ce442ee8617e329d8e5f1e6c36e628e65e921bf84421dcc4c15e50c88da1f2b(GitHub asset digest verified).Current-main integration — 2026-11-03. Head
af6e9e83fa50bfe3bff146f2560120f11b9f1d0aincludes main4f41f4c375f5abb487dbd184fbc150f31994d762and retains the prior public history and attribution/licence notices. Main’s newer math implementations and fixtures remain alongside this topic. Main’s float argument-reduction tables, helper andTrigfRemPio2remain byte-identical and separate from the retained topic double-trig implementation. Actual open prerequisite #10250 head5c054e6b5e48aef1bde87b7f6c31b70a9e00d563is an ancestor.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. The four notice-line trailing spaces from this integration are removed in the follow-up below; no claim that main uses them remains.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 integration (2026-11-02):
2181a5edab48e035145cff5825c79240a87e8181includes maina4eca2a056bf3bbbec98ab42e9d28163e4ea9cb8and retains the existing public commits. Conflicts preserve main’s math implementations, regression checks and debt entries alongside this topic. Linux x86-64 Release, GCC 16.2.1: rebuilt libc and the three math executables;guest_math,guest_math_exactandguest_dinkumware_internalseach pass three times (9 passes, zero skips), andpublic_headerspasses. The same baseline groups pass on main; conventions and whitespace pass. Source and dependency blobs, executable/library hashes, raw logs and JUnit are retained. This refresh adds no new console, Windows, title, GPU or numerical-reference measurement. Qualification evidence, SHA-25622866bd2a060ba69cd4387d471605afe20ed644e3257174b2d1488635f8c9b52(download verified).The current prerequisite #10250 head
5c054e6b5e48aef1bde87b7f6c31b70a9e00d563is an ancestor of refreshed headaf6e9e83fa50bfe3bff146f2560120f11b9f1d0a.Main conflict refresh, 2026-10-27 10:18 UTC pass: exact head
57b6d204b0f7856c66cd6b997330c02dc9e5b83eon tested main3fea2a937ba9fbab2f06c51691fe0c5763659aa3. The topic implementations and fixtures are retained alongside current main's newer math functions and coverage.Linux Release focused rebuild:
guest_mathandguest_math_exacteach pass three repetitions: 6 passes, zero skips. Conventions, whitespace and merge checks pass. Every refreshed head's submodule pointers match the pinned main; the private dependency checkouts used for the gates are aligned. No new negative-control, Windows, console, title, GPU, full-suite or performance run is claimed. Earlier measurements below retain their original exact pins. Fulfilled merge-order dependencies have been cleared from the checklist; open prerequisites remain.Exact source/dependency pins, patch-preservation and gitlink proofs, builds, verbose tests, JUnit and lease-push receipts. SHA-256:
702c4110ee9dde421c2dd5e057ed53a2df05e0cf7b01f67e8fb9cb779e332f7c; downloaded copy verified.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main4be3da2.Comparison: a scratch loader runs the decrypted
libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theirasinandacoswith this PR's code, checking result bits (NaN payloads included) anderrno, on:Results:
errnoon all of them.errno. The bits differ on 5,576asinand 1,823acosarguments, because that copy is an FMA-contracted build.errnorule: the console setsEDOMon exactly the arguments outside [-1, 1].guest_math: the newCheckAsinConsoleBitshas 25 arguments, each with the console'sasinandacosand itserrno:inf;main's existingasinchecks still pass, except one. The check from fix(libc): asin(|x| > 1) returns the x86 default NaN and leaves errno unchanged #3605 thatasin(2.0)leaveserrnoat 0 now expectsEDOM, because both PPSA07923's and PPSA05916'sasin(2.0)set it (and every other argument outside [-1, 1] does too). ItsFE_INVALIDchecks, raised for 2.0 and not for a quiet NaN, are unchanged and pass. cc @CouchRiv: the NaN bits and flags from fix(libc): asin(|x| > 1) returns the x86 default NaN and leaves errno unchanged #3605 are kept; only theerrnofollows the console instead of FreeBSD's source.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.python tools/check_conventions.py --base origin/mainandgit diff --checkpass.Overlap and order: fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771 (
asinf), fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does #10222, fix(libc): compute atan and atan2 with FreeBSD msun's algorithm, as titles' libc.prx does #10229, fix(libc): compute exp with FreeBSD msun's algorithm, as titles' libc.prx does #10234, fix(libc): compute log with FreeBSD msun's algorithm, as titles' libc.prx does #10245, fix(libc): compute log10 with fdlibm's algorithm, as titles' libc.prx does #10247 and fix(libc): compute sin, cos and tan with FreeBSD msun's algorithm, as titles' libc.prx does #10250, all mine, replace one-line host wrappers nearasin's andacos's or add tests and debt entries at the same anchors, so they conflict textually. This PR lands last: fix(libc): compute atanf with FreeBSD msun's algorithm, as titles' libc.prx does #9777 → fix(libc): compute atan2f with FreeBSD msun's algorithm, as titles' libc.prx does #9784 → fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does #10222 → fix(libc): compute powf like the libc.prx that titles ship #9850 → fix(libc): compute atan and atan2 with FreeBSD msun's algorithm, as titles' libc.prx does #10229 → fix(libc): compute exp with FreeBSD msun's algorithm, as titles' libc.prx does #10234 → fix(libc): compute log with FreeBSD msun's algorithm, as titles' libc.prx does #10245 → fix(libc): compute log10 with fdlibm's algorithm, as titles' libc.prx does #10247 → fix(libc): compute sin, cos and tan with FreeBSD msun's algorithm, as titles' libc.prx does #10250 → fix(libc): compute asin and acos with FreeBSD msun's algorithm, as titles' libc.prx does #10253 → thepowPR, with fix(libc): compute erff and erfcf with fdlibm's algorithm, as titles' libc.prx does #10226 after fix(libc): compute expm1f with FreeBSD msun's algorithm, as titles' libc.prx does #10222, fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does #9857 before fix(libc): compute sin, cos and tan with FreeBSD msun's algorithm, as titles' libc.prx does #10250 and fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771 before fix(libc): compute asin and acos with FreeBSD msun's algorithm, as titles' libc.prx does #10253. A combined preview of all twelve heads (5d16b438db, including fix(libc): compute sinf, cosf, tanf and sincosf with FreeBSD msun's algorithms, as titles' libc.prx does #9857 and fix(libc): compute asinf with FreeBSD msun's algorithm, as titles' libc.prx does #9771) resolves every conflict by keeping each port and dropping each host wrapper. Each ported function is defined once and each console test is called once, andguest_mathandguest_dinkumware_internalspass in three runs out of three on it.Not tested: Linux and macOS (the result no longer depends on the host's functions), a console, the floating-point exception flags, and
asinl/acosl.Current Linux qualification (2026-10-28)
Rebased onto
main2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 at5b96a875888056c5bd758270593be17d1a3f5542(Arch Linux 7.2.9, AMD Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON).libc,guest_math_testsandguest_math_exact_testsrebuilt from this exact source.guest_mathandguest_math_exacteach passed three consecutive runs (6/6, no skips); the same two suites each passed three runs on the pinned main (6/6). Conventions and whitespace checks pass.Exact source pins, preservation proofs, dependency checks, build logs and JUnit, SHA-256
1176269c9e6948b5252a5db9e660978d7f978fb2d9f4ed6c68bc050b10b5ae68. This is focused Linux CPU qualification; earlier Windows/title/reference measurements retain their original pins. No new title or performance result is claimed.Current Linux qualification — 2026-10-29
Refreshed against main
5454cd2e455994d992aca39335ce60507eeda1eb.Linux qualification at
ec98fb890ddb084b3a597798521e2c24260fb344(Arch Linux 7.2.9, Ryzen 9 7950X, GCC 16.2.1, Ninja Release, BUILD_TESTING=ON):guest_math,guest_math_exact,guest_dinkumware_internalseach pass three consecutive runs (9/9, no skips). Thepublic_headersaudit passes at this exact head. All tracked public-header files match the pinned main; the affected test targets rebuild against those headers. Conventions and whitespace checks pass. The same focused groups passed three times on the pinned main.Evidence: immutable Linux qualification bundle. Its SHA-256 is
53b095da2f67f55b8aa56ba273681e0330fb39739be844458038dde410fb8cc4. No fresh Windows runtime execution is claimed; older measurements retain their recorded source pins.AI-assisted: yes (Codex).
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 did5c054e6b5e48aef1bde87b7f6c31b70a9e00d563)