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 *file
) 
  30                 UNUSED(file
); /* no temperature file on OpenBSD */ 
  34                 mib
[2] = 0; /* cpu0 */ 
  36                 mib
[4] = 0; /* temp0 */ 
  40                 if (sysctl(mib
, 5, &temp
, &size
, NULL
, 0) < 0) { 
  41                         fprintf(stderr
, "sysctl 'SENSOR_TEMP': %s\n", 
  46                 /* kelvin to celsius */ 
  47                 return bprintf("%d", (temp
.value 
- 273150000) / 1000000);