fix(libc): store the gamma sign in an exported signgam #5495
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5495"
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 Roojool on 2026-10-13T21:06:58Z.
What
lgammanow fills the guestsigngam, which libc also exports.FreeBSD 11's
e_lgamma_r.cderives the sign stored intosigngamfrom the argument alone, and the Windows CRT has nolgamma_r, so that rule is evaluated here:+1at a pole, at the infinities and for NaN,-1for a negative zero and any tiny negative argument, and otherwise, forx < 0, the sign ofsin(pi*x), which is negative exactly whereceil(x)is even. The magnitude still comes from the host'slgamma(last-bit differences from the console's msun code are possible).lgammafandlgammalare not exported in this tree, so no other call fillssigngam.The export follows the library's own convention — every external global is exported and renamed to its NID, here
5gOOC0kzW0c. Thelibc.prxbundled with PPSA59322 and PPSA76677 exports that NID as a 4-byteSTB_GLOBAL/STT_OBJECT, so the console does too. No title available here imports it today; this fixes the libc contract, and the debt entry keeps the caveats:signgamis a plain global, so concurrentlgammacalls and a guest reading it race exactly as they do on FreeBSD, and console behaviour of the whole pair is unverified.Tested
guest_mathgainssigngamassertions aroundlgammacalls with both signs (-0.5→-1,1.5→+1), poles and non-finite inputs. On unmodifiedmainthe extended test fails to link (undefined reference to 'signgam_nid_postfix'); with the change it passes (Windows 4 runs including reruns; WSL Ubuntu 3/3).libc.prxexport table contains5gOOC0kzW0con Windows (objdump) and the ELF shows a 4-byteOBJECT GLOBALon Linux (readelf); the helper that computes the sign stays internal.guest_mathcases and thenid_*patcher tests (6/6) pass; the fulllibstarget with the real NID patcher builds on both platforms.python tools/check_conventions.py --base upstream/mainpasses.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-13T21:07:07Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T04:42:26Z.
Closing: no title is known to reach this. With the queue at 480+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.
Pull request closed