Skip to content

Commit

Permalink
Rollup merge of rust-lang#98042 - DrMeepster:winfred_std_changes, r=C…
Browse files Browse the repository at this point in the history
…hrisDenton

Fix compat_fn option method on miri

This change is required to make `WaitOnAddress` work with rust-lang/miri#2231
  • Loading branch information
Dylan-DPC authored Jun 14, 2022
2 parents f008d44 + 5470a38 commit c3c26ec
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions library/std/src/sys/windows/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,21 +102,23 @@ macro_rules! compat_fn {
}

#[allow(dead_code)]
#[inline(always)]
pub fn option() -> Option<F> {
unsafe { PTR }
unsafe {
if cfg!(miri) {
// Miri does not run `init`, so we just call `get_f` each time.
get_f()
} else {
PTR
}
}
}

#[allow(dead_code)]
pub unsafe fn call($($argname: $argtype),*) -> $rettype {
if let Some(ptr) = PTR {
if let Some(ptr) = option() {
return ptr($($argname),*);
}
if cfg!(miri) {
// Miri does not run `init`, so we just call `get_f` each time.
if let Some(ptr) = get_f() {
return ptr($($argname),*);
}
}
$fallback_body
}
}
Expand Down

0 comments on commit c3c26ec

Please sign in to comment.