Commit 8d56e472c9
Changed files (34)
lib
compiler_rt
std
hash
io
math
big
Random
Thread
src
resinator
lib/compiler_rt/paritydi2_test.zig
@@ -26,7 +26,7 @@ test "paritydi2" {
try test__paritydi2(@bitCast(@as(u64, 0xffffffff_fffffffe)));
try test__paritydi2(@bitCast(@as(u64, 0xffffffff_ffffffff)));
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: u32 = 0;
while (i < 10_000) : (i += 1) {
lib/compiler_rt/paritysi2_test.zig
@@ -26,7 +26,7 @@ test "paritysi2" {
try test__paritysi2(@bitCast(@as(u32, 0xfffffffe)));
try test__paritysi2(@bitCast(@as(u32, 0xffffffff)));
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: u32 = 0;
while (i < 10_000) : (i += 1) {
lib/compiler_rt/parityti2_test.zig
@@ -26,7 +26,7 @@ test "parityti2" {
try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe)));
try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff)));
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: u32 = 0;
while (i < 10_000) : (i += 1) {
lib/compiler_rt/popcountdi2_test.zig
@@ -25,7 +25,7 @@ test "popcountdi2" {
try test__popcountdi2(@as(i64, @bitCast(@as(u64, 0xffffffff_fffffffe))));
try test__popcountdi2(@as(i64, @bitCast(@as(u64, 0xffffffff_ffffffff))));
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: u32 = 0;
while (i < 10_000) : (i += 1) {
lib/compiler_rt/popcountsi2_test.zig
@@ -25,7 +25,7 @@ test "popcountsi2" {
try test__popcountsi2(@as(i32, @bitCast(@as(u32, 0xfffffffe))));
try test__popcountsi2(@as(i32, @bitCast(@as(u32, 0xffffffff))));
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: u32 = 0;
while (i < 10_000) : (i += 1) {
lib/compiler_rt/popcountti2_test.zig
@@ -25,7 +25,7 @@ test "popcountti2" {
try test__popcountti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))));
try test__popcountti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))));
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: u32 = 0;
while (i < 10_000) : (i += 1) {
lib/compiler_rt/udivmodei4.zig
@@ -132,7 +132,7 @@ test "__udivei4/__umodei4" {
if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
- const RndGen = std.rand.DefaultPrng;
+ const RndGen = std.Random.DefaultPrng;
var rnd = RndGen.init(42);
var i: usize = 10000;
while (i > 0) : (i -= 1) {
lib/std/crypto/benchmark.zig
@@ -10,7 +10,7 @@ const crypto = std.crypto;
const KiB = 1024;
const MiB = 1024 * KiB;
-var prng = std.rand.DefaultPrng.init(0);
+var prng = std.Random.DefaultPrng.init(0);
const random = prng.random();
const Crypto = struct {
lib/std/crypto/kyber_d00.zig
@@ -110,7 +110,7 @@ const assert = std.debug.assert;
const crypto = std.crypto;
const math = std.math;
const mem = std.mem;
-const RndGen = std.rand.DefaultPrng;
+const RndGen = std.Random.DefaultPrng;
const sha3 = crypto.hash.sha3;
// Q is the parameter q ≡ 3329 = 2¹¹ + 2¹⁰ + 2⁸ + 1.
lib/std/crypto/tlcsprng.zig
@@ -10,7 +10,7 @@ const os = std.os;
/// We use this as a layer of indirection because global const pointers cannot
/// point to thread-local variables.
-pub const interface = std.rand.Random{
+pub const interface = std.Random{
.ptr = undefined,
.fillFn = tlsCsprngFill,
};
@@ -43,7 +43,7 @@ const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
}) orelse true;
const is_haiku = builtin.os.tag == .haiku;
-const Rng = std.rand.DefaultCsprng;
+const Rng = std.Random.DefaultCsprng;
const Context = struct {
init_state: enum(u8) { uninitialized = 0, initialized, failed },
lib/std/hash/benchmark.zig
@@ -10,7 +10,7 @@ const KiB = 1024;
const MiB = 1024 * KiB;
const GiB = 1024 * MiB;
-var prng = std.rand.DefaultPrng.init(0);
+var prng = std.Random.DefaultPrng.init(0);
const random = prng.random();
const Hash = struct {
lib/std/heap/arena_allocator.zig
@@ -250,7 +250,7 @@ test "ArenaAllocator (reset with preheating)" {
var arena_allocator = ArenaAllocator.init(std.testing.allocator);
defer arena_allocator.deinit();
// provides some variance in the allocated data
- var rng_src = std.rand.DefaultPrng.init(19930913);
+ var rng_src = std.Random.DefaultPrng.init(19930913);
const random = rng_src.random();
var rounds: usize = 25;
while (rounds > 0) {
lib/std/io/test.zig
@@ -1,6 +1,6 @@
const std = @import("std");
const io = std.io;
-const DefaultPrng = std.rand.DefaultPrng;
+const DefaultPrng = std.Random.DefaultPrng;
const expect = std.testing.expect;
const expectEqual = std.testing.expectEqual;
const expectError = std.testing.expectError;
lib/std/math/big/rational.zig
@@ -594,7 +594,7 @@ test "big.rational toFloat" {
test "big.rational set/to Float round-trip" {
var a = try Rational.init(testing.allocator);
defer a.deinit();
- var prng = std.rand.DefaultPrng.init(0x5EED);
+ var prng = std.Random.DefaultPrng.init(0x5EED);
const random = prng.random();
var i: usize = 0;
while (i < 512) : (i += 1) {
lib/std/Random/Ascon.zig
@@ -10,7 +10,6 @@
const std = @import("std");
const mem = std.mem;
-const Random = std.rand.Random;
const Self = @This();
const Ascon = std.crypto.core.Ascon(.little);
@@ -39,9 +38,9 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void {
self.state.permute();
}
-/// Returns a `std.rand.Random` structure backed by the current RNG.
-pub fn random(self: *Self) Random {
- return Random.init(self, fill);
+/// Returns a `std.Random` structure backed by the current RNG.
+pub fn random(self: *Self) std.Random {
+ return std.Random.init(self, fill);
}
/// Fills the buffer with random bytes.
lib/std/Random/benchmark.zig
@@ -4,7 +4,7 @@ const std = @import("std");
const builtin = @import("builtin");
const time = std.time;
const Timer = time.Timer;
-const rand = std.rand;
+const Random = std.Random;
const KiB = 1024;
const MiB = 1024 * KiB;
@@ -19,32 +19,32 @@ const Rng = struct {
const prngs = [_]Rng{
Rng{
- .ty = rand.Isaac64,
+ .ty = Random.Isaac64,
.name = "isaac64",
.init_u64 = 0,
},
Rng{
- .ty = rand.Pcg,
+ .ty = Random.Pcg,
.name = "pcg",
.init_u64 = 0,
},
Rng{
- .ty = rand.RomuTrio,
+ .ty = Random.RomuTrio,
.name = "romutrio",
.init_u64 = 0,
},
Rng{
- .ty = std.rand.Sfc64,
+ .ty = Random.Sfc64,
.name = "sfc64",
.init_u64 = 0,
},
Rng{
- .ty = std.rand.Xoroshiro128,
+ .ty = Random.Xoroshiro128,
.name = "xoroshiro128",
.init_u64 = 0,
},
Rng{
- .ty = std.rand.Xoshiro256,
+ .ty = Random.Xoshiro256,
.name = "xoshiro256",
.init_u64 = 0,
},
@@ -52,12 +52,12 @@ const prngs = [_]Rng{
const csprngs = [_]Rng{
Rng{
- .ty = rand.Ascon,
+ .ty = Random.Ascon,
.name = "ascon",
.init_u8s = &[_]u8{0} ** 32,
},
Rng{
- .ty = rand.ChaCha,
+ .ty = Random.ChaCha,
.name = "chacha",
.init_u8s = &[_]u8{0} ** 32,
},
lib/std/Random/ChaCha.zig
@@ -5,7 +5,6 @@
const std = @import("std");
const mem = std.mem;
-const Random = std.rand.Random;
const Self = @This();
const Cipher = std.crypto.stream.chacha.ChaCha8IETF;
@@ -53,9 +52,9 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void {
self.refill();
}
-/// Returns a `std.rand.Random` structure backed by the current RNG.
-pub fn random(self: *Self) Random {
- return Random.init(self, fill);
+/// Returns a `std.Random` structure backed by the current RNG.
+pub fn random(self: *Self) std.Random {
+ return std.Random.init(self, fill);
}
// Refills the buffer with random bytes, overwriting the previous key.
lib/std/Random/Isaac64.zig
@@ -4,7 +4,6 @@
//! https://doc.rust-lang.org/rand/src/rand/prng/isaac64.rs.html
const std = @import("std");
-const Random = std.rand.Random;
const mem = std.mem;
const Isaac64 = @This();
@@ -30,8 +29,8 @@ pub fn init(init_s: u64) Isaac64 {
return isaac;
}
-pub fn random(self: *Isaac64) Random {
- return Random.init(self, fill);
+pub fn random(self: *Isaac64) std.Random {
+ return std.Random.init(self, fill);
}
fn step(self: *Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void {
lib/std/Random/Pcg.zig
@@ -3,7 +3,6 @@
//! PRNG
const std = @import("std");
-const Random = std.rand.Random;
const Pcg = @This();
const default_multiplier = 6364136223846793005;
@@ -21,8 +20,8 @@ pub fn init(init_s: u64) Pcg {
return pcg;
}
-pub fn random(self: *Pcg) Random {
- return Random.init(self, fill);
+pub fn random(self: *Pcg) std.Random {
+ return std.Random.init(self, fill);
}
fn next(self: *Pcg) u32 {
@@ -37,7 +36,7 @@ fn next(self: *Pcg) u32 {
fn seed(self: *Pcg, init_s: u64) void {
// Pcg requires 128-bits of seed.
- var gen = std.rand.SplitMix64.init(init_s);
+ var gen = std.Random.SplitMix64.init(init_s);
self.seedTwo(gen.next(), gen.next());
}
lib/std/Random/RomuTrio.zig
@@ -3,7 +3,6 @@
// Beware: this PRNG is trivially predictable. While fast, it should *never* be used for cryptographic purposes.
const std = @import("std");
-const Random = std.rand.Random;
const math = std.math;
const RomuTrio = @This();
@@ -17,8 +16,8 @@ pub fn init(init_s: u64) RomuTrio {
return x;
}
-pub fn random(self: *RomuTrio) Random {
- return Random.init(self, fill);
+pub fn random(self: *RomuTrio) std.Random {
+ return std.Random.init(self, fill);
}
fn next(self: *RomuTrio) u64 {
@@ -42,7 +41,7 @@ pub fn seedWithBuf(self: *RomuTrio, buf: [24]u8) void {
pub fn seed(self: *RomuTrio, init_s: u64) void {
// RomuTrio requires 192-bits of seed.
- var gen = std.rand.SplitMix64.init(init_s);
+ var gen = std.Random.SplitMix64.init(init_s);
self.x_state = gen.next();
self.y_state = gen.next();
lib/std/Random/Sfc64.zig
@@ -3,7 +3,6 @@
//! See http://pracrand.sourceforge.net/
const std = @import("std");
-const Random = std.rand.Random;
const math = std.math;
const Sfc64 = @This();
@@ -23,8 +22,8 @@ pub fn init(init_s: u64) Sfc64 {
return x;
}
-pub fn random(self: *Sfc64) Random {
- return Random.init(self, fill);
+pub fn random(self: *Sfc64) std.Random {
+ return std.Random.init(self, fill);
}
fn next(self: *Sfc64) u64 {
lib/std/Random/Xoroshiro128.zig
@@ -3,7 +3,6 @@
//! PRNG
const std = @import("std");
-const Random = std.rand.Random;
const math = std.math;
const Xoroshiro128 = @This();
@@ -16,8 +15,8 @@ pub fn init(init_s: u64) Xoroshiro128 {
return x;
}
-pub fn random(self: *Xoroshiro128) Random {
- return Random.init(self, fill);
+pub fn random(self: *Xoroshiro128) std.Random {
+ return std.Random.init(self, fill);
}
pub fn next(self: *Xoroshiro128) u64 {
@@ -59,7 +58,7 @@ pub fn jump(self: *Xoroshiro128) void {
pub fn seed(self: *Xoroshiro128, init_s: u64) void {
// Xoroshiro requires 128-bits of seed.
- var gen = std.rand.SplitMix64.init(init_s);
+ var gen = std.Random.SplitMix64.init(init_s);
self.s[0] = gen.next();
self.s[1] = gen.next();
lib/std/Random/Xoshiro256.zig
@@ -3,7 +3,6 @@
//! PRNG
const std = @import("std");
-const Random = std.rand.Random;
const math = std.math;
const Xoshiro256 = @This();
@@ -18,8 +17,8 @@ pub fn init(init_s: u64) Xoshiro256 {
return x;
}
-pub fn random(self: *Xoshiro256) Random {
- return Random.init(self, fill);
+pub fn random(self: *Xoshiro256) std.Random {
+ return std.Random.init(self, fill);
}
pub fn next(self: *Xoshiro256) u64 {
@@ -57,7 +56,7 @@ pub fn jump(self: *Xoshiro256) void {
pub fn seed(self: *Xoshiro256, init_s: u64) void {
// Xoshiro requires 256-bits of seed.
- var gen = std.rand.SplitMix64.init(init_s);
+ var gen = std.Random.SplitMix64.init(init_s);
self.s[0] = gen.next();
self.s[1] = gen.next();
lib/std/Random/ziggurat.zig
@@ -10,7 +10,7 @@
const std = @import("../std.zig");
const builtin = @import("builtin");
const math = std.math;
-const Random = std.rand.Random;
+const Random = std.Random;
pub fn next_f64(random: Random, comptime tables: ZigTable) f64 {
while (true) {
@@ -127,7 +127,7 @@ pub fn norm_zero_case(random: Random, u: f64) f64 {
}
test "normal dist sanity" {
- var prng = std.rand.DefaultPrng.init(0);
+ var prng = Random.DefaultPrng.init(0);
const random = prng.random();
var i: usize = 0;
@@ -156,7 +156,7 @@ pub fn exp_zero_case(random: Random, _: f64) f64 {
}
test "exp dist smoke test" {
- var prng = std.rand.DefaultPrng.init(0);
+ var prng = Random.DefaultPrng.init(0);
const random = prng.random();
var i: usize = 0;
lib/std/Thread/RwLock.zig
@@ -328,7 +328,7 @@ test "RwLock - concurrent access" {
}
fn writer(self: *Self, thread_idx: usize) !void {
- var prng = std.rand.DefaultPrng.init(thread_idx);
+ var prng = std.Random.DefaultPrng.init(thread_idx);
var rnd = prng.random();
while (true) {
lib/std/hash_map.zig
@@ -1884,7 +1884,7 @@ test "std.hash_map put and remove loop in random order" {
while (i < size) : (i += 1) {
try keys.append(i);
}
- var prng = std.rand.DefaultPrng.init(0);
+ var prng = std.Random.DefaultPrng.init(0);
const random = prng.random();
while (i < iterations) : (i += 1) {
@@ -1916,7 +1916,7 @@ test "std.hash_map remove one million elements in random order" {
keys.append(i) catch unreachable;
}
- var prng = std.rand.DefaultPrng.init(0);
+ var prng = std.Random.DefaultPrng.init(0);
const random = prng.random();
random.shuffle(u32, keys.items);
lib/std/mem.zig
@@ -4423,7 +4423,7 @@ test "read/write(Var)PackedInt" {
const foreign_endian: Endian = if (native_endian == .big) .little else .big;
const expect = std.testing.expect;
- var prng = std.rand.DefaultPrng.init(1234);
+ var prng = std.Random.DefaultPrng.init(1234);
const random = prng.random();
@setEvalBranchQuota(10_000);
lib/std/priority_dequeue.zig
@@ -866,7 +866,7 @@ test "std.PriorityDequeue: shrinkAndFree" {
}
test "std.PriorityDequeue: fuzz testing min" {
- var prng = std.rand.DefaultPrng.init(0x12345678);
+ var prng = std.Random.DefaultPrng.init(0x12345678);
const random = prng.random();
const test_case_count = 100;
@@ -878,7 +878,7 @@ test "std.PriorityDequeue: fuzz testing min" {
}
}
-fn fuzzTestMin(rng: std.rand.Random, comptime queue_size: usize) !void {
+fn fuzzTestMin(rng: std.Random, comptime queue_size: usize) !void {
const allocator = testing.allocator;
const items = try generateRandomSlice(allocator, rng, queue_size);
@@ -895,7 +895,7 @@ fn fuzzTestMin(rng: std.rand.Random, comptime queue_size: usize) !void {
}
test "std.PriorityDequeue: fuzz testing max" {
- var prng = std.rand.DefaultPrng.init(0x87654321);
+ var prng = std.Random.DefaultPrng.init(0x87654321);
const random = prng.random();
const test_case_count = 100;
@@ -907,7 +907,7 @@ test "std.PriorityDequeue: fuzz testing max" {
}
}
-fn fuzzTestMax(rng: std.rand.Random, queue_size: usize) !void {
+fn fuzzTestMax(rng: std.Random, queue_size: usize) !void {
const allocator = testing.allocator;
const items = try generateRandomSlice(allocator, rng, queue_size);
@@ -924,7 +924,7 @@ fn fuzzTestMax(rng: std.rand.Random, queue_size: usize) !void {
}
test "std.PriorityDequeue: fuzz testing min and max" {
- var prng = std.rand.DefaultPrng.init(0x87654321);
+ var prng = std.Random.DefaultPrng.init(0x87654321);
const random = prng.random();
const test_case_count = 100;
@@ -936,7 +936,7 @@ test "std.PriorityDequeue: fuzz testing min and max" {
}
}
-fn fuzzTestMinMax(rng: std.rand.Random, queue_size: usize) !void {
+fn fuzzTestMinMax(rng: std.Random, queue_size: usize) !void {
const allocator = testing.allocator;
const items = try generateRandomSlice(allocator, rng, queue_size);
@@ -963,7 +963,7 @@ fn fuzzTestMinMax(rng: std.rand.Random, queue_size: usize) !void {
}
}
-fn generateRandomSlice(allocator: std.mem.Allocator, rng: std.rand.Random, size: usize) ![]u32 {
+fn generateRandomSlice(allocator: std.mem.Allocator, rng: std.Random, size: usize) ![]u32 {
var array = std.ArrayList(u32).init(allocator);
try array.ensureTotalCapacity(size);
lib/std/Random.zig
@@ -380,7 +380,7 @@ pub fn shuffleWithIndex(r: Random, comptime T: type, buf: []T, comptime Index: t
///
/// This is useful for selecting an item from a slice where weights are not equal.
/// `T` must be a numeric type capable of holding the sum of `proportions`.
-pub fn weightedIndex(r: std.rand.Random, comptime T: type, proportions: []const T) usize {
+pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize {
// This implementation works by summing the proportions and picking a
// random point in [0, sum). We then loop over the proportions,
// accumulating until our accumulator is greater than the random point.
lib/std/sort.zig
@@ -379,7 +379,7 @@ test "sort with context in the middle of a slice" {
}
test "sort fuzz testing" {
- var prng = std.rand.DefaultPrng.init(0x12345678);
+ var prng = std.Random.DefaultPrng.init(0x12345678);
const random = prng.random();
const test_case_count = 10;
lib/std/treap.zig
@@ -18,7 +18,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
/// A customized pseudo random number generator for the treap.
/// This just helps reducing the memory size of the treap itself
- /// as std.rand.DefaultPrng requires larger state (while producing better entropy for randomness to be fair).
+ /// as std.Random.DefaultPrng requires larger state (while producing better entropy for randomness to be fair).
const Prng = struct {
xorshift: usize = 0,
@@ -305,7 +305,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
// https://lemire.me/blog/2017/09/18/visiting-all-values-in-an-array-exactly-once-in-random-order/
fn SliceIterRandomOrder(comptime T: type) type {
return struct {
- rng: std.rand.Random,
+ rng: std.Random,
slice: []T,
index: usize = undefined,
offset: usize = undefined,
@@ -313,7 +313,7 @@ fn SliceIterRandomOrder(comptime T: type) type {
const Self = @This();
- pub fn init(slice: []T, rng: std.rand.Random) Self {
+ pub fn init(slice: []T, rng: std.Random) Self {
return Self{
.rng = rng,
.slice = slice,
@@ -353,7 +353,7 @@ test "std.Treap: insert, find, replace, remove" {
var treap = TestTreap{};
var nodes: [10]TestNode = undefined;
- var prng = std.rand.DefaultPrng.init(0xdeadbeef);
+ var prng = std.Random.DefaultPrng.init(0xdeadbeef);
var iter = SliceIterRandomOrder(TestNode).init(&nodes, prng.random());
// insert check
lib/build_runner.zig
@@ -420,7 +420,7 @@ fn runStepNames(
const starting_steps = try arena.dupe(*Step, step_stack.keys());
- var rng = std.rand.DefaultPrng.init(seed);
+ var rng = std.Random.DefaultPrng.init(seed);
const rand = rng.random();
rand.shuffle(*Step, starting_steps);
@@ -836,7 +836,7 @@ fn constructGraphAndCheckForDependencyLoop(
b: *std.Build,
s: *Step,
step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void),
- rand: std.rand.Random,
+ rand: std.Random,
) !void {
switch (s.state) {
.precheck_started => {
src/resinator/compile.zig
@@ -3356,7 +3356,7 @@ test "StringTable" {
}
break :ids buf;
};
- var prng = std.rand.DefaultPrng.init(0);
+ var prng = std.Random.DefaultPrng.init(0);
var random = prng.random();
random.shuffle(u16, &ids);
src/reduce.zig
@@ -136,7 +136,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
var more_fixups: Ast.Fixups = .{};
defer more_fixups.deinit(gpa);
- var rng = std.rand.DefaultPrng.init(seed);
+ var rng = std.Random.DefaultPrng.init(seed);
// 1. Walk the AST of the source file looking for independent
// reductions and collecting them all into an array list.
@@ -274,7 +274,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
return std.process.cleanExit();
}
-fn sortTransformations(transformations: []Walk.Transformation, rng: std.rand.Random) void {
+fn sortTransformations(transformations: []Walk.Transformation, rng: std.Random) void {
rng.shuffle(Walk.Transformation, transformations);
// Stable sort based on priority to keep randomness as the secondary sort.
// TODO: introduce transformation priorities