Skip to content

Commit

Permalink
Don't break windows/rand for miri
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDenton committed Sep 7, 2022
1 parent b2e4f9d commit 832c7af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions library/std/src/sys/windows/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 832c7af

Please sign in to comment.