u-boot/lib/rand.c
Tom Rini 467382ca03 lib: Remove <common.h> inclusion from these files
After some header file cleanups to add missing include files, remove
common.h from all files in the lib directory. This primarily means just
dropping the line but in a few cases we need to add in other header
files now.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-12-21 08:54:37 -05:00

31 lines
477 B
C

// SPDX-License-Identifier: GPL-2.0+
/*
* Simple xorshift PRNG
* see http://www.jstatsoft.org/v08/i14/paper
*
* Copyright (c) 2012 Michael Walle
* Michael Walle <michael@walle.cc>
*/
#include <rand.h>
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;
}