Repository navigation
fix(libc): compute log10 with fdlibm's algorithm, as titles' libc.prx does - #10247
Conversation
|
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
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). |
a24a71c to
19999e0
Compare
Additive conflicts with main's newer libc math changes: the debt list keeps both sides' entries (per entry), the GuestMath.cpp test functions and calls from both sides are kept, and Math.cpp keeps both sides' independent changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merged current
AI-assisted: yes (Claude Code) |
harisibrar1
left a comment
There was a problem hiding this comment.
Checked against main 39a36bb and fdlibm e_log10.c and k_log.h at freebsd-src 59bc2f0952:
- It merges cleanly into current main. Main's
log10is still the host's (Math.cpp:1082), and_Log(DinkumwareInternals.cpp:87) is the only internal caller. - I compared
log10_nid_postfixandLog10Kernelline by line with e_log10.c and__kernel_log. Everything matches: the subnormal scaling, the0x95f64normalisation, the(2+hx)shortcut andi|=jselect, and the hi/lo recombination order. After scaling a subnormal, the low word is correctly taken from the scaled value. - All the constants (two54, ivln10hi/lo, log10_2hi/lo, Lg1-Lg7) match the source literals and their hex comments.
- I ran a separate Python transcription of the cited fdlibm source on the 21 non-special cases in
CheckLog10ConsoleBits. All of them give the expected bits, including the subnormals, DBL_MAX and the six UCRT-differing arguments. - Small note: this PR and #10253 both add their test function and call at the same place in GuestMath.cpp (just before
CheckExpm1ConsoleBits), so they conflict textually and the second to land needs a trivial rebase.
Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
|
Windows run of 2e79449 merged onto Built |
…h-window-buffer fix(shader): keep mesh register windows out of local memory on NVIDIA
fix(libkernel): return EFAULT from the utimes family for an unreadable times array
…-size-and-event-queries test(libSceRudp): cover max segment size and event lifecycle in GuestRudpStatus
fix(libkernel): return EFAULT from rtprio_thread and sched_rr_get_interval for a bad pointer
…ker-relative-jump-tables-address-space-bounds fix(relinker): validate text section range before scanning relative jump tables
…sample-alpha-to-coverage fix(agc): reject unmeasured single-sample dithered alpha-to-coverage
…module-pins build(deps): restore the SPIRV-Tools, SPIRV-Headers and libvorbis pins
…-header-validation fix(libc): validate guest heap block headers before freeing
…raw-pipeline-report-duplicate-format fix(agc): eliminate duplicated read counters in pipelined draw reports
…ata-backup-dir-name-validation fix(libSceSaveData.native): validate directory name in sceSaveDataBackup
…port feat(agc): host system report and an actionable missing-Vulkan-feature message
…r-callbacks feat(libSceIcu): implement converter stop and skip callbacks
…-sys-is-ps4-process feat(libkernel_sys): implement sceKernelIsPs4Process query
…n-memory-font-entry fix(libSceFont): reuse a font context entry by address only while it is active
|
Integrated current main Rebuilt actual Linux libc and focused test binaries. Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-math6-main08a10-linux-20261030.tar.gz (SHA-256 b984a6334dce65b5c9148e3791ba21605074a5e762ea0f07f96de2f38062ef6e). |
What
log10returned the host'slog10, so its last bit and itserrnodepended on the host. On Windows (UCRT) it differs from thelibc.prxthat titles ship on 3,066,397 of 320 million random arguments. For example,log10(0x4003a67d5567227b)is0x3fd8fa5a3b281494in the bundledlibc.prxand0x3fd8fa5a3b281493here, andlog10(0x4047f462f020acde)is0x3ffae2ff9b87b792there and0x3ffae2ff9b87b793here.The titles' copy (NID
WuMbPBKN1TU) is not the FreeBSD 11.4e_log10.c, which works throughk_log1p. That version differs from the bundled library on about 1% of arguments. It is the older fdlibme_log10.cover itsk_log.h__kernel_log, the same lineage as theerffin #10226.log10now computes it:log;__kernel_logas a staticLog10Kernel;ivln10hi/ivln10loandlog10_2hi/log10_2lorecombination, withx - 1split at its low word.errno: the bundled library's handling differs fromlog's (#10245).log10setsEDOMfor every nonzero argument with the sign bit set: the negative numbers, negative subnormals,-infand negative NaNs. It leaveserrnoalone for ±0, where it returns-inf, and for positive NaN and+inf. This port does the same, and keeps the NaN payloads of fdlibm'sx + xand(x - x) / 0._Logwith a positive base callslog10, and its existing test still passes:log10(1000)is exactly 3 here too.Tested
Current Linux refresh:
19999e0615e1f97ce018d3cea034071743014e32on main6c52b649e7b1592f28db0cb8fe9ac604f0a242e7. Fresh isolated libc/math build passed;guest_mathandguest_dinkumware_internalseach passed three consecutive runs. Diff and conventions checks pass; math and test topic changes remain unchanged after rebase. Linux logs and rebase checks.The Windows module comparisons and negative control below are historical evidence from original head
a24a71c90f2add35da580c8bed491078c791a2d8; Windows was not rerun on the refreshed commit. The original report's console results mean the supplied titles' bundled libraries executed on the Windows host, not measurements on a physical console.Windows 11 Enterprise 10.0.22621, Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release,
BUILD_TESTING=ON,main4997726.Comparison: a scratch loader runs the decrypted
libc.prxof PPSA07923, PPSA05916 and PPSA13934 natively and supplies__error. It compared theirlog10with this PR's code, checking result bits (NaN payloads included) anderrno, on two sets:errnoon all of them.errno. The bits differ on 229,944 random arguments, because that copy is an FMA-contracted build.guest_math: the newCheckLog10ConsoleBitshas 26 cases with the bundled library's results anderrno:|f| < 2^-20edge;DBL_MAX, ±inf, −1 and NaN payloads of both signs;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: Refreshed as one standalone log10 topic on main
6c52b649e7b1592f28db0cb8fe9ac604f0a242e7. The previous fix(libc): compute log with FreeBSD msun's algorithm, as titles' libc.prx does #10245 dependency described series order rather than a required implementation. Nearby math ports still share text/test/debt anchors. fix(libc): compute log2 with fdlibm's algorithm, as titles' libc.prx does #10317 requires this PR's kernel and remains stacked on it.Not tested: macOS, a physical console, floating-point exception flags, and
log10l. Original module comparison and negative control were Windows-only; the new Linux build and regression checks are scoped separately above.Current Linux qualification (2026-10-28)
Rebased onto
main2227f1366188cda5699dd20e2e756a18006a5d4b. Linux CPU validation on 2026-10-28 at6bceecd018be481d9a2b66a36f1704472eeeca5f(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.Canonical declaration cleanup (2026-10-28)
At
2f72ecea0435, removed 93 duplicate local export declarations fromGuestMath.cpp; its includedApi.hppsupplies them. Production code and numeric test bodies are unchanged. Original fails the actual header audit; candidate passes. Per-branch affected-test syntax compilation and conventions/whitespace pass; full standalone-header compilation passed once for the byte-identical header tree shared by the four affected PRs. Source/proofs/logs, SHA25644f560018e4f6b52e8dda4158383f64fc3059fcdb6444840fe5c04fb2c884f11. No new numerical-runtime/platform claim; earlier runs retain original pins. Normal fast-forward only, no rebase. AI-assisted: Codex.Current qualification — 2026-10-30
Integrated current main
08a10d225306ad102b57408e2ef7566bcfb829b2into this existing topic at476bb9f96cb5f66b7bfba9de65143f5d2568d24c. Current-main functions, fixtures, unrelated debt rows and exact dependency gitlinks are preserved; original topic functions and authored commits are retained.Rebuilt actual Linux libc and focused test binaries.
guest_math,guest_math_exact,guest_dinkumware_internalseach passed three consecutive runs (9 runtime passes), pluspublic_headers; conventions and whitespace checks pass. Pinned main passed all seven selected runtime suites plus the header audit three times (24 runs). This is focused Linux CPU qualification; prior Windows/reference evidence retains its original pins. No new Windows, console, SDK-module, title, GPU or performance claim. AI-assisted: yes.Evidence: https://github.com/JJenkx/AnyPS5/releases/download/linux-validation-20261023/owned-math6-main08a10-linux-20261030.tar.gz (SHA-256 b984a6334dce65b5c9148e3791ba21605074a5e762ea0f07f96de2f38062ef6e).
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).