missing ifaddrs.h header
use argv[0] for executable path

Index: rts/System/Platform/Misc.cpp
--- rts/System/Platform/Misc.cpp.orig
+++ rts/System/Platform/Misc.cpp
@@ -31,6 +31,12 @@
 #elif defined( __FreeBSD__)
 	#include <sys/sysctl.h>
 
+#elif defined(__OpenBSD__)
+	#include <ifaddrs.h>
+	#include <sys/types.h>
+	#include <sys/sysctl.h>
+	#include <unistd.h>
+
 #else
 
 #endif
@@ -220,7 +226,24 @@ namespace Platform
 		if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &cb, nullptr, 0) == 0)
 			procExeFilePath = buf;
 
+		#elif defined(__OpenBSD__)
+		size_t ret;
 
+		if (argv0[0] == '/') {
+    			// absolute path
+    			procExeFilePath = argv0;
+		} else {
+    			// The binary is assumed to be in /usr/local/bin
+    			char buf[PATH_MAX] = "";
+    			ret = strlcpy(buf, "/usr/local/bin/", sizeof(buf));
+    			if (ret >= sizeof(buf))
+				LOG_L(L_WARNING, "[%s] executable directory truncated: %s", __func__, buf);
+    			strlcat(buf, argv0, sizeof(buf));
+    			if (ret >= sizeof(buf))
+				LOG_L(L_WARNING, "[%s] executable path truncated: %s", __func__, buf);
+    			procExeFilePath = buf;
+		}
+
 		#else
 		#error implement this
 		#endif
@@ -748,7 +771,7 @@ namespace Platform
 		return (GetMacType(macAddr, 0), macAddr);
 	}
 
-	#elif defined(__APPLE__)
+	#elif defined(__APPLE__) || defined(__OpenBSD__)
 
 	std::array<uint8_t, 6> GetRawMacAddr() {
 		// TODO: http://lists.freebsd.org/pipermail/freebsd-hackers/2004-June/007415.html
@@ -795,4 +818,11 @@ namespace Platform
 		snprintf(hexAddr.data(), hexAddr.size(), "%02x:%02x:%02x:%02x:%02x:%02x", rawAddr[0], rawAddr[1], rawAddr[2], rawAddr[3], rawAddr[4], rawAddr[5]);
 		return hexAddr;
 	}
+
+#ifdef __OpenBSD__
+	void SetArgv0(const char *s) {
+    		argv0 = s;
+	}
+#endif
+
 } // namespace Platform
