fix(libc): store the sign of gamma in an exported signgam from lgamma #6318
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6318"
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 hypermoist on 2026-10-15T11:13:29Z.
What
lgammareturned the host's value but never stored the sign of Γ(x), because libc exported nosigngam. The debt entry indocs/dev/debt/libc.mdrecorded this.libc now exports
signgam(NID5gOOC0kzW0c, from the aerolib symbol list), starting at 0 as in FreeBSD 11'ss_signgam.c.lgammasets it by the rules of FreeBSD 11'se_lgamma_r.c:sin_pi(x)), 1 otherwise.The returned value is unchanged; it is still the host's
lgamma.Overlap: #5775 rewrites the same
lgammaline, to handle subnormal arguments on Windows. Whichever merges second needs a trivial rebase that keeps both the subnormal branch and thesigngamstore.Tested
CachyOS Linux (kernel 7.2.9), GCC 16.2.1, Release, on
main8856f180c.guest_mathchecks the stored sign for positive values, ±0, -0.5, -1.5, -2.5, a tiny negative, negative integers including -2^60, a value just above -2^52, ±inf and NaN.lgamma_rover 2,000,000 values in [-200, 200], including integers and values scaled by 2^-70. There were 0 mismatches outside the negative-integer poles, where glibc and FreeBSD intentionally differ.guest_math.tools/check_conventions.py --base origin/mainpasses.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T11:24:48Z.
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.
docs/dev/debt/libc.mddocs/dev/debt/libc.mdcore/libs/tests/GuestMath.cppdocs/dev/debt/libc.mdcore/libs/prx/libc/src/Math.cppcore/libs/tests/GuestMath.cppcore/libs/prx/libc/src/Math.cppcore/libs/tests/GuestMath.cppcore/libs/prx/libc/src/Math.cppcore/libs/tests/GuestMath.cppcore/libs/prx/libc/src/Math.cppcore/libs/tests/GuestMath.cppcore/libs/prx/libc/src/Math.cppcore/libs/tests/GuestMath.cppdocs/dev/debt/libc.mdcore/libs/prx/libc/src/Math.cppdocs/dev/debt/libc.mdImported from boykopovar/AnyPS5. Originally posted by hypermoist on 2026-10-16T03:15:31Z.
Rebased onto current
main(5d9dcc42d). The conflict was with the new tiny-argument path inlgamma(-log|x|below 2^-56):signgamis now set first and that path is kept unchanged, and both the new subnormal tests and thesigngamtests stay inGuestMath.cpp.guest_mathpasses andcheck_conventions.pyis clean.🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by harmsluis on 2026-10-16T18:59:05Z.
Windows run (Windows 11 build 26300, non-elevated, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON), built targetguest_math_tests:mainc84249186(baseline):guest_mathpasses.20edd079e) merged ontoc84249186without conflicts: builds with no new warnings, andguest_mathpasses 5/5 repeated runs (ctest --repeat until-fail:5).libc.prxexportssigngam_nid_postfixas data (objdump -p). The test sets the variable to 7 before eachlgammacall and reads it through that import, so the sign checks exercise the DLL's variable rather than a local copy.Not covered: the full build, and the patched/NID-renamed
libc.prx.