Skip to content

rand.musl #

Constants #

const seed_len = 1

struct MuslRNG #

struct MuslRNG {
	buffer.PRNGBuffer
mut:
	state u32 = seed.time_seed_32()
}

MuslRNG ported from https://git.musl-libc.org/cgit/musl/tree/src/prng/rand_r.c

fn (MuslRNG) seed #

fn (mut rng MuslRNG) seed(seed_data []u32)

seed sets the current random state based on seed_data. seed expects seed_data to be only one u32.

fn (MuslRNG) u8 #

fn (mut rng MuslRNG) u8() u8

byte returns a uniformly distributed pseudorandom 8-bit unsigned positive byte.

fn (MuslRNG) u16 #

fn (mut rng MuslRNG) u16() u16

u16 returns a pseudorandom 16-bit unsigned integer (u16).

fn (MuslRNG) u32 #

fn (mut rng MuslRNG) u32() u32

u32 returns a pseudorandom 32-bit unsigned integer (u32).

fn (MuslRNG) u64 #

fn (mut rng MuslRNG) u64() u64

u64 returns a pseudorandom 64-bit unsigned integer (u64).

fn (MuslRNG) block_size #

fn (mut rng MuslRNG) block_size() int

block_size returns the number of bits that the RNG can produce in a single iteration.

fn (MuslRNG) free #

unsafe
fn (mut rng MuslRNG) free()

free should be called when the generator is no longer needed