Chris Wilson | 376b813 | 2016-07-03 09:42:38 +0100 | [diff] [blame^] | 1 | #include "igt_rand.h" |
2 | |||||
3 | static uint32_t state = 0x12345678; | ||||
4 | |||||
5 | uint32_t | ||||
6 | hars_petruska_f54_1_random_seed(uint32_t new_state) | ||||
7 | { | ||||
8 | uint32_t old_state = state; | ||||
9 | state = new_state; | ||||
10 | return old_state; | ||||
11 | } | ||||
12 | |||||
13 | uint32_t | ||||
14 | hars_petruska_f54_1_random_unsafe(void) | ||||
15 | { | ||||
16 | #define rol(x,k) ((x << k) | (x >> (32-k))) | ||||
17 | return state = (state ^ rol (state, 5) ^ rol (state, 24)) + 0x37798849; | ||||
18 | #undef rol | ||||
19 | } |