1/* @title: PRNG */
2#pragma once
3#include <stdint.h>
4
5#define PRNG_SPLITMIX64_GAMMA UINT64_C(0x9e3779b97f4a7c15)
6#define PRNG_SPLITMIX64_M1 UINT64_C(0xbf58476d1ce4e5b9)
7#define PRNG_SPLITMIX64_M2 UINT64_C(0x94d049bb133111eb)
8
9static inline uint64_t prng_splitmix64_next(uint64_t *state) {
10 uint64_t z = (*state += PRNG_SPLITMIX64_GAMMA);
11 z = (z ^ (z >> 30)) * PRNG_SPLITMIX64_M1;
12 z = (z ^ (z >> 27)) * PRNG_SPLITMIX64_M2;
13 return z ^ (z >> 31);
14}
15
16void prng_seed(uint64_t seed);
17uint64_t prng_next(void);
18