Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
5 #include <sys/sysctl.h>
7 #include <sys/sensors.h>
9 #include "../../util.h"
12 temp(const char *null
)
20 mib
[2] = 0; /* cpu0 */
22 mib
[4] = 0; /* temp0 */
26 if (sysctl(mib
, 5, &temp
, &size
, NULL
, 0) == -1) {
27 fprintf(stderr
, "sysctl 'SENSOR_TEMP': %s\n", strerror(errno
));
31 return bprintf("%d", (temp
.value
- 273150000) / 1000000); /* kelvin to celsius */