]> git.ipfire.org Git - thirdparty/make.git/commit
Implement a simple xorshift 32bit random number generator
authorPaul Smith <psmith@gnu.org>
Mon, 26 Sep 2022 18:38:27 +0000 (14:38 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 1 Oct 2022 15:45:39 +0000 (11:45 -0400)
commita99378ebe46f5245ef1307c6a9834d19d57882d0
tree9a4ff69f870b13b0545fb629dd8112bdabaa5ddd
parent6c87f3fb85311eb845ce437b1d31e8b7443a9233
Implement a simple xorshift 32bit random number generator

Avoid relying on the system random number generator for our random
shuffle, so that the same seed gives the same results on all systems.
This generator doesn't need to be amazing, just pretty good, so don't
bother with xorshift* or xorshift+, etc.

* src/makeint.h: Declare make_seed() and make_rand().
* src/misc.c (make_seed): Set the seed value for the RNG.
(make_rand): Return the next random number.  If the seed was not set
initialize it first.
* src/shuffle.c (shuffle_set_mode): If we don't get a seed from the
user just leave it unset (0).
(shuffle_deps_recursive): Use make_seed() not srand().
(random_shuffle_array): Use make_rand() not rand().
src/makeint.h
src/misc.c
src/shuffle.c