| 23 | |
| 24 | #if !defined(_M_ARM64) |
| 25 | int GetLogicalProcessorCountInWindows() { |
| 26 | DWORD returnLength = 0; |
| 27 | vector<unsigned char> buffer; |
| 28 | PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX info = nullptr; |
| 29 | // First, call to get the size of the data needed. |
| 30 | GetLogicalProcessorInformationEx(RelationAll, NULL, &returnLength); |
| 31 | buffer.resize(returnLength); |
| 32 | // Now retrieve the data. |
| 33 | if (GetLogicalProcessorInformationEx(RelationAll, reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *>(buffer.data()), &returnLength)) { |
| 34 | int logicalProcessorCount = 0; |
| 35 | DWORD offset = 0; |
| 36 | // Parse the returned buffer for processor information |
| 37 | while (offset < returnLength) { |
| 38 | info = reinterpret_cast<SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *>(buffer.data() + offset); |
| 39 | if (info->Relationship == RelationProcessorCore) { |
| 40 | // For each core, count the number of set bits in the GroupMask |
| 41 | for (int i = 0; i < info->Processor.GroupCount; ++i) { |
| 42 | auto mask = info->Processor.GroupMask[i].Mask; |
| 43 | // Count bits set to 1 in the processor mask |
| 44 | while (mask) { |
| 45 | logicalProcessorCount += (mask & 1); |
| 46 | mask >>= 1; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | offset += info->Size; |
| 51 | } |
| 52 | return logicalProcessorCount; |
| 53 | } |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | bool g_isVHSet = false; |
| 58 | void ( * g_HwBpHandler ) ( int, void * ) = nullptr; |
no test coverage detected