From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/u-boot/lib/rand.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 roms/u-boot/lib/rand.c (limited to 'roms/u-boot/lib/rand.c') diff --git a/roms/u-boot/lib/rand.c b/roms/u-boot/lib/rand.c new file mode 100644 index 000000000..d256baf5c --- /dev/null +++ b/roms/u-boot/lib/rand.c @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Simple xorshift PRNG + * see http://www.jstatsoft.org/v08/i14/paper + * + * Copyright (c) 2012 Michael Walle + * Michael Walle + */ + +#include +#include + +static unsigned int y = 1U; + +unsigned int rand_r(unsigned int *seedp) +{ + *seedp ^= (*seedp << 13); + *seedp ^= (*seedp >> 17); + *seedp ^= (*seedp << 5); + + return *seedp; +} + +unsigned int rand(void) +{ + return rand_r(&y); +} + +void srand(unsigned int seed) +{ + y = seed; +} -- cgit