about summary refs log tree commit diff
path: root/src/libstd/sys/unix/rand.rs
diff options
context:
space:
mode:
authorJeremy Soller <jeremy@system76.com>2019-04-07 08:39:54 -0600
committerJeremy Soller <jeremy@system76.com>2019-08-06 16:18:23 -0600
commit0498da9a3dc061f604fcfb9b56bd889e07f2b7e2 (patch)
treec297dc9d51cd63c0a1297426ae3633e3921dcb44 /src/libstd/sys/unix/rand.rs
parent6a91782b72fca586b15ba68364bc7baab837af86 (diff)
downloadrust-0498da9a3dc061f604fcfb9b56bd889e07f2b7e2.tar.gz
rust-0498da9a3dc061f604fcfb9b56bd889e07f2b7e2.zip
redox: convert to target_family unix
Diffstat (limited to 'src/libstd/sys/unix/rand.rs')
-rw-r--r--src/libstd/sys/unix/rand.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs
index 71c62461ee9..c5be1763302 100644
--- a/src/libstd/sys/unix/rand.rs
+++ b/src/libstd/sys/unix/rand.rs
@@ -15,7 +15,8 @@ pub fn hashmap_random_keys() -> (u64, u64) {
           not(target_os = "ios"),
           not(target_os = "openbsd"),
           not(target_os = "freebsd"),
-          not(target_os = "fuchsia")))]
+          not(target_os = "fuchsia"),
+          not(target_os = "redox")))]
 mod imp {
     use crate::fs::File;
     use crate::io::Read;
@@ -174,3 +175,15 @@ mod imp {
         unsafe { zx_cprng_draw(v.as_mut_ptr(), v.len()) }
     }
 }
+
+#[cfg(target_os = "redox")]
+mod imp {
+    use crate::fs::File;
+    use crate::io::Read;
+
+    pub fn fill_bytes(v: &mut [u8]) {
+        // Open rand:, read from it, and close it again.
+        let mut file = File::open("rand:").expect("failed to open rand:");
+        file.read_exact(v).expect("failed to read rand:")
+    }
+}