Skip to content

Commit 832c7af

Browse files
committed
Don't break windows/rand for miri
1 parent b2e4f9d commit 832c7af

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

library/std/src/sys/windows/rand.rs

+12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ pub fn hashmap_random_keys() -> (u64, u64) {
3838

3939
struct Rng(c::BCRYPT_ALG_HANDLE);
4040
impl Rng {
41+
#[cfg(miri)]
42+
fn open() -> Result<Self, c::NTSTATUS> {
43+
const BCRYPT_RNG_ALG_HANDLE: c::BCRYPT_ALG_HANDLE = ptr::invalid_mut(0x81);
44+
let _ = (
45+
c::BCryptOpenAlgorithmProvider,
46+
c::BCryptCloseAlgorithmProvider,
47+
c::BCRYPT_RNG_ALGORITHM,
48+
c::STATUS_NOT_SUPPORTED,
49+
);
50+
Ok(Self(BCRYPT_RNG_ALG_HANDLE))
51+
}
52+
#[cfg(not(miri))]
4153
// Open a handle to the RNG algorithm.
4254
fn open() -> Result<Self, c::NTSTATUS> {
4355
use crate::sync::atomic::AtomicPtr;

0 commit comments

Comments
 (0)