feat(libc): implement rand_r #3191
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3191"
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-11T00:51:26Z.
Resubmission of #2216, which was closed because no title was shown stopping on
rand_r. Withtzset(#3124) merged, PS5MC (PPSA99420) now stops atrand_ronmain06da1176, per @babyhuey's catalog run withsce_module/libc.prxunwrapped (comment):dW3xsu3EgFIisrand_r. With this change the title moves on torewind(3QIPIh-GDjw, #1871), per the same run.rand_ris still absent on currentmain, and no open PR implements it. The branch is rebased onto currentmain. Windows 11 (WinLibs GCC 15.2.0), Release:guest_mathpasses 3/3, andcheck_conventions.pyandpr_overlap.py --branchpass.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-11T00:51:44Z.
Progress report (
06da117→86db61c)➖ System libraries: 85.96% (+0.0%, +1 implemented functions)
✅ 1 implemented
rand_r_nid_postfixImported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T01:18:20Z.
Fork CI for this head merged onto current
main(run 38099847203):agc_unit_shadow,agc_driver_flat_apertures(timeout) andagc_driver_image_packed16_load, which fail identically inmain's own push build (run 38098335801). This PR only touches libc, so they're unrelated.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T01:36:59Z.
Checked with #3190, #3191 and #3192 stacked on
maind31b57a4(all merge cleanly), catalog builds withsce_module/libc.prxunwrapped. Linux (Ubuntu 24.04, GCC 13) and Windows 11 (WinLibs GCC 15.2), Release:guest_mathandguest_stringspass 5/5 (--repeat until-fail:5) on both, with no warnings inMath.cpporStringExtensions.cpp.PS5MC (PPSA99420) gets past
rand_ron both and stops atsetstate:app.elf: symbol lookup error: app.elf: undefined symbol: woQta4WRpk0FAIL: unresolved ELF import woQta4WRpk0 (setstate) from libSceLibcInternal.prx