shithub: mc

Download patch

ref: 2c4ac1330705a7358cd9946ac5af3308ba1cef23
parent: 164646bf80884c20db57978c56134fb875c9e337
author: Andrew Chambers <andrewchamberss@gmail.com>
date: Tue Mar 1 16:49:52 EST 2016

uname for openbsd

--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -680,8 +680,59 @@
 
 
 /* system information */
-const uname	= {buf;	-> -1}
+const uname	= {buf
+	var mib : int[2]
+	var ret
+	var sys
+	var nod
+	var rel
+	var ver
+	var mach
 
+	ret = 0
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 1 /* KERN_OSTYPE */
+	sys = buf.system[:]
+	ret = sysctl(mib[:], &sys, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 10 /* KERN_HOSTNAME */
+	nod = buf.node[:]
+	ret = sysctl(mib[:], &nod, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 2 /* KERN_OSRELEASE */
+	rel = buf.release[:]
+	ret = sysctl(mib[:], &rel, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 1 /* CTL_KERN */
+	mib[1] = 27 /* KERN_OSVERSION */
+	ver = buf.version[:]
+	ret = sysctl(mib[:], &ver, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	mib[0] = 6 /* CTL_HW */
+	mib[1] = 1 /* HW_MACHINE */
+	mach = buf.machine[:]
+	ret = sysctl(mib[:], &mach, [][:])
+	if ret < 0
+		-> ret
+	;;
+
+	-> 0
+}
+
 const sysctl = {mib, old, new
 	var mibp
 	var mibsz
@@ -696,12 +747,12 @@
 	mibsz = a(mib.len)
 	o = old#
 	oldp = o castto(byte#)
-	oldsz = a(o.len)
+	oldsz = o.len castto(int64)
 	newp = new castto(byte#)
 	newsz = a(new.len)
 
 	/* all args already passed through a() or ar  ptrs */
-	ret = syscall(Sys__sysctl, mibp, mibsz, oldp, oldsz, newp, newsz) castto(int)
+	ret = syscall(Sys__sysctl, mibp, mibsz, oldp, a(&oldsz), newp, newsz) castto(int)
 
 	old# = o[:oldsz]
 	-> ret
--- a/mbld/opts.myr
+++ b/mbld/opts.myr
@@ -50,6 +50,7 @@
 	| "Linux":	opt_sys = "linux"
 	| "Darwin":	opt_sys = "osx"
 	| "FreeBSD":	opt_sys = "freebsd"
+	| "OpenBSD":	opt_sys = "openbsd"
 	| "Plan9":	opt_sys = "plan9"
 	| unknown:	std.fatal("unknown systemy \"{}\"\n", unknown)
 	;;
--- a/mbld/syssel.myr
+++ b/mbld/syssel.myr
@@ -100,6 +100,7 @@
 
 	match opt_sys
 	| "freebsd":	tag(b.sysattrs, ["freebsd", "posixy"][:])
+	| "openbsd":	tag(b.sysattrs, ["openbsd", "posixy"][:])
 	| "osx":	tag(b.sysattrs, ["osx", "posixy"][:])
 	| "linux":	tag(b.sysattrs, ["linux", "posixy"][:])
 	| "plan9":	tag(b.sysattrs, ["plan9"][:])