From 36a452c852146cfaa15dab7df2fcbc2fb87bed8d Mon Sep 17 00:00:00 2001 From: Carter Li Date: Wed, 19 Feb 2025 08:53:16 +0800 Subject: [PATCH] CPU (NetBSD): support non-intel CPUs Fix #1573 --- src/detection/cpu/cpu_nbsd.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/detection/cpu/cpu_nbsd.c b/src/detection/cpu/cpu_nbsd.c index 4d9530b5..11888729 100644 --- a/src/detection/cpu/cpu_nbsd.c +++ b/src/detection/cpu/cpu_nbsd.c @@ -42,10 +42,11 @@ static const char* detectCpuTemp(double* current) const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) { - if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != NULL) + if (ffSysctlGetString("machdep.cpu_brand", &cpu->name) != NULL && + ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != NULL && + ffSysctlGetString("hw.cpu0.name", &cpu->name) != NULL) { - if (ffSysctlGetString("machdep.dmi.processor-version", &cpu->name) != NULL) - return "sysctlbyname(machdep.cpu_brand) failed"; + ffStrbufSetS(&cpu->name, "Unknown CPU"); } if (ffSysctlGetString("machdep.dmi.processor-vendor", &cpu->vendor) == NULL) @@ -58,6 +59,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu) ffCPUDetectSpeedByCpuid(cpu); uint32_t freq = (uint32_t) ffSysctlGetInt("machdep.cpu.frequency.target", 0); + if (freq == 0) freq = (uint32_t) (ffSysctlGetInt64("hw.cpu0.clock_frequency", 0) / 1000000); if (freq > cpu->frequencyBase) cpu->frequencyBase = freq; cpu->temperature = FF_CPU_TEMP_UNSET;