blob: a3298a9f25e66ff7740afc845a0927aa249f8b56 [file] [log] [blame]
Chris Wilson376b8132016-07-03 09:42:38 +01001#include "igt_rand.h"
2
3static uint32_t state = 0x12345678;
4
5uint32_t
6hars_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
13uint32_t
14hars_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}