random.h

struct xoshiro256ss_state

A struct keeping the internal state for xoshiro256ss algorithm.

u64 rol64(u64 x, int k)

Rotl function implementation for u64 value.

Parameters
  • x – the number

  • k – a bit count

Returns

the result of rotating the bits of the number to the left by that count.

u64 xoshiro256ss(struct xoshiro256ss_state *state)

xoshiro256** is the family’s general-purpose random 64-bit number generator (xor/shift/rotate).

Details:

Wikipedia — Xorshift

Parameters
  • state – a pointer to xoshiro256ss_state struct

Returns

u64

Notes

The “Scrambled Linear Pseudorandom Number Generators” article by David Blackman and Sebastiano Vigna shows that “static inline” may be needed for “rol64” function, but compiler is already inlining it on -O3.