]> git.lizzy.rs Git - rust.git/commitdiff
use SecRandomCopyBytes on macOS in Miri
authorRalf Jung <post@ralfj.de>
Sun, 21 Apr 2019 19:38:59 +0000 (21:38 +0200)
committerRalf Jung <post@ralfj.de>
Sun, 21 Apr 2019 19:54:00 +0000 (21:54 +0200)
src/libstd/sys/unix/rand.rs

index 77f1439e17b10324c7d67d25ab036d7755a27922..e923b9aa29b0117d0d4144f9539e4ba0fd245241 100644 (file)
@@ -13,6 +13,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
 
 #[cfg(all(unix,
           not(target_os = "ios"),
+          not(all(target_os = "macos", miri)),
           not(target_os = "openbsd"),
           not(target_os = "freebsd"),
           not(target_os = "fuchsia")))]
@@ -106,7 +107,9 @@ pub fn fill_bytes(v: &mut [u8]) {
 // once per thread in `hashmap_random_keys`. Therefore `SecRandomCopyBytes` is
 // only used on iOS where direct access to `/dev/urandom` is blocked by the
 // sandbox.
-#[cfg(target_os = "ios")]
+// HACK: However, we do use this when running in Miri on macOS; intercepting this is much
+// easier than intercepting accesses to /dev/urandom.
+#[cfg(any(target_os = "ios", all(target_os = "macos", miri)))]
 mod imp {
     use crate::io;
     use crate::ptr;