tiny.stabilizer.Marsaglia
Defined in tiny.stabilizer.
API (8)
Actions
Public operations.
Fields and members
Public fields and members.
Source
Source: lib/stabilizer/src/rng.zig:3
zig
pub const Marsaglia = struct { state: u32, cached: u32 = 0, byte_index: u3 = 4, pub fn init(seed: u64) Marsaglia { const folded = @as(u32, @truncate(seed)) ^ @as(u32, @truncate(seed >> 32)); return .{ .state = if (folded == 0) 0x6d2b_79f5 else folded }; } pub fn nextU32(self: *Marsaglia) u32 { var x = self.state; x ^= x << 13; x ^= x >> 17; x ^= x << 5; self.state = if (x == 0) 0x6d2b_79f5 else x; return self.state; } pub fn nextU64(self: *Marsaglia) u64 { return (@as(u64, self.nextU32()) << 32) | self.nextU32(); } pub fn bounded(self: *Marsaglia, upper: usize) usize { std.debug.assert(upper > 0); return @intCast(self.nextU64() % upper); } pub fn nextByte(self: *Marsaglia) u8 { if (self.byte_index >= 4) { self.cached = self.nextU32(); self.byte_index = 0; } const shift: u5 = @intCast(@as(u16, self.byte_index) * 8); const byte: u8 = @truncate(self.cached >> shift); self.byte_index += 1; return byte; }};Source: lib/stabilizer/src/root.zig:52
zig
pub const Marsaglia = rng_mod.Marsaglia;Complete caller list for Marsaglia.init
9 direct callers.
tiny.stabilizer.CodeRandomizer.init[function] atlib/stabilizer/src/code.zig:95tiny.stabilizer.ShuffleAllocator.init[function] atlib/stabilizer/src/heap.zig:84lib.stabilizer.src.properties.runtime.StackPadRegistryProperty.property[function] — private source atlib/stabilizer/src/properties/runtime.zig:69in nearest public ownerlib.stabilizer.src.properties.runtimelib.stabilizer.src.properties.stack.StackProperty.property[function] — private source atlib/stabilizer/src/properties/stack.zig:177in nearest public ownerlib.stabilizer.src.properties.stacklib.stabilizer.src.properties.stack.test_runtime_refills_stack_pads_only_before_code_functions_register[function] — test source atlib/stabilizer/src/properties/stack.zig:93in nearest public ownerlib.stabilizer.src.properties.stacklib.stabilizer.src.properties.stack.test_stack_config_preserves_upstream_sixteen_byte_multiplier[function] — test source atlib/stabilizer/src/properties/stack.zig:59in nearest public ownerlib.stabilizer.src.properties.stacktiny.stabilizer.Runtime.init[function] atlib/stabilizer/src/runtime.zig:24lib.stabilizer.src.runtime.test_runtime_rerandomizeAt_preserves_instruction_pointer_in_stack-only_mode[function] — test source atlib/stabilizer/src/runtime.zig:209in nearest public ownerlib.stabilizer.src.runtimelib.stabilizer.src.runtime.test_runtime_rerandomizes_registered_stack_pad_slots[function] — test source atlib/stabilizer/src/runtime.zig:157in nearest public ownerlib.stabilizer.src.runtime
Audit
| Definitions | 6 |
|---|---|
| Public names | 6 |
| Members | 3 |
| Version | 26.7.0 |
| Revision | daab053ee433 |