Skip to content

Commit 2ffa13d

Browse files
committed
---
yaml --- r: 16260 b: refs/heads/try c: 78fe75a h: refs/heads/master v: v3
1 parent e166a2d commit 2ffa13d

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: e04e9488adfd06128e9fda3ff423e5e35f3357f5
5+
refs/heads/try: 78fe75a7415f1073917b5202b83dad6f2ce0c2d6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/libcore/rand.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,17 @@ mod tests {
303303
assert ra.gen_str(100u) == rb.gen_str(100u);
304304
}
305305

306+
#[test]
307+
fn rng_seeded_custom_seed2() {
308+
let seed = [2u8, 32u8, 4u8, 32u8, 51u8];
309+
let ra = rand::seeded_rng(seed);
310+
// Regression test that isaac is actually using the above vector
311+
let r = ra.next();
312+
#error("%?", r);
313+
assert r == 890007737u32 // on x86_64
314+
|| r == 2935188040u32; // on x86
315+
}
316+
306317
#[test]
307318
fn gen_int_range() {
308319
let r = rand::rng();

branches/try/src/rt/rust_builtin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ rand_new() {
204204
}
205205

206206
extern "C" CDECL void *
207-
rand_new_seeded(rust_vec* seed) {
207+
rand_new_seeded(rust_vec_box* seed) {
208208
rust_task *task = rust_get_current_task();
209209
rust_sched_loop *thread = task->sched_loop;
210210
randctx *rctx = (randctx *) task->malloc(sizeof(randctx),

branches/try/src/rt/rust_util.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ inline void isaac_seed(rust_kernel* kernel, uint8_t* dest)
128128
}
129129

130130
inline void
131-
isaac_init(rust_kernel *kernel, randctx *rctx, rust_vec* user_seed)
131+
isaac_init(rust_kernel *kernel, randctx *rctx, rust_vec_box* user_seed)
132132
{
133133
memset(rctx, 0, sizeof(randctx));
134134

135135
char *env_seed = kernel->env->rust_seed;
136136
if (user_seed != NULL) {
137137
// ignore bytes after the required length
138-
size_t seed_len = user_seed->fill < sizeof(rctx->randrsl)
139-
? user_seed->fill : sizeof(rctx->randrsl);
140-
memcpy(&rctx->randrsl, user_seed->data, seed_len);
138+
size_t seed_len = user_seed->body.fill < sizeof(rctx->randrsl)
139+
? user_seed->body.fill : sizeof(rctx->randrsl);
140+
memcpy(&rctx->randrsl, user_seed->body.data, seed_len);
141141
} else if (env_seed != NULL) {
142142
ub4 seed = (ub4) atoi(env_seed);
143143
for (size_t i = 0; i < RANDSIZ; i ++) {

0 commit comments

Comments
 (0)