about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-04-21 21:38:59 +0200
committerRalf Jung <post@ralfj.de>2019-04-21 21:54:00 +0200
commit54aefc6a2d076b74921a8d78c5d8c68c13bfa4a7 (patch)
tree684e9762f7380015f78823f2d1d3ed9e8edf6402 /src/libstd/sys
parent31a75a172859d906d8e6a34af4afff9830af495c (diff)
use SecRandomCopyBytes on macOS in Miri
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/rand.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/rand.rs b/src/libstd/sys/unix/rand.rs
index 77f1439e17b..e923b9aa29b 100644
--- a/src/libstd/sys/unix/rand.rs
+++ b/src/libstd/sys/unix/rand.rs
@@ -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 @@ mod imp {
 // 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;