Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
12 if(pscanf(file
, "%d", &temp
) != 1) {
16 return bprintf("%d", temp
/ 1000);
18 #elif defined(__OpenBSD__)
20 #include <sys/time.h> /* before <sys/sensors.h> for struct timeval */
21 #include <sys/sensors.h>
22 #include <sys/sysctl.h>
25 temp(const char *unused
)
33 mib
[2] = 0; /* cpu0 */
35 mib
[4] = 0; /* temp0 */
39 if (sysctl(mib
, 5, &temp
, &size
, NULL
, 0) < 0) {
40 warn("sysctl 'SENSOR_TEMP':");
44 /* kelvin to celsius */
45 return bprintf("%d", (temp
.value
- 273150000) / 1E6
);