1 #include "igt_rand.h" 2 3 /** 4 * SECTION:igt_rand 5 * @short_description: Random numbers helper library 6 * @title: Random 7 * @include: igt_rand.h 8 */ 9 10 static uint32_t global = 0x12345678; 11 hars_petruska_f54_1_random_seed(uint32_t new_state)12uint32_t hars_petruska_f54_1_random_seed(uint32_t new_state) 13 { 14 uint32_t old_state = global; 15 global = new_state; 16 return old_state; 17 } 18 hars_petruska_f54_1_random(uint32_t * s)19uint32_t hars_petruska_f54_1_random(uint32_t *s) 20 { 21 #define rol(x,k) ((x << k) | (x >> (32-k))) 22 return *s = (*s ^ rol(*s, 5) ^ rol(*s, 24)) + 0x37798849; 23 #undef rol 24 } 25 hars_petruska_f54_1_random_unsafe(void)26uint32_t hars_petruska_f54_1_random_unsafe(void) 27 { 28 return hars_petruska_f54_1_random(&global); 29 } 30