Skip to content

Commit 0951313

Browse files
committed
Remove the C(++) ISAAC Rng from the old rt.
This has to leave rust_gen_seed and rng_gen_seed around since they're used to initialise the std::rand RNGs.
1 parent fb923c7 commit 0951313

File tree

9 files changed

+2
-391
lines changed

9 files changed

+2
-391
lines changed

mk/rt.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ RUNTIME_CXXS_$(1)_$(2) := \
7474
rt/rust_rng.cpp \
7575
rt/rust_upcall.cpp \
7676
rt/rust_uv.cpp \
77-
rt/isaac/randport.cpp \
7877
rt/miniz.cpp \
7978
rt/memory_region.cpp \
8079
rt/boxed_region.cpp \

src/libstd/rand/mod.rs

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ pub mod rustrt {
242242
use libc::size_t;
243243

244244
extern {
245-
pub fn rand_seed_size() -> size_t;
246245
pub fn rand_gen_seed(buf: *mut u8, sz: size_t);
247246
}
248247
}
@@ -822,8 +821,8 @@ pub fn seed() -> ~[u8] {
822821
#[fixed_stack_segment]; #[inline(never)];
823822

824823
unsafe {
825-
let n = rustrt::rand_seed_size() as uint;
826-
let mut s = vec::from_elem(n, 0_u8);
824+
let n = RAND_SIZE * 4;
825+
let mut s = vec::from_elem(n as uint, 0_u8);
827826
do s.as_mut_buf |p, sz| {
828827
rustrt::rand_gen_seed(p, sz as size_t)
829828
}
@@ -1053,46 +1052,6 @@ mod test {
10531052
(f32, (f64, (float,)))) = random();
10541053
}
10551054

1056-
#[test]
1057-
fn compare_isaac_implementation() {
1058-
#[fixed_stack_segment]; #[inline(never)];
1059-
1060-
// This is to verify that the implementation of the ISAAC rng is
1061-
// correct (i.e. matches the output of the upstream implementation,
1062-
// which is in the runtime)
1063-
use libc::size_t;
1064-
1065-
#[abi = "cdecl"]
1066-
mod rustrt {
1067-
use libc::size_t;
1068-
1069-
#[allow(non_camel_case_types)] // runtime type
1070-
pub enum rust_rng {}
1071-
1072-
extern {
1073-
pub fn rand_new_seeded(buf: *u8, sz: size_t) -> *rust_rng;
1074-
pub fn rand_next(rng: *rust_rng) -> u32;
1075-
pub fn rand_free(rng: *rust_rng);
1076-
}
1077-
}
1078-
1079-
// run against several seeds
1080-
do 10.times {
1081-
unsafe {
1082-
let seed = super::seed();
1083-
let rt_rng = do seed.as_imm_buf |p, sz| {
1084-
rustrt::rand_new_seeded(p, sz as size_t)
1085-
};
1086-
let mut rng = IsaacRng::new_seeded(seed);
1087-
1088-
do 10000.times {
1089-
assert_eq!(rng.next(), rustrt::rand_next(rt_rng));
1090-
}
1091-
rustrt::rand_free(rt_rng);
1092-
}
1093-
}
1094-
}
1095-
10961055
#[test]
10971056
fn test_sample() {
10981057
let MIN_VAL = 1;

src/rt/isaac/rand.h

Lines changed: 0 additions & 54 deletions
This file was deleted.

src/rt/isaac/randport.cpp

Lines changed: 0 additions & 139 deletions
This file was deleted.

src/rt/isaac/standard.h

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/rt/rust_builtin.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -69,35 +69,11 @@ rust_env_pairs() {
6969
}
7070
#endif
7171

72-
extern "C" CDECL size_t
73-
rand_seed_size() {
74-
return rng_seed_size();
75-
}
76-
7772
extern "C" CDECL void
7873
rand_gen_seed(uint8_t* dest, size_t size) {
7974
rng_gen_seed(dest, size);
8075
}
8176

82-
extern "C" CDECL void *
83-
rand_new_seeded(uint8_t* seed, size_t seed_size) {
84-
assert(seed != NULL);
85-
rust_rng *rng = (rust_rng *) malloc(sizeof(rust_rng));
86-
assert(rng != NULL && "rng alloc failed");
87-
rng_init(rng, NULL, seed, seed_size);
88-
return rng;
89-
}
90-
91-
extern "C" CDECL uint32_t
92-
rand_next(rust_rng *rng) {
93-
return rng_gen_u32(rng);
94-
}
95-
96-
extern "C" CDECL void
97-
rand_free(rust_rng *rng) {
98-
free(rng);
99-
}
100-
10177
extern "C" CDECL char*
10278
#if defined(__WIN32__)
10379
rust_list_dir_val(WIN32_FIND_DATA* entry_ptr) {

0 commit comments

Comments
 (0)