Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions library/std/src/sys/windows/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,21 @@ macro_rules! compat_fn {

#[allow(dead_code)]
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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super hot code, do we want inline(always) on option to ensure it doesn't get slowed down too much?

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