Skip to content

Commit

Permalink
miri: teach about GetActiveProcessorCount
Browse files Browse the repository at this point in the history
  • Loading branch information
klensy committed Aug 16, 2023
1 parent ebd39e5 commit 4dfdc9d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/tools/miri/src/shims/windows/foreign_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
)?;
}

// Number of cores, but more accurate vaulue, than GetSystemInfo.dwNumberOfProcessors
// if number of cores > 64. If called with ALL_PROCESSOR_GROUPS as groupnumber,
// returns total number of cores, instead of number in group, see
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getactiveprocessorcount
"GetActiveProcessorCount" => {
let [groupnumber] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
this.read_scalar(groupnumber)?.to_u16()?;
this.write_scalar(Scalar::from_u32(this.machine.num_cpus), dest)?;
}

// Thread-local storage
"TlsAlloc" => {
// This just creates a key; Windows does not natively support TLS destructors.
Expand Down

0 comments on commit 4dfdc9d

Please sign in to comment.