]> Git Repo - J-u-boot.git/blame - lib/rand.c
board_r: Detect ifc-nor flash at run-time
[J-u-boot.git] / lib / rand.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
9acf1ca5
MW
2/*
3 * Simple xorshift PRNG
4 * see http://www.jstatsoft.org/v08/i14/paper
5 *
6 * Copyright (c) 2012 Michael Walle
7 * Michael Walle <[email protected]>
9acf1ca5
MW
8 */
9
10#include <common.h>
840ef4d4 11#include <rand.h>
9acf1ca5
MW
12
13static unsigned int y = 1U;
14
15unsigned int rand_r(unsigned int *seedp)
16{
17 *seedp ^= (*seedp << 13);
18 *seedp ^= (*seedp >> 17);
19 *seedp ^= (*seedp << 5);
20
21 return *seedp;
22}
23
24unsigned int rand(void)
25{
26 return rand_r(&y);
27}
28
29void srand(unsigned int seed)
30{
31 y = seed;
32}
This page took 0.42899 seconds and 4 git commands to generate.