docs(libc): record PS5 measurements of rand, rand_r and drand48 #16613
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16613"
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 xXPBSXx on 2026-11-07T09:32:19Z.
What
The
rand,srandandrand_rentry says the generator was read from disassembly of three titles'libc.prxand not measured on a console, and that the console's system libc has a different generator (reported from a PS4 Pro). This records what the system modulelibSceLibcInternalof a PS5 returned in a payload process:randaftersrandwith six seeds andrand_rfrom five states gave exactly the values AnyPS5 computes, andsrand48(1)followed by threedrand48calls gave the same bit patterns. The entries now say so. The PS4 Pro report stays as a report; a title process and a title's ownlibc.prxare not measured. This matchesMath.cppandRandom.cpp, so no code changes.Tested
Measured on a PS5 with firmware 11.60 (
kernel_get_fw_version0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr), on 2026-11-07 at 04:28 UTC. A title process may differ. The expected values come from the formulas inMath.cpp:3934-3948(rand,srand,rand_r) andRandom.cpp:100-140(drand48,srand48), evaluated with a script over the raw output.mainrand()x3, fresh process, and aftersrand(1)srand(0);rand()x3srand(0x2a);rand()x3srand(0x7fffffff);rand()x3srand(0x80000000);rand()x3srand(0xffffffff);rand()x3rand_rfrom states 0x1, 0x0, 0x3039, 0x7fffffff, 0x80000000, two calls eachsrand48(1);drand48()x3, raw double bitsThe probe also ran
random,srandom,initstate,setstate,erand48and a 1000-calldrand48test; those results are in the raw output but were not compared with AnyPS5 and are not part of this change. The probe source and its raw output are in the first comment.tools/check_conventions.py --base upstream/mainpasses.Overlap: the 125 open pull requests that change
docs/dev/debt/libc.mdwere checked on 2026-11-07 at 05:42 UTC againstmain4ba64592376: 28 already conflicted withmainin that file without this change. #9677, #8417 and #7544 conflict in that file only with this change, although none of them edits therand,srand,rand_r,drand48orerand48entry. Between 08:50 UTC and 09:00 UTC the pull requests that change that file and were updated since 05:30 UTC were checked again againstmain05129d2c4e: the same three are the only ones that conflict with this change but not withmain.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)AI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T21:55:51Z.
Review: COMMENTED
Docs check of head
5f566a6906againstmain0bae53facd: I compared what the entry says about the code with the code, and checked the links and counts. I can't check the console measurements themselves.rand_rstill multiplies by 16807 (Math.cpp:3991). The new measurement is of the systemlibSceLibcInternal, and the entry keeps it separate from the bundledlibc.prxthe code follows.