Xinqi Bao's Git
1 /* See LICENSE file for copyright and license details. */
12 return (pscanf(file
, "%d", &temp
) == 1) ?
13 bprintf("%d", temp
/ 1000) : NULL
;
15 #elif defined(__OpenBSD__)
19 #include <sys/time.h> /* before <sys/sensors.h> for struct timeval */
20 #include <sys/sensors.h>
21 #include <sys/sysctl.h>
24 temp(const char *null
)
32 mib
[2] = 0; /* cpu0 */
34 mib
[4] = 0; /* temp0 */
38 if (sysctl(mib
, 5, &temp
, &size
, NULL
, 0) < 0) {
39 fprintf(stderr
, "sysctl 'SENSOR_TEMP': %s\n",
44 /* kelvin to celsius */
45 return bprintf("%d", (temp
.value
- 273150000) / 1000000);