CPU: use module options

This commit is contained in:
李通洲
2023-06-12 09:56:03 +08:00
parent 8a284ae9a1
commit 56effcb189
7 changed files with 73 additions and 71 deletions
+11 -13
View File
@@ -3,23 +3,17 @@
#include "util/windows/registry.h"
#include "util/mallocHelper.h"
void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFinstance* instance, const FFCPUOptions* options, FFCPUResult* cpu)
{
FF_UNUSED(instance);
cpu->temperature = FF_CPU_TEMP_UNSET;
cpu->coresPhysical = cpu->coresLogical = cpu->coresOnline = 0;
cpu->frequencyMax = cpu->frequencyMin = 0;
ffStrbufInit(&cpu->name);
ffStrbufInit(&cpu->vendor);
{
DWORD length = 0;
GetLogicalProcessorInformationEx(RelationAll, NULL, &length);
if (GetLogicalProcessorInformationEx(RelationAll, NULL, &length) != ERROR_INSUFFICIENT_BUFFER)
return "GetLogicalProcessorInformationEx(RelationAll, NULL, &length) failed";
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* FF_AUTO_FREE
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*)malloc(length);
if(pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
if (pProcessorInfo && GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length))
{
for(
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX* ptr = pProcessorInfo;
@@ -36,11 +30,13 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
}
}
}
else
return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed";
}
FF_HKEY_AUTO_DESTROY hKey;
if(!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, NULL))
return;
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, NULL) failed";
{
uint32_t mhz;
@@ -51,6 +47,8 @@ void ffDetectCPUImpl(const FFinstance* instance, FFCPUResult* cpu)
ffRegReadStrbuf(hKey, L"ProcessorNameString", &cpu->name, NULL);
ffRegReadStrbuf(hKey, L"VendorIdentifier", &cpu->vendor, NULL);
if(instance->config.cpu.temp)
if(options->temp)
ffDetectSmbiosTemp(&cpu->temperature, NULL);
return NULL;
}