Temp (FreeBSD): improve CPU temp detection

This commit is contained in:
李通洲
2023-10-10 09:28:31 +08:00
parent 42f6d029b0
commit e7df94495c
3 changed files with 16 additions and 1 deletions
+4 -1
View File
@@ -16,7 +16,10 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
cpu->temperature = FF_CPU_TEMP_UNSET;
if (options->temp)
ffDetectThermalTemp(&cpu->temperature);
{
if (!ffDetectCpuTemp(&cpu->temperature))
ffDetectThermalTemp(&cpu->temperature);
}
return NULL;
}
+11
View File
@@ -1,6 +1,17 @@
#include "temps_bsd.h"
#include "common/sysctl.h"
const char* ffDetectCpuTemp(double* current)
{
int temp = ffSysctlGetInt("dev.cpu.0.temperature", -999999);
if (temp == -999999)
return "ffSysctlGetInt(\"dev.cpu.0.temperature\") failed";
// In tenth of degrees Celsius
*current = (double) temp / 10;
return NULL;
}
const char* ffDetectThermalTemp(double* current)
{
int temp = ffSysctlGetInt("hw.acpi.thermal.tz0.temperature", -999999);
+1
View File
@@ -3,6 +3,7 @@
#ifndef FF_INCLUDED_detection_temps_windows
#define FF_INCLUDED_detection_temps_windows
const char* ffDetectCpuTemp(double* current);
const char* ffDetectThermalTemp(double* current);
#endif