fix(libc): compute lgamma with FreeBSD msun's algorithm, as titles' libc.prx does #18787
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/18787"
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-11-12T08:43:43Z.
What
lgammareturned the host'slgamma. On glibc that result differs in the last bit from thelibc.prxthat titles bundle, on about 40% of inputs in every range:mainFreeBSD 11.4's
e_lgamma_r.c, compiled without contraction, matches the module bit for bit on all 400000 of these inputs. Solgammanow runs a port of it,LgammaMsun, which uses this libc's existingKernelSin,KernelCosandlog, as the other msun ports here do. It is placed afterKernelCoswith the Sun notice, matching the file's other ports.Two things are unchanged:
signgamkeeps its current rules. #7544, #17026 and #8417 deal with it. The module stores 1 for-0, as #17026 says.ERANGEis now set only at the poles (0 and the negative integers), as the module does. It is no longer set when a large argument overflows (lgamma(1e308)), where the host'slgammaset it.The debt entry now names the algorithm and the fused-multiply-add caveat.
Tested
Linux 7.2.14, glibc 2.44, GCC 16.2.1, Release.
I called each title's relinked bundled
libc.prxand this build'slibc.prxside by side on the same 400000 inputs, spread over the ranges above.guest_math_testsgained seven exact-bit cases taken from PPSA08194. It aborts onmainand passes here.guest_math_elementary,guest_math_exactandguest_sce_v2_log_gammapass.python3 tools/check_conventions.py --base origin/mainpasses. Not run on Windows; the port uses only this libc's own kernels.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 PrivacyOnion on 2026-11-12T08:45:40Z.
Review: CHANGES_REQUESTED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
809ea49d12:tools/check_conventions.pypassed;git diff --checkclean.guest_math_testsbuilt cleanly.guest_math,guest_math_elementary,guest_math_exact):Generated withfooter from the description; the AI-assisted checkbox can stay.Requesting changes for the points above.
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-12T11:07:09Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
8730c7fa24:tools/check_conventions.pypassed;git diff --checkclean.guest_math_testsbuilt cleanly.guest_math,guest_math_elementary,guest_math_exact):core/libs/prx/libc/src/Math.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by PrivacyOnion on 2026-11-15T00:37:47Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
293c9dd56f:tools/check_conventions.pypassed;git diff --checkclean.guest_math_testsbuilt cleanly.guest_math,guest_math_elementary,guest_math_exact):core/libs/prx/libc/src/Math.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me