GK SDK 源码库: XMIPCLinuxV100R005C00SPC030 (kernel/tools/open_source excluded)
This commit is contained in:
@@ -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 <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;
|
||||
}
|
||||
Reference in New Issue
Block a user