blob: 38862c12eb320a46b9fcc983cf0b5a1ddc3aaaa7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "internal.h"
static uint32_t next = 1;
static uint32_t seed;
/* Return next random integer */
int32_t rand()
{
next = next * 1103515245L + 12345;
return (uint32_t) (next / 65536L) % 32768L;
}
/* Set seed for random generator */
void srand(seed)
uint32_t seed;
{
next = seed;
}
void srandom(seed)
uint32_t seed;
{
srand(seed);
}
int32_t random()
{
return rand();
}
|