mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-08 22:24:32 +00:00
840ef4d43b
Create a new rand.h header file and move functions into it, to reduce the size of common.h Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
32 lines
497 B
C
32 lines
497 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 <common.h>
|
|
#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;
|
|
}
|