rand.musl #
Copyright (c) 2019-2024 Alexander Medvednikov. All rights reserved. Use of this source code is governed by an MIT license that can be found in the LICENSE file.
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 #
@[inline]
fn (mut rng MuslRNG) u8() u8
u8 returns a uniformly distributed pseudorandom 8-bit unsigned positive u8.
fn (MuslRNG) u16 #
@[inline]
fn (mut rng MuslRNG) u16() u16
u16 returns a pseudorandom 16-bit unsigned integer (u16).
fn (MuslRNG) u32 #
@[ignore_overflow]
fn (mut rng MuslRNG) u32() u32
u32 returns a pseudorandom 32-bit unsigned integer (u32).
fn (MuslRNG) u64 #
@[inline]
fn (mut rng MuslRNG) u64() u64
u64 returns a pseudorandom 64-bit unsigned integer (u64).
fn (MuslRNG) block_size #
@[inline]
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.