From 8a5e2704e019c4f29eb069d2741771b48bd008fd Mon Sep 17 00:00:00 2001 From: Alastair Poole Date: Tue, 16 Jun 2020 17:29:51 +0100 Subject: [PATCH] freebsd: thermal here sucks. There are modules for more but it's too much. They should use a decent API and not put things all over the place/name space. --- src/bin/system/machine.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/bin/system/machine.c b/src/bin/system/machine.c index 214d2b5..7ab10d1 100644 --- a/src/bin/system/machine.c +++ b/src/bin/system/machine.c @@ -38,9 +38,7 @@ #include #include #include -#if defined(__linux__) -# define BORING_USER 1 -#else +#if !defined(__linux__) # include #endif #include @@ -682,16 +680,17 @@ _sensors_thermal_get(Sys_Info *sysinfo) sensor->value = (snsr.value - 273150000) / 1000000.0; // (uK -> C) } #elif defined(__FreeBSD__) || defined(__DragonFly__) - unsigned int value; + sensor_t *sensor; + int value; size_t len = sizeof(value); - if ((sysctlbyname - ("hw.acpi.thermal.tz0.temperature", &value, &len, NULL, - 0)) != -1) + + if ((sysctlbyname("hw.acpi.thermal.tz0.temperature", &value, &len, NULL, 0)) != -1) { - *temperature = (value - 2732) / 10; + sensors = realloc(sensors, 1 + sysinfo->snsr_count * sizeof(sensor_t *)); + sensors[sysinfo->snsr_count++] = sensor = calloc(1, sizeof(sensor_t)); + sensor->name = strdup("hw.acpi.thermal.tz0"); + sensor->value = (float) (value - 2732) / 10; } - else - *temperature = INVALID_TEMP; #elif defined(__linux__) sensor_t *sensor; struct dirent *dh;