fix(libc): compute atanh with FreeBSD msun's algorithm, as titles' libc.prx does #10315
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10315"
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:29:50Z.
What
atanhreturned the host'satanh, so its last bit and itserrnodepended on the host. For example,atanh(0x3f03a67d5567227b)is0x3f03a67d558ea76ein the bundledlibc.prxand0x3f03a67d558ea76fon Windows (UCRT). On 20 million random arguments, UCRT'satanhdiffers from the titles' copy on 1,841,966.The titles' copy (NID
YjbpxXpi6Zk) is FreeBSD msun'se_atanh.c, computed through msun'slog1p.atanhnow computes it overlog1p_nid_postfix, the msun port supplied by the already merged #10314:2^-28shortcut;|x| < 0.5form0.5 * log1p(2x + 2x^2 / (1 - x));0.5 * log1p(2x / (1 - x))form above it.errno: msun sets none. The titles' copy sets it at msun's two error returns:EDOMat(x - x) / (x - x), for |x| > 1, the infinities and every NaN, keeping NaN payloads;ERANGEatx / 0, for ±1.This is the same rule as the bundled library's
atanhfalready in the debt file. The internallog1pcalls always get arguments ≥ 0, solog1p's ownEDOMnever fires from here.Tested
Current-main refresh — 2026-11-04. Head
9811e07c2f421d3ea034cb7f3388a006dc354c11merges 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).Current-main integration — 2026-11-03. Head
7c767c439fb25a28415020465d9f727ecf964fe5includes 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). That Linux archive makes no Windows/macOS, SDK-module, console, title/GPU or performance claim; older platform/reference reports retain their original pins. AI-assisted: yes (Codex). The prior Windows/negative-control head remains0a95fd8f78c6b9c57c5a16212b48b3b01cbe0b0b; relevant atanh/log1p routines, edge fixtures, Dinkumware source/test and VABI header are byte-identical, that continuity proof remains separately scoped. Fresh final-head Linux and Windows controls are recorded below.Fresh current-head Windows qualification — 2026-11-03: exact 7c767 Windows receipt records 12/12 initial math/exact/Dinkumware/header passes, a frozen-test body-only
std::atanhnegative atCheckAtanhConsoleBits, then 12/12 restored passes, zero skips. Actual module binding, 37,044 source/provider blobs and raw hashes are verified. Raw PE hashes differ; only timestamp/checksum fields are zeroed in a separate in-memory comparison, with all other bytes identical. This is not a fresh Linux negative or a new SDK-module/console/title/performance/full-suite result. AI-assisted: yes (Sol6.1medium).Fresh current-head Linux negative/restoration — 2026-11-03: On the same exact
7c767c439fb25a28415020465d9f727ecf964fe5head, the three math/exact/Dinkumware groups pass three times each (9). Replacing only the doubleatanh_nid_postfixbody withreturn std::atanh(x);fails the unchangedCheckAtanhConsoleBitsbit assertion atGuestMath.cpp:1417. Restoring the exact source returns all three groups to three passes each (9), pluspublic_headers, zero skips. The library and all three test executables have identical raw SHA-256s before and after restoration. Both 31,551-provider-blob audits match; source is clean and the actual privatelibc.prxloader path is recorded. Verified Linux control/restoration logs, JUnit and fingerprints, SHA-2564cf51299cc068b43477322860d635451ba2450a478ea6b865af3e85b18c0ca5c. This supplies a fresh Linux final-tree negative separately from the historical controls; no new SDK-module, console, title or performance comparison. AI-assisted: yes (Codex).Earlier dated qualifications below retain their recorded source/platform pins.
Historical head
0a95fd8f78c6b9c57c5a16212b48b3b01cbe0b0bmerged main92d2fdc3438f83e39d624eb65f3195bf2701568cinto the existing branch, without rebasing or force-pushing. The conflict resolution retains both this PR's atanh test calls/debt entry and main's log10/log2 calls/debt entries. The atanh implementation is byte-identical to prior public head72a6683e64531e4fc948e6115af96037b367ab5e.Linux x86-64, Arch 7.2.11-arch1-1, Ryzen 9 7950X, GCC 16.2.1, Ninja Release,
BUILD_TESTING=ON, pinned dependency worktrees. Rebuilt actual libc and the math/exact-math/Dinkumware targets.guest_math,guest_math_exact,guest_dinkumware_internals,public_headers: 4/4 pass, zero skips.Final-tree negative control: the same frozen math executable aborts under GDB at
CheckAtanhConsoleBitswhen onlyatanh_nid_postfixis replaced with the pre-topicreturn std::atanh(x)wrapper. All other production functions and every test are retained. Exact source restoration rebuilds libc byte-for-byte identically; all four checks pass again. Conventions and whitespace checks pass; worktree clean.Fresh build/control logs, JUnit, hashes and exact diff, SHA-256
abd0345d33231e5b624db479c7e01b85cca84b5329598e643a61595b4f78f85f.Earlier reference measurements retain their original source pins and scope; see prior exact-head qualification. At historical head
0a95fd8, Windows qualification and the supported-behavior host-wrapper negative control were complete; see that Windows follow-up for the exact pins, 12/12 initial and 12/12 restored passes, loaded-module path and verified artifact. No new bundled-library reference, console, title/GPU or performance execution is claimed. The separate #10565 follow-up addresses matching x87 exception flags; that behavior is not added here.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)Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T12:46:33Z.
Review: COMMENTED
Checked against main
39a36bbec8and FreeBSD release/11.4.0 lib/msun/src/e_atanh.c (over s_log1p.c):(ix|((lx|-lx)>>31))domain test, thex/zeropole, the 2^-28 shortcut and both log1p forms.EDOMandERANGEare added only at msun's two error returns.CheckAtanhConsoleBitsexpectations, including NaN payloads and errno.git merge-file; the reverse order gives the same result.Math.cppends up with a singlelog1p.GuestMath.cppgets twostatic void CheckLog1pConsoleBits()definitions, because this PR inserts it afterMakeExtendedand #10314 afterCheckExpm1ConsoleBits.main()also gets two calls to it. That would fail to compile as a redefinition. I didn't build it.docs/dev/debt/libc.mdgets two identicallog1pbullets, one beforeexpm1and one after.atanhis still the host forwarder.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:12:54Z.
Review: DISMISSED
The earlier review identified a real stacked-test collision with #10314; the updated description says the inherited
log1ptest and debt entry now align with that branch, which addresses that concern. The integration evidence is still based on6c52b64, 6,822 commits behind currentmain, and the hosted Linux/Windows product jobs are skipped. Please refresh #10314 and this dependent branch onto currentmain, then rerunguest_mathandguest_dinkumware_internalson the final head on Linux and Windows. Keep the negative control tied to that final tree.