Skip to content

Commit 4dfdc9d

Browse files
committed
miri: teach about GetActiveProcessorCount
1 parent ebd39e5 commit 4dfdc9d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/tools/miri/src/shims/windows/foreign_items.rs

+10
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
203203
)?;
204204
}
205205

206+
// Number of cores, but more accurate vaulue, than GetSystemInfo.dwNumberOfProcessors
207+
// if number of cores > 64. If called with ALL_PROCESSOR_GROUPS as groupnumber,
208+
// returns total number of cores, instead of number in group, see
209+
// https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-getactiveprocessorcount
210+
"GetActiveProcessorCount" => {
211+
let [groupnumber] = this.check_shim(abi, Abi::System { unwind: false }, link_name, args)?;
212+
this.read_scalar(groupnumber)?.to_u16()?;
213+
this.write_scalar(Scalar::from_u32(this.machine.num_cpus), dest)?;
214+
}
215+
206216
// Thread-local storage
207217
"TlsAlloc" => {
208218
// This just creates a key; Windows does not natively support TLS destructors.

0 commit comments

Comments
 (0)