[*] Count discontiguous bits in the win32 processor map

This commit is contained in:
Reece Wilson 2021-10-16 00:15:13 +01:00
parent 5e0cc1ccfa
commit 586ec565e1

View File

@ -435,11 +435,22 @@ namespace Aurora::HWInfo
if (sysinfo[i].Relationship == RelationProcessorCore)
{
gCpuInfo.cores++;
auto mask = sysinfo[i].ProcessorMask;
unsigned long offset, count;
BitScanForward(&offset, mask);
BitScanForward(&count, ~(mask >> offset));
gCpuInfo.threads += count;
unsigned long offset {}, tmp;
while (offset != (sizeof(offset) * 8 - 1))
{
// Count the index to a 1
if (BitScanForward(&tmp, mask >> offset) == 0) break; // mask was zero, end of scan
offset += tmp;
// Count the 1's by inverting the bitmap and counting to 1
BitScanForward(&tmp, ~(mask >> offset));
offset += tmp;
// Increment threads by the bits set in
gCpuInfo.threads += tmp;
}
}
else if (sysinfo[i].Relationship == RelationProcessorPackage)
{