about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
authorChris Denton <christophersdenton@gmail.com>2022-09-07 13:14:27 +0100
committerChris Denton <christophersdenton@gmail.com>2022-09-07 14:00:15 +0100
commit832c7af0ea93ec0d0dd121cf0988d82621582475 (patch)
treec7282c571f7ec32b25abcce6785afa4dce078c15 /library/std/src/sys
parentb2e4f9dcb32aafcfa1bd2ab6b291ca84b7db0121 (diff)
downloadrust-832c7af0ea93ec0d0dd121cf0988d82621582475.tar.gz
rust-832c7af0ea93ec0d0dd121cf0988d82621582475.zip
Don't break windows/rand for miri
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/windows/rand.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/library/std/src/sys/windows/rand.rs b/library/std/src/sys/windows/rand.rs
index 3dfa8dba977..d6cd8f80271 100644
--- a/library/std/src/sys/windows/rand.rs
+++ b/library/std/src/sys/windows/rand.rs
@@ -38,6 +38,18 @@ pub fn hashmap_random_keys() -> (u64, u64) {
 
 struct Rng(c::BCRYPT_ALG_HANDLE);
 impl Rng {
+    #[cfg(miri)]
+    fn open() -> Result<Self, c::NTSTATUS> {
+        const BCRYPT_RNG_ALG_HANDLE: c::BCRYPT_ALG_HANDLE = ptr::invalid_mut(0x81);
+        let _ = (
+            c::BCryptOpenAlgorithmProvider,
+            c::BCryptCloseAlgorithmProvider,
+            c::BCRYPT_RNG_ALGORITHM,
+            c::STATUS_NOT_SUPPORTED,
+        );
+        Ok(Self(BCRYPT_RNG_ALG_HANDLE))
+    }
+    #[cfg(not(miri))]
     // Open a handle to the RNG algorithm.
     fn open() -> Result<Self, c::NTSTATUS> {
         use crate::sync::atomic::AtomicPtr;