Repository navigation
feat(libc): implement rand_r - #3191
Merged
Merged
Conversation
Share rand's generator step with rand_r, which advances the caller's state instead of the global one, as FreeBSD's rand and rand_r share do_rand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 tasks done
Contributor
Author
|
Fork CI for this head merged onto current
|
Contributor
|
Checked with #3190, #3191 and #3192 stacked on PS5MC (PPSA99420) gets past
|
This was referenced Oct 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resubmission of #2216, which was closed because no title was shown stopping on
rand_r. Withtzset(#3124) merged, PS5MC (PPSA99420) now stops atrand_ronmain06da117, 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 feat(libc): implement lrand48 and srand48 #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