$OpenBSD: patch-src_modules_temperature_tempget_c,v 1.3 2011/01/16 01:00:11 laurent Exp $
--- src/modules/temperature/tempget.c.orig	Thu Nov 11 14:04:16 2010
+++ src/modules/temperature/tempget.c	Sat Jan  8 17:02:10 2011
@@ -8,6 +8,14 @@
 # include <sys/sysctl.h>
 #endif
 
+#ifdef __OpenBSD__
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/sensors.h>
+#include <errno.h>
+#include <err.h>
+#endif
+
 #include <Ecore.h>
 #include <Ecore_File.h>
 
@@ -19,9 +27,18 @@ static int poll_interval = 32;
 static int cur_poll_interval = 32;
 
 static char *sensor_path = NULL;
-#ifdef __FreeBSD__
+#if defined (__FreeBSD__) || defined (__OpenBSD__)
 static int mib[5];
 #endif
+
+#ifdef __OpenBSD__
+static int dev, numt;
+static struct sensordev snsrdev;  
+static size_t sdlen = sizeof(snsrdev);
+static struct sensor snsr;
+static size_t slen = sizeof(snsr);
+#endif
+
 static Ecore_Poller *poller = NULL;
 static int ptemp = 0;
 
@@ -90,6 +107,24 @@ init(void)
 	/* TODO: FreeBSD can also have more temperature sensors! */
 	sensor_type = SENSOR_TYPE_FREEBSD;
 	sensor_name = strdup("tz0");
+#elif __OpenBSD__ 
+	mib[0] = CTL_HW;
+	mib[1] = HW_SENSORS;
+
+	for (dev = 0; ; dev++) {
+		mib[2] = dev;
+		if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1) {
+			if (errno == ENOENT)    /* no further sensors */
+				break;
+			else
+				continue;                                       
+		}
+		if (strcmp(snsrdev.xname, "cpu0") == 0) {
+			sensor_type = SENSOR_TYPE_OPENBSD;
+			sensor_name = strdup("cpu0");
+			break;
+		}
+	}
 #else
 	therms = ecore_file_ls("/proc/acpi/thermal_zone");
 	if (therms)
@@ -205,6 +240,20 @@ init(void)
 	     sysctlnametomib(sensor_path, mib, &len);
 #endif
 	     break;
+	   case SENSOR_TYPE_OPENBSD:
+#ifdef __OpenBSD__
+		for (numt = 0; numt < snsrdev.maxnumt[SENSOR_TEMP]; numt++) {
+			mib[4] = numt;
+			slen = sizeof(snsr);
+			if (sysctl(mib, 5, &snsr, &slen, NULL, 0) == -1)        
+				continue;
+			if (slen > 0 && (snsr.flags & SENSOR_FINVALID) == 0) {
+				break;
+			}
+               }
+#endif
+
+		break;
 	   case SENSOR_TYPE_OMNIBOOK:
 	     sensor_path = strdup("/proc/omnibook/temperature");
 	     break;
@@ -293,6 +342,16 @@ check(void)
 	  }
 	else
 	  goto error;
+#endif
+	break;
+      case SENSOR_TYPE_OPENBSD:
+#ifdef __OpenBSD__
+	if (sysctl(mib, 5, &snsr, &slen, NULL, 0) != -1) {
+	 temp = (snsr.value - 273150000) / 1000000.0;
+	 ret = 1;
+	}
+	else
+	 goto error;
 #endif
 	break;
       case SENSOR_TYPE_OMNIBOOK:
