8 #if defined(__FreeBSD__)
10 #include <sys/types.h>
11 #include <sys/sysctl.h>
13 #define TZ_KELVTOC(x) (((x) - TZ_ZEROC) / 10), abs(((x) - TZ_ZEROC) % 10)
18 * Reads the CPU temperature from /sys/class/thermal/thermal_zone0/temp and
19 * returns the temperature in degree celcius.
22 const char *get_cpu_temperature_info() {
27 slurp(thermal_zone, buf, sizeof(buf));
28 temp = strtol(buf, NULL, 10);
29 if (temp == LONG_MIN || temp == LONG_MAX || temp <= 0)
30 (void)snprintf(buf, sizeof(buf), "T: ? C");
32 (void)snprintf(buf, sizeof(buf), "T: %ld C", (temp/1000));
33 #elif defined(__FreeBSD__)
35 size_t sysctl_size = sizeof (sysctl_rslt);
36 if (sysctlbyname(thermal_zone,&sysctl_rslt,&sysctl_size,NULL,0))
39 snprintf(buf,sizeof(buf),"T: %d.%d C",TZ_KELVTOC(sysctl_rslt));