44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
/***
|
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
File: CpuBitId.NT.hpp
|
|
Date: 2022-3-16
|
|
Author: Reece
|
|
***/
|
|
#pragma once
|
|
|
|
namespace Aurora::HWInfo
|
|
{
|
|
AuList<unsigned long> CpuBitId::ToCpuSets() const
|
|
{
|
|
AuList<unsigned long> ret;
|
|
|
|
AuUInt8 index {};
|
|
while (CpuBitScanForward(index, index))
|
|
{
|
|
unsigned long logicalProcessorIndex = index % 64;
|
|
unsigned long groupIndex = index / 64;
|
|
ret.push_back(((groupIndex + 1ull) * 0x100ull) + logicalProcessorIndex);
|
|
index++;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
void CpuBitId::ToMsWin7GroupAffinity(void *ptr) const
|
|
{
|
|
auto &logicalProcessorQWord = *AuReinterpretCast<AuUInt64 *>(ptr);
|
|
auto &groupIndexU16 = *AuReinterpretCast<AuUInt16 *>(AuReinterpretCast<AuUInt8 *>(ptr) + 8);
|
|
|
|
AuUInt8 index {};
|
|
while (CpuBitScanForward(index, index))
|
|
{
|
|
AuUInt64 logicalProcessorIndex = index % 64;
|
|
AuUInt64 groupIndex = index / 64;
|
|
|
|
logicalProcessorQWord |= 1ull << logicalProcessorIndex;
|
|
groupIndexU16 = AuUInt16(groupIndex);
|
|
index++;
|
|
}
|
|
}
|
|
} |