Add basic support for mini2440 board to barebox.
[barebox-mini2440.git] / lib / random.c
blob352d6bf3f7d9454e99cbcca747fd6a3f2c7e60a1
1 #include <common.h>
2 #include <stdlib.h>
4 static unsigned int random_seed;
6 #if RAND_MAX > 32767
7 #error this rand implementation is for RAND_MAX < 32678 only.
8 #endif
10 unsigned int rand(void)
12 random_seed = random_seed * 1103515245 + 12345;
13 return (random_seed / 65536) % (RAND_MAX + 1);
16 void srand(unsigned int seed)
18 random_seed = seed;
21 void get_random_bytes(char *buf, int len)
23 while (len--)
24 *buf++ = rand() % 256;