This commit is contained in:
Paul Sajna
2018-03-20 19:45:45 -07:00
parent a24f537a38
commit cc5a4e92ce
+3 -7
View File
@@ -2,9 +2,7 @@
#![feature(core_intrinsics)]
#![feature(global_allocator)]
///! stdlib implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/stdlib.h.html
extern crate ctype;
extern crate errno;
extern crate platform;
@@ -12,7 +10,7 @@ extern crate ralloc;
extern crate rand;
use core::{ptr, str};
use rand::{Rng, XorShiftRng, SeedableRng};
use rand::{Rng, SeedableRng, XorShiftRng};
use errno::*;
use platform::types::*;
@@ -382,15 +380,13 @@ pub extern "C" fn qsort(
#[no_mangle]
pub unsafe extern "C" fn rand() -> c_int {
match RNG {
Some(ref mut rng) => {
rng.gen_range::<c_int>(0, RAND_MAX)
},
Some(ref mut rng) => rng.gen_range::<c_int>(0, RAND_MAX),
None => {
let mut rng = XorShiftRng::from_seed([1; 16]);
let ret = rng.gen_range::<c_int>(0, RAND_MAX);
RNG = Some(rng);
ret
},
}
}
}