1 #[cfg(not(feature = "fuzztarget"))]
3 use rand::{thread_rng,Rng};
5 pub fn fill_bytes(data: &mut [u8]) {
6 let mut rng = thread_rng();
10 pub fn rand_f32() -> f32 {
11 let mut rng = thread_rng();
15 #[cfg(not(feature = "fuzztarget"))]
16 pub use self::real_rng::*;
18 #[cfg(feature = "fuzztarget")]
22 static mut RNG_ITER: u64 = 0;
24 pub fn fill_bytes(data: &mut [u8]) {
25 let rng = unsafe { RNG_ITER += 1; RNG_ITER -1 };
26 for i in 0..data.len() / 8 {
27 data[i*8..(i+1)*8].copy_from_slice(&byte_utils::be64_to_array(rng));
29 let rem = data.len() % 8;
30 let off = data.len() - rem;
31 data[off..].copy_from_slice(&byte_utils::be64_to_array(rng)[0..rem]);
34 pub fn rand_f32() -> f32 {
35 let rng = unsafe { RNG_ITER += 1; RNG_ITER - 1 };
36 f64::from_bits(rng) as f32
39 pub fn reset_rng_state() {
40 unsafe { RNG_ITER = 0; }
43 #[cfg(feature = "fuzztarget")]
44 pub use self::fuzzy_rng::*;