Replace usage of rand_r with nrand48 #817
Merged
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.
This replaces the call to
rand_r
withnrand48
and changesrand_seed
to be an array instead of an unsigned int.With
rand_r
being deprecated in POSIX 2024, the best replacement isnrand48
, which stores its intermediate values as a 48-bit integer in an array of shorts instead of an unsigned int and returns a 32-bit value not constrained byRAND_MAX
.nrand48
has been in the POSIX spec. since 2004 and on the large UNIX systems since SVr4. Only things that could be affected are BSDs older than ~2004, but those are presumably old enough that we can ignore them.bin/package test
returned with all tests passing (particularly tests/subshell.sh and tests/variables.sh) and monkey testing shows getting and settingRANDOM
works.