feat(libc): implement rand_r #2216
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2216"
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 reyani-dev on 2026-10-09T11:51:02Z.
What
Exports
rand_r. In FreeBSD,randandrand_rshare one generator step (do_randinlib/libc/stdlib/rand.c):randadvances the global state, andrand_radvances the caller'sunsigned int. This moves the step thatrand_nid_postfixalready implements into an internal helper (NextRand_nid_no_patch, not exported) used by both, sorand_rmatches this libc'srandexactly.rand's behaviour is unchanged. A null state pointer throwsstd::invalid_argument.Title: PPSA99420 PS5MC imports it from
libSceLibcInternal(resolved throughlibc.prx), per the #1578 audit. I haven't run the title.Tested
Windows 11, WinLibs GCC 15.2.0 r7, Release,
-DBUILD_TESTING=ON:guest_math_tests, next totanf:rand_r(&seed)calls equalsrand(seed)followed by eightrand()calls;guest_mathfail.cmake --build build --target libs: the patchedlibc.prxexportsdW3xsu3EgFI(rand_r) and stillcpCOXWMgha0(rand), and the helper isn't exported.tools/check_conventions.pypasses, andtools/pr_overlap.py --branchreports no overlap. It also merges cleanly with #2038 (lrand48/srand48, added just belowsrand), checked withgit merge-tree.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T11:51:25Z.
Progress report (
d70b899→41ddf48)📈 System libraries: 84.7% (+0.01%, +1 implemented functions)
✅ 1 implemented
rand_r_nid_postfixImported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-09T12:12:07Z.
Full Linux and Windows builds and tests for this head (
41ddf48e), using the project's Build workflow. I can't start the upstream manual run, so I ran the samebuild.ymlin my fork through a mirror PR. Like the upstream run, the jobs check out the PR head merged into currentmain(d70b8998):ctest: 516/516 passedctest: 507/507 passedRun: https://github.com/AchrafReyani/AnyPS5/actions/runs/37926277687
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T20:10:10Z.
Same as #2167, for
rand_r.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T00:43:32Z.
@AchrafReyani
rand_ris now a title's next stop onmain. Withtzset(#3124) merged, PS5MC (PPSA99420) onmain06da1176reports this on Linux (catalog build,sce_module/libc.prxunwrapped as #2605 requires):app.elf: symbol lookup error: app.elf: undefined symbol: dW3xsu3EgFIThis head (
41ddf48e) merges cleanly onto06da1176,guest_mathpasses 5/5 (--repeat until-fail:5), and PS5MC then stops atrewind(3QIPIh-GDjw, #1871).Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T00:51:28Z.
Thanks @babyhuey, resubmitted as #3191, rebased onto current
mainwith your stop.Pull request closed