OurOS 0.1
Operating System built by McGill Students
 
Loading...
Searching...
No Matches
rand.h
1/*
2 * MT19937 random number generator seeded with timestamp counter and x86
3 * entropy sourcing instructions.
4 */
5
6#ifndef _SYS_RAND_H
7#define _SYS_RAND_H
8
9#include <stdint.h>
10
11#define MT19937_VECTOR_LEN 624
12
13typedef struct {
14 uint32_t vector[MT19937_VECTOR_LEN];
15 int index;
16} mt19937_state;
17
18/*
19 * Initialize the MT19937 random number generator at *state
20 */
21void mt19937_init(mt19937_state *state, uint32_t seed);
22
23/*
24 * Get a random, uniformally distributed 32-bit value from the MT19937 random
25 * number generator at *state
26 */
27uint32_t mt19937_gen32(mt19937_state *state);
28
29/*
30 * Seed the global random number generator
31 */
32void srand(uint32_t seed);
33
34/*
35 * Get a random, uniformally distributed 32-bit value
36 */
37uint32_t rand(void);
38
39#endif