authorgravatar for git@e4m2.come4m2 <git@e4m2.com> 2024-02-08 15:21:35+01:00
committergravatar for git@e4m2.come4m2 <git@e4m2.com> 2024-02-08 15:21:35+01:00
log8d56e472c9fa97dc6eeae9866eed927910f7dfe2
tree76886b87aee7e499e51b9852701c4ebb75dd135d
parent9af077d71eaf2c004d63405fc5c017e237cb9c6c

Replace std.rand references with std.Random


34 files changed, 71 insertions(+), 79 deletions(-)

lib/build_runner.zig+2-2
...@@ -420,7 +420,7 @@ fn runStepNames(...@@ -420,7 +420,7 @@ fn runStepNames(
420420
421 const starting_steps = try arena.dupe(*Step, step_stack.keys());421 const starting_steps = try arena.dupe(*Step, step_stack.keys());
422422
423 var rng = std.rand.DefaultPrng.init(seed);423 var rng = std.Random.DefaultPrng.init(seed);
424 const rand = rng.random();424 const rand = rng.random();
425 rand.shuffle(*Step, starting_steps);425 rand.shuffle(*Step, starting_steps);
426426
...@@ -836,7 +836,7 @@ fn constructGraphAndCheckForDependencyLoop(...@@ -836,7 +836,7 @@ fn constructGraphAndCheckForDependencyLoop(
836 b: *std.Build,836 b: *std.Build,
837 s: *Step,837 s: *Step,
838 step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void),838 step_stack: *std.AutoArrayHashMapUnmanaged(*Step, void),
839 rand: std.rand.Random,839 rand: std.Random,
840) !void {840) !void {
841 switch (s.state) {841 switch (s.state) {
842 .precheck_started => {842 .precheck_started => {
lib/compiler_rt/paritydi2_test.zig+1-1
...@@ -26,7 +26,7 @@ test "paritydi2" {...@@ -26,7 +26,7 @@ test "paritydi2" {
26 try test__paritydi2(@bitCast(@as(u64, 0xffffffff_fffffffe)));26 try test__paritydi2(@bitCast(@as(u64, 0xffffffff_fffffffe)));
27 try test__paritydi2(@bitCast(@as(u64, 0xffffffff_ffffffff)));27 try test__paritydi2(@bitCast(@as(u64, 0xffffffff_ffffffff)));
2828
29 const RndGen = std.rand.DefaultPrng;29 const RndGen = std.Random.DefaultPrng;
30 var rnd = RndGen.init(42);30 var rnd = RndGen.init(42);
31 var i: u32 = 0;31 var i: u32 = 0;
32 while (i < 10_000) : (i += 1) {32 while (i < 10_000) : (i += 1) {
lib/compiler_rt/paritysi2_test.zig+1-1
...@@ -26,7 +26,7 @@ test "paritysi2" {...@@ -26,7 +26,7 @@ test "paritysi2" {
26 try test__paritysi2(@bitCast(@as(u32, 0xfffffffe)));26 try test__paritysi2(@bitCast(@as(u32, 0xfffffffe)));
27 try test__paritysi2(@bitCast(@as(u32, 0xffffffff)));27 try test__paritysi2(@bitCast(@as(u32, 0xffffffff)));
2828
29 const RndGen = std.rand.DefaultPrng;29 const RndGen = std.Random.DefaultPrng;
30 var rnd = RndGen.init(42);30 var rnd = RndGen.init(42);
31 var i: u32 = 0;31 var i: u32 = 0;
32 while (i < 10_000) : (i += 1) {32 while (i < 10_000) : (i += 1) {
lib/compiler_rt/parityti2_test.zig+1-1
...@@ -26,7 +26,7 @@ test "parityti2" {...@@ -26,7 +26,7 @@ test "parityti2" {
26 try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe)));26 try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe)));
27 try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff)));27 try test__parityti2(@bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff)));
2828
29 const RndGen = std.rand.DefaultPrng;29 const RndGen = std.Random.DefaultPrng;
30 var rnd = RndGen.init(42);30 var rnd = RndGen.init(42);
31 var i: u32 = 0;31 var i: u32 = 0;
32 while (i < 10_000) : (i += 1) {32 while (i < 10_000) : (i += 1) {
lib/compiler_rt/popcountdi2_test.zig+1-1
...@@ -25,7 +25,7 @@ test "popcountdi2" {...@@ -25,7 +25,7 @@ test "popcountdi2" {
25 try test__popcountdi2(@as(i64, @bitCast(@as(u64, 0xffffffff_fffffffe))));25 try test__popcountdi2(@as(i64, @bitCast(@as(u64, 0xffffffff_fffffffe))));
26 try test__popcountdi2(@as(i64, @bitCast(@as(u64, 0xffffffff_ffffffff))));26 try test__popcountdi2(@as(i64, @bitCast(@as(u64, 0xffffffff_ffffffff))));
2727
28 const RndGen = std.rand.DefaultPrng;28 const RndGen = std.Random.DefaultPrng;
29 var rnd = RndGen.init(42);29 var rnd = RndGen.init(42);
30 var i: u32 = 0;30 var i: u32 = 0;
31 while (i < 10_000) : (i += 1) {31 while (i < 10_000) : (i += 1) {
lib/compiler_rt/popcountsi2_test.zig+1-1
...@@ -25,7 +25,7 @@ test "popcountsi2" {...@@ -25,7 +25,7 @@ test "popcountsi2" {
25 try test__popcountsi2(@as(i32, @bitCast(@as(u32, 0xfffffffe))));25 try test__popcountsi2(@as(i32, @bitCast(@as(u32, 0xfffffffe))));
26 try test__popcountsi2(@as(i32, @bitCast(@as(u32, 0xffffffff))));26 try test__popcountsi2(@as(i32, @bitCast(@as(u32, 0xffffffff))));
2727
28 const RndGen = std.rand.DefaultPrng;28 const RndGen = std.Random.DefaultPrng;
29 var rnd = RndGen.init(42);29 var rnd = RndGen.init(42);
30 var i: u32 = 0;30 var i: u32 = 0;
31 while (i < 10_000) : (i += 1) {31 while (i < 10_000) : (i += 1) {
lib/compiler_rt/popcountti2_test.zig+1-1
...@@ -25,7 +25,7 @@ test "popcountti2" {...@@ -25,7 +25,7 @@ test "popcountti2" {
25 try test__popcountti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))));25 try test__popcountti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_fffffffe))));
26 try test__popcountti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))));26 try test__popcountti2(@as(i128, @bitCast(@as(u128, 0xffffffff_ffffffff_ffffffff_ffffffff))));
2727
28 const RndGen = std.rand.DefaultPrng;28 const RndGen = std.Random.DefaultPrng;
29 var rnd = RndGen.init(42);29 var rnd = RndGen.init(42);
30 var i: u32 = 0;30 var i: u32 = 0;
31 while (i < 10_000) : (i += 1) {31 while (i < 10_000) : (i += 1) {
lib/compiler_rt/udivmodei4.zig+1-1
...@@ -132,7 +132,7 @@ test "__udivei4/__umodei4" {...@@ -132,7 +132,7 @@ test "__udivei4/__umodei4" {
132 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;132 if (builtin.zig_backend == .stage2_c) return error.SkipZigTest;
133 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;133 if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
134134
135 const RndGen = std.rand.DefaultPrng;135 const RndGen = std.Random.DefaultPrng;
136 var rnd = RndGen.init(42);136 var rnd = RndGen.init(42);
137 var i: usize = 10000;137 var i: usize = 10000;
138 while (i > 0) : (i -= 1) {138 while (i > 0) : (i -= 1) {
lib/std/Random.zig+1-1
...@@ -380,7 +380,7 @@ pub fn shuffleWithIndex(r: Random, comptime T: type, buf: []T, comptime Index: t...@@ -380,7 +380,7 @@ pub fn shuffleWithIndex(r: Random, comptime T: type, buf: []T, comptime Index: t
380///380///
381/// This is useful for selecting an item from a slice where weights are not equal.381/// This is useful for selecting an item from a slice where weights are not equal.
382/// `T` must be a numeric type capable of holding the sum of `proportions`.382/// `T` must be a numeric type capable of holding the sum of `proportions`.
383pub fn weightedIndex(r: std.rand.Random, comptime T: type, proportions: []const T) usize {383pub fn weightedIndex(r: Random, comptime T: type, proportions: []const T) usize {
384 // This implementation works by summing the proportions and picking a384 // This implementation works by summing the proportions and picking a
385 // random point in [0, sum). We then loop over the proportions,385 // random point in [0, sum). We then loop over the proportions,
386 // accumulating until our accumulator is greater than the random point.386 // accumulating until our accumulator is greater than the random point.
lib/std/Random/Ascon.zig+3-4
...@@ -10,7 +10,6 @@...@@ -10,7 +10,6 @@
1010
11const std = @import("std");11const std = @import("std");
12const mem = std.mem;12const mem = std.mem;
13const Random = std.rand.Random;
14const Self = @This();13const Self = @This();
1514
16const Ascon = std.crypto.core.Ascon(.little);15const Ascon = std.crypto.core.Ascon(.little);
...@@ -39,9 +38,9 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void {...@@ -39,9 +38,9 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void {
39 self.state.permute();38 self.state.permute();
40}39}
4140
42/// Returns a `std.rand.Random` structure backed by the current RNG.41/// Returns a `std.Random` structure backed by the current RNG.
43pub fn random(self: *Self) Random {42pub fn random(self: *Self) std.Random {
44 return Random.init(self, fill);43 return std.Random.init(self, fill);
45}44}
4645
47/// Fills the buffer with random bytes.46/// Fills the buffer with random bytes.
lib/std/Random/ChaCha.zig+3-4
...@@ -5,7 +5,6 @@...@@ -5,7 +5,6 @@
55
6const std = @import("std");6const std = @import("std");
7const mem = std.mem;7const mem = std.mem;
8const Random = std.rand.Random;
9const Self = @This();8const Self = @This();
109
11const Cipher = std.crypto.stream.chacha.ChaCha8IETF;10const Cipher = std.crypto.stream.chacha.ChaCha8IETF;
...@@ -53,9 +52,9 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void {...@@ -53,9 +52,9 @@ pub fn addEntropy(self: *Self, bytes: []const u8) void {
53 self.refill();52 self.refill();
54}53}
5554
56/// Returns a `std.rand.Random` structure backed by the current RNG.55/// Returns a `std.Random` structure backed by the current RNG.
57pub fn random(self: *Self) Random {56pub fn random(self: *Self) std.Random {
58 return Random.init(self, fill);57 return std.Random.init(self, fill);
59}58}
6059
61// Refills the buffer with random bytes, overwriting the previous key.60// Refills the buffer with random bytes, overwriting the previous key.
lib/std/Random/Isaac64.zig+2-3
...@@ -4,7 +4,6 @@...@@ -4,7 +4,6 @@
4//! https://doc.rust-lang.org/rand/src/rand/prng/isaac64.rs.html4//! https://doc.rust-lang.org/rand/src/rand/prng/isaac64.rs.html
55
6const std = @import("std");6const std = @import("std");
7const Random = std.rand.Random;
8const mem = std.mem;7const mem = std.mem;
9const Isaac64 = @This();8const Isaac64 = @This();
109
...@@ -30,8 +29,8 @@ pub fn init(init_s: u64) Isaac64 {...@@ -30,8 +29,8 @@ pub fn init(init_s: u64) Isaac64 {
30 return isaac;29 return isaac;
31}30}
3231
33pub fn random(self: *Isaac64) Random {32pub fn random(self: *Isaac64) std.Random {
34 return Random.init(self, fill);33 return std.Random.init(self, fill);
35}34}
3635
37fn step(self: *Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void {36fn step(self: *Isaac64, mix: u64, base: usize, comptime m1: usize, comptime m2: usize) void {
lib/std/Random/Pcg.zig+3-4
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3//! PRNG3//! PRNG
44
5const std = @import("std");5const std = @import("std");
6const Random = std.rand.Random;
7const Pcg = @This();6const Pcg = @This();
87
9const default_multiplier = 6364136223846793005;8const default_multiplier = 6364136223846793005;
...@@ -21,8 +20,8 @@ pub fn init(init_s: u64) Pcg {...@@ -21,8 +20,8 @@ pub fn init(init_s: u64) Pcg {
21 return pcg;20 return pcg;
22}21}
2322
24pub fn random(self: *Pcg) Random {23pub fn random(self: *Pcg) std.Random {
25 return Random.init(self, fill);24 return std.Random.init(self, fill);
26}25}
2726
28fn next(self: *Pcg) u32 {27fn next(self: *Pcg) u32 {
...@@ -37,7 +36,7 @@ fn next(self: *Pcg) u32 {...@@ -37,7 +36,7 @@ fn next(self: *Pcg) u32 {
3736
38fn seed(self: *Pcg, init_s: u64) void {37fn seed(self: *Pcg, init_s: u64) void {
39 // Pcg requires 128-bits of seed.38 // Pcg requires 128-bits of seed.
40 var gen = std.rand.SplitMix64.init(init_s);39 var gen = std.Random.SplitMix64.init(init_s);
41 self.seedTwo(gen.next(), gen.next());40 self.seedTwo(gen.next(), gen.next());
42}41}
4342
lib/std/Random/RomuTrio.zig+3-4
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3// Beware: this PRNG is trivially predictable. While fast, it should *never* be used for cryptographic purposes.3// Beware: this PRNG is trivially predictable. While fast, it should *never* be used for cryptographic purposes.
44
5const std = @import("std");5const std = @import("std");
6const Random = std.rand.Random;
7const math = std.math;6const math = std.math;
8const RomuTrio = @This();7const RomuTrio = @This();
98
...@@ -17,8 +16,8 @@ pub fn init(init_s: u64) RomuTrio {...@@ -17,8 +16,8 @@ pub fn init(init_s: u64) RomuTrio {
17 return x;16 return x;
18}17}
1918
20pub fn random(self: *RomuTrio) Random {19pub fn random(self: *RomuTrio) std.Random {
21 return Random.init(self, fill);20 return std.Random.init(self, fill);
22}21}
2322
24fn next(self: *RomuTrio) u64 {23fn next(self: *RomuTrio) u64 {
...@@ -42,7 +41,7 @@ pub fn seedWithBuf(self: *RomuTrio, buf: [24]u8) void {...@@ -42,7 +41,7 @@ pub fn seedWithBuf(self: *RomuTrio, buf: [24]u8) void {
4241
43pub fn seed(self: *RomuTrio, init_s: u64) void {42pub fn seed(self: *RomuTrio, init_s: u64) void {
44 // RomuTrio requires 192-bits of seed.43 // RomuTrio requires 192-bits of seed.
45 var gen = std.rand.SplitMix64.init(init_s);44 var gen = std.Random.SplitMix64.init(init_s);
4645
47 self.x_state = gen.next();46 self.x_state = gen.next();
48 self.y_state = gen.next();47 self.y_state = gen.next();
lib/std/Random/Sfc64.zig+2-3
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3//! See http://pracrand.sourceforge.net/3//! See http://pracrand.sourceforge.net/
44
5const std = @import("std");5const std = @import("std");
6const Random = std.rand.Random;
7const math = std.math;6const math = std.math;
8const Sfc64 = @This();7const Sfc64 = @This();
98
...@@ -23,8 +22,8 @@ pub fn init(init_s: u64) Sfc64 {...@@ -23,8 +22,8 @@ pub fn init(init_s: u64) Sfc64 {
23 return x;22 return x;
24}23}
2524
26pub fn random(self: *Sfc64) Random {25pub fn random(self: *Sfc64) std.Random {
27 return Random.init(self, fill);26 return std.Random.init(self, fill);
28}27}
2928
30fn next(self: *Sfc64) u64 {29fn next(self: *Sfc64) u64 {
lib/std/Random/Xoroshiro128.zig+3-4
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3//! PRNG3//! PRNG
44
5const std = @import("std");5const std = @import("std");
6const Random = std.rand.Random;
7const math = std.math;6const math = std.math;
8const Xoroshiro128 = @This();7const Xoroshiro128 = @This();
98
...@@ -16,8 +15,8 @@ pub fn init(init_s: u64) Xoroshiro128 {...@@ -16,8 +15,8 @@ pub fn init(init_s: u64) Xoroshiro128 {
16 return x;15 return x;
17}16}
1817
19pub fn random(self: *Xoroshiro128) Random {18pub fn random(self: *Xoroshiro128) std.Random {
20 return Random.init(self, fill);19 return std.Random.init(self, fill);
21}20}
2221
23pub fn next(self: *Xoroshiro128) u64 {22pub fn next(self: *Xoroshiro128) u64 {
...@@ -59,7 +58,7 @@ pub fn jump(self: *Xoroshiro128) void {...@@ -59,7 +58,7 @@ pub fn jump(self: *Xoroshiro128) void {
5958
60pub fn seed(self: *Xoroshiro128, init_s: u64) void {59pub fn seed(self: *Xoroshiro128, init_s: u64) void {
61 // Xoroshiro requires 128-bits of seed.60 // Xoroshiro requires 128-bits of seed.
62 var gen = std.rand.SplitMix64.init(init_s);61 var gen = std.Random.SplitMix64.init(init_s);
6362
64 self.s[0] = gen.next();63 self.s[0] = gen.next();
65 self.s[1] = gen.next();64 self.s[1] = gen.next();
lib/std/Random/Xoshiro256.zig+3-4
...@@ -3,7 +3,6 @@...@@ -3,7 +3,6 @@
3//! PRNG3//! PRNG
44
5const std = @import("std");5const std = @import("std");
6const Random = std.rand.Random;
7const math = std.math;6const math = std.math;
8const Xoshiro256 = @This();7const Xoshiro256 = @This();
98
...@@ -18,8 +17,8 @@ pub fn init(init_s: u64) Xoshiro256 {...@@ -18,8 +17,8 @@ pub fn init(init_s: u64) Xoshiro256 {
18 return x;17 return x;
19}18}
2019
21pub fn random(self: *Xoshiro256) Random {20pub fn random(self: *Xoshiro256) std.Random {
22 return Random.init(self, fill);21 return std.Random.init(self, fill);
23}22}
2423
25pub fn next(self: *Xoshiro256) u64 {24pub fn next(self: *Xoshiro256) u64 {
...@@ -57,7 +56,7 @@ pub fn jump(self: *Xoshiro256) void {...@@ -57,7 +56,7 @@ pub fn jump(self: *Xoshiro256) void {
5756
58pub fn seed(self: *Xoshiro256, init_s: u64) void {57pub fn seed(self: *Xoshiro256, init_s: u64) void {
59 // Xoshiro requires 256-bits of seed.58 // Xoshiro requires 256-bits of seed.
60 var gen = std.rand.SplitMix64.init(init_s);59 var gen = std.Random.SplitMix64.init(init_s);
6160
62 self.s[0] = gen.next();61 self.s[0] = gen.next();
63 self.s[1] = gen.next();62 self.s[1] = gen.next();
lib/std/Random/benchmark.zig+9-9
...@@ -4,7 +4,7 @@ const std = @import("std");...@@ -4,7 +4,7 @@ const std = @import("std");
4const builtin = @import("builtin");4const builtin = @import("builtin");
5const time = std.time;5const time = std.time;
6const Timer = time.Timer;6const Timer = time.Timer;
7const rand = std.rand;7const Random = std.Random;
88
9const KiB = 1024;9const KiB = 1024;
10const MiB = 1024 * KiB;10const MiB = 1024 * KiB;
...@@ -19,32 +19,32 @@ const Rng = struct {...@@ -19,32 +19,32 @@ const Rng = struct {
1919
20const prngs = [_]Rng{20const prngs = [_]Rng{
21 Rng{21 Rng{
22 .ty = rand.Isaac64,22 .ty = Random.Isaac64,
23 .name = "isaac64",23 .name = "isaac64",
24 .init_u64 = 0,24 .init_u64 = 0,
25 },25 },
26 Rng{26 Rng{
27 .ty = rand.Pcg,27 .ty = Random.Pcg,
28 .name = "pcg",28 .name = "pcg",
29 .init_u64 = 0,29 .init_u64 = 0,
30 },30 },
31 Rng{31 Rng{
32 .ty = rand.RomuTrio,32 .ty = Random.RomuTrio,
33 .name = "romutrio",33 .name = "romutrio",
34 .init_u64 = 0,34 .init_u64 = 0,
35 },35 },
36 Rng{36 Rng{
37 .ty = std.rand.Sfc64,37 .ty = Random.Sfc64,
38 .name = "sfc64",38 .name = "sfc64",
39 .init_u64 = 0,39 .init_u64 = 0,
40 },40 },
41 Rng{41 Rng{
42 .ty = std.rand.Xoroshiro128,42 .ty = Random.Xoroshiro128,
43 .name = "xoroshiro128",43 .name = "xoroshiro128",
44 .init_u64 = 0,44 .init_u64 = 0,
45 },45 },
46 Rng{46 Rng{
47 .ty = std.rand.Xoshiro256,47 .ty = Random.Xoshiro256,
48 .name = "xoshiro256",48 .name = "xoshiro256",
49 .init_u64 = 0,49 .init_u64 = 0,
50 },50 },
...@@ -52,12 +52,12 @@ const prngs = [_]Rng{...@@ -52,12 +52,12 @@ const prngs = [_]Rng{
5252
53const csprngs = [_]Rng{53const csprngs = [_]Rng{
54 Rng{54 Rng{
55 .ty = rand.Ascon,55 .ty = Random.Ascon,
56 .name = "ascon",56 .name = "ascon",
57 .init_u8s = &[_]u8{0} ** 32,57 .init_u8s = &[_]u8{0} ** 32,
58 },58 },
59 Rng{59 Rng{
60 .ty = rand.ChaCha,60 .ty = Random.ChaCha,
61 .name = "chacha",61 .name = "chacha",
62 .init_u8s = &[_]u8{0} ** 32,62 .init_u8s = &[_]u8{0} ** 32,
63 },63 },
lib/std/Random/ziggurat.zig+3-3
...@@ -10,7 +10,7 @@...@@ -10,7 +10,7 @@
10const std = @import("../std.zig");10const std = @import("../std.zig");
11const builtin = @import("builtin");11const builtin = @import("builtin");
12const math = std.math;12const math = std.math;
13const Random = std.rand.Random;13const Random = std.Random;
1414
15pub fn next_f64(random: Random, comptime tables: ZigTable) f64 {15pub fn next_f64(random: Random, comptime tables: ZigTable) f64 {
16 while (true) {16 while (true) {
...@@ -127,7 +127,7 @@ pub fn norm_zero_case(random: Random, u: f64) f64 {...@@ -127,7 +127,7 @@ pub fn norm_zero_case(random: Random, u: f64) f64 {
127}127}
128128
129test "normal dist sanity" {129test "normal dist sanity" {
130 var prng = std.rand.DefaultPrng.init(0);130 var prng = Random.DefaultPrng.init(0);
131 const random = prng.random();131 const random = prng.random();
132132
133 var i: usize = 0;133 var i: usize = 0;
...@@ -156,7 +156,7 @@ pub fn exp_zero_case(random: Random, _: f64) f64 {...@@ -156,7 +156,7 @@ pub fn exp_zero_case(random: Random, _: f64) f64 {
156}156}
157157
158test "exp dist smoke test" {158test "exp dist smoke test" {
159 var prng = std.rand.DefaultPrng.init(0);159 var prng = Random.DefaultPrng.init(0);
160 const random = prng.random();160 const random = prng.random();
161161
162 var i: usize = 0;162 var i: usize = 0;
lib/std/Thread/RwLock.zig+1-1
...@@ -328,7 +328,7 @@ test "RwLock - concurrent access" {...@@ -328,7 +328,7 @@ test "RwLock - concurrent access" {
328 }328 }
329329
330 fn writer(self: *Self, thread_idx: usize) !void {330 fn writer(self: *Self, thread_idx: usize) !void {
331 var prng = std.rand.DefaultPrng.init(thread_idx);331 var prng = std.Random.DefaultPrng.init(thread_idx);
332 var rnd = prng.random();332 var rnd = prng.random();
333333
334 while (true) {334 while (true) {
lib/std/crypto/benchmark.zig+1-1
...@@ -10,7 +10,7 @@ const crypto = std.crypto;...@@ -10,7 +10,7 @@ const crypto = std.crypto;
10const KiB = 1024;10const KiB = 1024;
11const MiB = 1024 * KiB;11const MiB = 1024 * KiB;
1212
13var prng = std.rand.DefaultPrng.init(0);13var prng = std.Random.DefaultPrng.init(0);
14const random = prng.random();14const random = prng.random();
1515
16const Crypto = struct {16const Crypto = struct {
lib/std/crypto/kyber_d00.zig+1-1
...@@ -110,7 +110,7 @@ const assert = std.debug.assert;...@@ -110,7 +110,7 @@ const assert = std.debug.assert;
110const crypto = std.crypto;110const crypto = std.crypto;
111const math = std.math;111const math = std.math;
112const mem = std.mem;112const mem = std.mem;
113const RndGen = std.rand.DefaultPrng;113const RndGen = std.Random.DefaultPrng;
114const sha3 = crypto.hash.sha3;114const sha3 = crypto.hash.sha3;
115115
116// Q is the parameter q ≡ 3329 = 2¹¹ + 2¹⁰ + 2⁸ + 1.116// Q is the parameter q ≡ 3329 = 2¹¹ + 2¹⁰ + 2⁸ + 1.
lib/std/crypto/tlcsprng.zig+2-2
...@@ -10,7 +10,7 @@ const os = std.os;...@@ -10,7 +10,7 @@ const os = std.os;
1010
11/// We use this as a layer of indirection because global const pointers cannot11/// We use this as a layer of indirection because global const pointers cannot
12/// point to thread-local variables.12/// point to thread-local variables.
13pub const interface = std.rand.Random{13pub const interface = std.Random{
14 .ptr = undefined,14 .ptr = undefined,
15 .fillFn = tlsCsprngFill,15 .fillFn = tlsCsprngFill,
16};16};
...@@ -43,7 +43,7 @@ const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{...@@ -43,7 +43,7 @@ const maybe_have_wipe_on_fork = builtin.os.isAtLeast(.linux, .{
43}) orelse true;43}) orelse true;
44const is_haiku = builtin.os.tag == .haiku;44const is_haiku = builtin.os.tag == .haiku;
4545
46const Rng = std.rand.DefaultCsprng;46const Rng = std.Random.DefaultCsprng;
4747
48const Context = struct {48const Context = struct {
49 init_state: enum(u8) { uninitialized = 0, initialized, failed },49 init_state: enum(u8) { uninitialized = 0, initialized, failed },
lib/std/hash/benchmark.zig+1-1
...@@ -10,7 +10,7 @@ const KiB = 1024;...@@ -10,7 +10,7 @@ const KiB = 1024;
10const MiB = 1024 * KiB;10const MiB = 1024 * KiB;
11const GiB = 1024 * MiB;11const GiB = 1024 * MiB;
1212
13var prng = std.rand.DefaultPrng.init(0);13var prng = std.Random.DefaultPrng.init(0);
14const random = prng.random();14const random = prng.random();
1515
16const Hash = struct {16const Hash = struct {
lib/std/hash_map.zig+2-2
...@@ -1884,7 +1884,7 @@ test "std.hash_map put and remove loop in random order" {...@@ -1884,7 +1884,7 @@ test "std.hash_map put and remove loop in random order" {
1884 while (i < size) : (i += 1) {1884 while (i < size) : (i += 1) {
1885 try keys.append(i);1885 try keys.append(i);
1886 }1886 }
1887 var prng = std.rand.DefaultPrng.init(0);1887 var prng = std.Random.DefaultPrng.init(0);
1888 const random = prng.random();1888 const random = prng.random();
18891889
1890 while (i < iterations) : (i += 1) {1890 while (i < iterations) : (i += 1) {
...@@ -1916,7 +1916,7 @@ test "std.hash_map remove one million elements in random order" {...@@ -1916,7 +1916,7 @@ test "std.hash_map remove one million elements in random order" {
1916 keys.append(i) catch unreachable;1916 keys.append(i) catch unreachable;
1917 }1917 }
19181918
1919 var prng = std.rand.DefaultPrng.init(0);1919 var prng = std.Random.DefaultPrng.init(0);
1920 const random = prng.random();1920 const random = prng.random();
1921 random.shuffle(u32, keys.items);1921 random.shuffle(u32, keys.items);
19221922
lib/std/heap/arena_allocator.zig+1-1
...@@ -250,7 +250,7 @@ test "ArenaAllocator (reset with preheating)" {...@@ -250,7 +250,7 @@ test "ArenaAllocator (reset with preheating)" {
250 var arena_allocator = ArenaAllocator.init(std.testing.allocator);250 var arena_allocator = ArenaAllocator.init(std.testing.allocator);
251 defer arena_allocator.deinit();251 defer arena_allocator.deinit();
252 // provides some variance in the allocated data252 // provides some variance in the allocated data
253 var rng_src = std.rand.DefaultPrng.init(19930913);253 var rng_src = std.Random.DefaultPrng.init(19930913);
254 const random = rng_src.random();254 const random = rng_src.random();
255 var rounds: usize = 25;255 var rounds: usize = 25;
256 while (rounds > 0) {256 while (rounds > 0) {
lib/std/io/test.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1const std = @import("std");1const std = @import("std");
2const io = std.io;2const io = std.io;
3const DefaultPrng = std.rand.DefaultPrng;3const DefaultPrng = std.Random.DefaultPrng;
4const expect = std.testing.expect;4const expect = std.testing.expect;
5const expectEqual = std.testing.expectEqual;5const expectEqual = std.testing.expectEqual;
6const expectError = std.testing.expectError;6const expectError = std.testing.expectError;
lib/std/math/big/rational.zig+1-1
...@@ -594,7 +594,7 @@ test "big.rational toFloat" {...@@ -594,7 +594,7 @@ test "big.rational toFloat" {
594test "big.rational set/to Float round-trip" {594test "big.rational set/to Float round-trip" {
595 var a = try Rational.init(testing.allocator);595 var a = try Rational.init(testing.allocator);
596 defer a.deinit();596 defer a.deinit();
597 var prng = std.rand.DefaultPrng.init(0x5EED);597 var prng = std.Random.DefaultPrng.init(0x5EED);
598 const random = prng.random();598 const random = prng.random();
599 var i: usize = 0;599 var i: usize = 0;
600 while (i < 512) : (i += 1) {600 while (i < 512) : (i += 1) {
lib/std/mem.zig+1-1
...@@ -4423,7 +4423,7 @@ test "read/write(Var)PackedInt" {...@@ -4423,7 +4423,7 @@ test "read/write(Var)PackedInt" {
44234423
4424 const foreign_endian: Endian = if (native_endian == .big) .little else .big;4424 const foreign_endian: Endian = if (native_endian == .big) .little else .big;
4425 const expect = std.testing.expect;4425 const expect = std.testing.expect;
4426 var prng = std.rand.DefaultPrng.init(1234);4426 var prng = std.Random.DefaultPrng.init(1234);
4427 const random = prng.random();4427 const random = prng.random();
44284428
4429 @setEvalBranchQuota(10_000);4429 @setEvalBranchQuota(10_000);
lib/std/priority_dequeue.zig+7-7
...@@ -866,7 +866,7 @@ test "std.PriorityDequeue: shrinkAndFree" {...@@ -866,7 +866,7 @@ test "std.PriorityDequeue: shrinkAndFree" {
866}866}
867867
868test "std.PriorityDequeue: fuzz testing min" {868test "std.PriorityDequeue: fuzz testing min" {
869 var prng = std.rand.DefaultPrng.init(0x12345678);869 var prng = std.Random.DefaultPrng.init(0x12345678);
870 const random = prng.random();870 const random = prng.random();
871871
872 const test_case_count = 100;872 const test_case_count = 100;
...@@ -878,7 +878,7 @@ test "std.PriorityDequeue: fuzz testing min" {...@@ -878,7 +878,7 @@ test "std.PriorityDequeue: fuzz testing min" {
878 }878 }
879}879}
880880
881fn fuzzTestMin(rng: std.rand.Random, comptime queue_size: usize) !void {881fn fuzzTestMin(rng: std.Random, comptime queue_size: usize) !void {
882 const allocator = testing.allocator;882 const allocator = testing.allocator;
883 const items = try generateRandomSlice(allocator, rng, queue_size);883 const items = try generateRandomSlice(allocator, rng, queue_size);
884884
...@@ -895,7 +895,7 @@ fn fuzzTestMin(rng: std.rand.Random, comptime queue_size: usize) !void {...@@ -895,7 +895,7 @@ fn fuzzTestMin(rng: std.rand.Random, comptime queue_size: usize) !void {
895}895}
896896
897test "std.PriorityDequeue: fuzz testing max" {897test "std.PriorityDequeue: fuzz testing max" {
898 var prng = std.rand.DefaultPrng.init(0x87654321);898 var prng = std.Random.DefaultPrng.init(0x87654321);
899 const random = prng.random();899 const random = prng.random();
900900
901 const test_case_count = 100;901 const test_case_count = 100;
...@@ -907,7 +907,7 @@ test "std.PriorityDequeue: fuzz testing max" {...@@ -907,7 +907,7 @@ test "std.PriorityDequeue: fuzz testing max" {
907 }907 }
908}908}
909909
910fn fuzzTestMax(rng: std.rand.Random, queue_size: usize) !void {910fn fuzzTestMax(rng: std.Random, queue_size: usize) !void {
911 const allocator = testing.allocator;911 const allocator = testing.allocator;
912 const items = try generateRandomSlice(allocator, rng, queue_size);912 const items = try generateRandomSlice(allocator, rng, queue_size);
913913
...@@ -924,7 +924,7 @@ fn fuzzTestMax(rng: std.rand.Random, queue_size: usize) !void {...@@ -924,7 +924,7 @@ fn fuzzTestMax(rng: std.rand.Random, queue_size: usize) !void {
924}924}
925925
926test "std.PriorityDequeue: fuzz testing min and max" {926test "std.PriorityDequeue: fuzz testing min and max" {
927 var prng = std.rand.DefaultPrng.init(0x87654321);927 var prng = std.Random.DefaultPrng.init(0x87654321);
928 const random = prng.random();928 const random = prng.random();
929929
930 const test_case_count = 100;930 const test_case_count = 100;
...@@ -936,7 +936,7 @@ test "std.PriorityDequeue: fuzz testing min and max" {...@@ -936,7 +936,7 @@ test "std.PriorityDequeue: fuzz testing min and max" {
936 }936 }
937}937}
938938
939fn fuzzTestMinMax(rng: std.rand.Random, queue_size: usize) !void {939fn fuzzTestMinMax(rng: std.Random, queue_size: usize) !void {
940 const allocator = testing.allocator;940 const allocator = testing.allocator;
941 const items = try generateRandomSlice(allocator, rng, queue_size);941 const items = try generateRandomSlice(allocator, rng, queue_size);
942942
...@@ -963,7 +963,7 @@ fn fuzzTestMinMax(rng: std.rand.Random, queue_size: usize) !void {...@@ -963,7 +963,7 @@ fn fuzzTestMinMax(rng: std.rand.Random, queue_size: usize) !void {
963 }963 }
964}964}
965965
966fn generateRandomSlice(allocator: std.mem.Allocator, rng: std.rand.Random, size: usize) ![]u32 {966fn generateRandomSlice(allocator: std.mem.Allocator, rng: std.Random, size: usize) ![]u32 {
967 var array = std.ArrayList(u32).init(allocator);967 var array = std.ArrayList(u32).init(allocator);
968 try array.ensureTotalCapacity(size);968 try array.ensureTotalCapacity(size);
969969
lib/std/sort.zig+1-1
...@@ -379,7 +379,7 @@ test "sort with context in the middle of a slice" {...@@ -379,7 +379,7 @@ test "sort with context in the middle of a slice" {
379}379}
380380
381test "sort fuzz testing" {381test "sort fuzz testing" {
382 var prng = std.rand.DefaultPrng.init(0x12345678);382 var prng = std.Random.DefaultPrng.init(0x12345678);
383 const random = prng.random();383 const random = prng.random();
384 const test_case_count = 10;384 const test_case_count = 10;
385385
lib/std/treap.zig+4-4
...@@ -18,7 +18,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {...@@ -18,7 +18,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
1818
19 /// A customized pseudo random number generator for the treap.19 /// A customized pseudo random number generator for the treap.
20 /// This just helps reducing the memory size of the treap itself20 /// This just helps reducing the memory size of the treap itself
21 /// as std.rand.DefaultPrng requires larger state (while producing better entropy for randomness to be fair).21 /// as std.Random.DefaultPrng requires larger state (while producing better entropy for randomness to be fair).
22 const Prng = struct {22 const Prng = struct {
23 xorshift: usize = 0,23 xorshift: usize = 0,
2424
...@@ -305,7 +305,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {...@@ -305,7 +305,7 @@ pub fn Treap(comptime Key: type, comptime compareFn: anytype) type {
305// https://lemire.me/blog/2017/09/18/visiting-all-values-in-an-array-exactly-once-in-random-order/305// https://lemire.me/blog/2017/09/18/visiting-all-values-in-an-array-exactly-once-in-random-order/
306fn SliceIterRandomOrder(comptime T: type) type {306fn SliceIterRandomOrder(comptime T: type) type {
307 return struct {307 return struct {
308 rng: std.rand.Random,308 rng: std.Random,
309 slice: []T,309 slice: []T,
310 index: usize = undefined,310 index: usize = undefined,
311 offset: usize = undefined,311 offset: usize = undefined,
...@@ -313,7 +313,7 @@ fn SliceIterRandomOrder(comptime T: type) type {...@@ -313,7 +313,7 @@ fn SliceIterRandomOrder(comptime T: type) type {
313313
314 const Self = @This();314 const Self = @This();
315315
316 pub fn init(slice: []T, rng: std.rand.Random) Self {316 pub fn init(slice: []T, rng: std.Random) Self {
317 return Self{317 return Self{
318 .rng = rng,318 .rng = rng,
319 .slice = slice,319 .slice = slice,
...@@ -353,7 +353,7 @@ test "std.Treap: insert, find, replace, remove" {...@@ -353,7 +353,7 @@ test "std.Treap: insert, find, replace, remove" {
353 var treap = TestTreap{};353 var treap = TestTreap{};
354 var nodes: [10]TestNode = undefined;354 var nodes: [10]TestNode = undefined;
355355
356 var prng = std.rand.DefaultPrng.init(0xdeadbeef);356 var prng = std.Random.DefaultPrng.init(0xdeadbeef);
357 var iter = SliceIterRandomOrder(TestNode).init(&nodes, prng.random());357 var iter = SliceIterRandomOrder(TestNode).init(&nodes, prng.random());
358358
359 // insert check359 // insert check
src/reduce.zig+2-2
...@@ -136,7 +136,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -136,7 +136,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
136 var more_fixups: Ast.Fixups = .{};136 var more_fixups: Ast.Fixups = .{};
137 defer more_fixups.deinit(gpa);137 defer more_fixups.deinit(gpa);
138138
139 var rng = std.rand.DefaultPrng.init(seed);139 var rng = std.Random.DefaultPrng.init(seed);
140140
141 // 1. Walk the AST of the source file looking for independent141 // 1. Walk the AST of the source file looking for independent
142 // reductions and collecting them all into an array list.142 // 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 {...@@ -274,7 +274,7 @@ pub fn main(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
274 return std.process.cleanExit();274 return std.process.cleanExit();
275}275}
276276
277fn sortTransformations(transformations: []Walk.Transformation, rng: std.rand.Random) void {277fn sortTransformations(transformations: []Walk.Transformation, rng: std.Random) void {
278 rng.shuffle(Walk.Transformation, transformations);278 rng.shuffle(Walk.Transformation, transformations);
279 // Stable sort based on priority to keep randomness as the secondary sort.279 // Stable sort based on priority to keep randomness as the secondary sort.
280 // TODO: introduce transformation priorities280 // TODO: introduce transformation priorities
src/resinator/compile.zig+1-1
...@@ -3356,7 +3356,7 @@ test "StringTable" {...@@ -3356,7 +3356,7 @@ test "StringTable" {
3356 }3356 }
3357 break :ids buf;3357 break :ids buf;
3358 };3358 };
3359 var prng = std.rand.DefaultPrng.init(0);3359 var prng = std.Random.DefaultPrng.init(0);
3360 var random = prng.random();3360 var random = prng.random();
3361 random.shuffle(u16, &ids);3361 random.shuffle(u16, &ids);
33623362