feat(libc): implement lrand48 and srand48 #2038
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2038"
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 Aryansh1520 on 2026-10-09T05:36:54Z.
What
PPSA28997 (God of War Sons of Sparta) imports
lrand48andsrand48. They follow FreeBSD libc:a = 0x5DEECE66D,c = 0xB0x1234ABCD330Esrand48sets the high 32 bits of the state from the seed and the low 16 bits to0x330Elrand48returns the top 31 bitsThe state shares the lock used by
rand. The guest'slongis 64-bit, so both functions usestd::int64_t.Tested
tools/check_conventions.py --base origin/mainandtools/pr_overlap.py --branchpass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T05:57:51Z.
Please add guest_math cases for known srand48/lrand48 sequences (for example, seed 0), reseeding, and independence from rand/srand state. These would catch a wrong mask, shift, or shared-state regression. I built exact head
9f51a0c1on Linux with GCC 12; the existing guest_math passed 1/1 in 0.01 s and conventions passed, but it does not cover the new sequence. GitHub reports no checks on this head.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:53Z.
Where does PPSA28997 stop on main without this? Please add that log line to the description.
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T10:36:53Z.
Added
guest_mathcases infdc6d0d9:0x1234ABCD330E(851401618, 1804928587, 758783491)srand48with 0, 1, -1 and a seed above 32 bits, where only the low 32 bits count. These match host glibc'ssrand48/lrand48(glibc differs only in its unseeded state)srand/randandsrand48/lrand48don't affect each other in either directionMutation check: a shift of 16 instead of 17, low bits other than
0x330E, a zero initial state, andsrand48also writing therandstate each makeguest_mathfail.On where PPSA28997 stops:
lrand48andsrand48are imported byIl2cppUserAssemblies.prx. I found them in its unresolved imports and implemented them before a run reached them, so I don't have a stop log line for them. On main (as of Oct 8) the title stops earlier, atLTov9gMEqCU(std::ios_base::_Addstd, #545).The build workflows on this head are waiting for approval to run (fork PR).
Imported from boykopovar/AnyPS5. Originally posted by Aryansh1520 on 2026-10-09T10:53:16Z.
Moved the new checks out of
GuestMath.cppinto their own test,GuestRand48.cpp(guest_rand48), incf569548. This PR no longer touchesGuestMath.cpp, so it no longer overlaps #1818 or #2037. The checks are unchanged.Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T15:46:31Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
cf569548, merged ontomaind70b8998in one build with 38 other PRs that had no Windows run.guest_rand48. None of them reported skipping a case.No title was run.
🤖 Addressed by Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:08:32Z.
Same as #2037: PPSA28997 stops at
LTov9gMEqCUbeforelrand48/srand48on main. Please reopen with the log line when it reaches them.Pull request closed