Repository navigation
feat(libc): implement random, srandom, initstate and setstate - #3229
Merged
Merged
Conversation
Port FreeBSD 11 lib/libc/stdlib/random.c (freebsd-src 4ab2e064): the additive feedback generator with the default 128-byte TYPE_3 table, good_rand seeding, state sizes rounded down to 8, 32, 64, 128 or 256 bytes, setstate returning the previous state, and initstate returning null below 8 bytes without setting errno. Calls are serialised by one lock; a null state throws. The import audit of the homebrew catalog on main 262c031 lists them as absent libSceLibcInternal imports: - random: PPSA74126 Stremio Plus, PPSA85300 VLC, PPSA99169 RetroArch, PPSA99177 PS5VR, PPSA99420 PS5MC, PPSA99505 Jelly5, PPSA99515 Emby5, PPSA99810 PSBox Cloud Gaming - srandom: PPSA85300, PPSA99169, PPSA99420, PPSA99810 - initstate, setstate: PPSA99177, PPSA99420, PPSA99505, PPSA99515 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
9 tasks done
Collaborator
Author
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.
What
Carries @screamm's branch from #3164 (
feat/libc-random-state, commitdd2e0716kept as is, with its authorship). Intake is paused for new contributors and the issue asks a maintainer to carry it.It adds the BSD
random,srandom,initstateandsetstate(w1o05aHJT4c,sPC7XE6hfFY,IIUY-5hk-4k,woQta4WRpk0, fromlibSceLibcInternal), following FreeBSD 11lib/libc/stdlib/random.c. Details are in #3164.Titles:
mainf1ae427 for Windows. I relinked the sha256-checked catalog release withrelinker --windows --registryand walked its imports in the order the entry stub resolves them (WindowsEntryStubBuilder, first unresolved import fails). With the bundledlibc.prxsearched as the stub does, the first import nothing exports issetstate. This comes from that walk, not from a run.random,initstateandsetstatetoo, and so do the other titles listed in libc: random, srandom, initstate and setstate are absent imports of eight catalog titles; fix branch ready #3164. They stop earlier, on exports other PRs cover.My commit only moves the TechnicalDebt line from the end of "Functional" to "Unknown function info", next to the other libc lines, since the console's generator isn't verified.
Tested
Linux (CachyOS), GCC 16, Release.
guest_random_statepasses.random.c(releng/11.0), compiled unchanged apart fromsrandomdev, gives the same first values for the default state (1408992891, 1638182910, 83848093, 145962118, 627851256) and forsrandom(12345)(1052984060, 1639322404, 1971525204, 2097956667, 2012147915).good_randconstant, the output shift or the number of seeding rounds each makes the test fail.tools/check_conventions.pypasses.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)