AuroraRuntime/Include/Aurora/HWInfo/CpuBitId.NT.inl

51 lines
1.4 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
{
extern AUKN_SYM AuUInt32 gWin32CPUSetLookupTable[512];
AuList<unsigned long> CpuBitId::ToCpuSets() const
{
AuList<unsigned long> ret;
AuUInt8 index {};
while (CpuBitScanForward(index, index))
{
#if defined(AURORA_RUNTIME_USE_FAST_CPUSETS)
unsigned long logicalProcessorIndex = index % 64;
unsigned long groupIndex = index / 64;
ret.push_back(((groupIndex + 1ull) * 0x100ull) + logicalProcessorIndex);
index++;
#else
ret.push_back(gWin32CPUSetLookupTable[index]);
index++;
#endif
}
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++;
}
}
}