summaryrefslogtreecommitdiff
path: root/lib/sys/sys+openbsd-x64.myr
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-11-20 18:30:55 -0800
committerOri Bernstein <ori@eigenstate.org>2016-11-20 18:30:55 -0800
commit0103ef37062ff55596da4d6ada8f75ae898885bc (patch)
treefde9191647fc76bf23a5b8f54d6a72f176627de1 /lib/sys/sys+openbsd-x64.myr
parent5519708b4c280661204744f50e140298919dd718 (diff)
downloadmc-0103ef37062ff55596da4d6ada8f75ae898885bc.tar.gz
Fix sysctl signature.
The previous one worked, but was really painful to use well for what it was intended.
Diffstat (limited to 'lib/sys/sys+openbsd-x64.myr')
-rw-r--r--lib/sys/sys+openbsd-x64.myr66
1 files changed, 25 insertions, 41 deletions
diff --git a/lib/sys/sys+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index 3b5ec0b..c267a7b 100644
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -527,7 +527,10 @@ pkg sys =
/* system information */
const uname : (buf : utsname# -> int)
- const sysctl : (mib : int[:], old : byte[:]#, new : byte[:] -> int)
+ const sysctl : (mib : int[:], \
+ old : void#, oldsz : size#, \
+ new : void#, newsz : size# \
+ -> int)
/* filled by start code */
extern const __cenvp : byte##
@@ -542,6 +545,7 @@ generic a = {x : @t; -> (x : uint64)}
extern const cstring : (str : byte[:] -> byte#)
extern const alloca : (sz : size -> byte#)
+extern const __cenvp : byte##
extern const __freebsd_pipe : (fds : fd[2]# -> int64)
@@ -654,49 +658,48 @@ const nanosleep = {req, rem; -> (syscall(Sysnanosleep, a(req), a(rem)) : int32)}
const uname = {buf
var mib : int[2]
var ret
- var sys
- var nod
- var rel
- var ver
- var mach
+ var sys, syssz
+ var nod, nodsz
+ var rel, relsz
+ var ver, versz
+ var mach, machsz
ret = 0
mib[0] = 1 /* CTL_KERN */
mib[1] = 1 /* KERN_OSTYPE */
- sys = buf.system[:]
- ret = sysctl(mib[:], &sys, [][:])
+ sys = (buf.system[:] : void#)
+ syssz = buf.system.len
+ ret = sysctl(mib[:], sys, &syssz, (0 : void#), (0 : size#))
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, [][:])
+ rel = (buf.release[:] : void#)
+ relsz = buf.release.len
+ ret = sysctl(mib[:], rel, &relsz, (0 : void#), (0 : size#))
if ret < 0
-> ret
;;
mib[0] = 1 /* CTL_KERN */
mib[1] = 27 /* KERN_OSVERSION */
- ver = buf.version[:]
- ret = sysctl(mib[:], &ver, [][:])
+ ver = (buf.version[:] : void#)
+ versz = buf.version.len
+ ret = sysctl(mib[:], ver, &versz, (0 : void#), (0 : size#))
if ret < 0
-> ret
;;
mib[0] = 6 /* CTL_HW */
mib[1] = 1 /* HW_MACHINE */
- mach = buf.machine[:]
- ret = sysctl(mib[:], &mach, [][:])
+ mach = (buf.machine[:] : void#)
+ machsz = buf.machine.len
+ ret = sysctl(mib[:], mach, &machsz, (0 : void#), (0 : size#))
if ret < 0
-> ret
;;
@@ -704,29 +707,10 @@ const uname = {buf
-> 0
}
-const sysctl = {mib, old, new
- var mibp
- var mibsz
- var o
- var oldp
- var oldsz
- var newp
- var newsz
- var ret
-
- mibp = (mib : byte#)
- mibsz = a(mib.len)
- o = old#
- oldp = (o : byte#)
- oldsz = (o.len : int64)
- newp = (new : byte#)
- newsz = a(new.len)
-
+const sysctl = {mib, old, oldsz, new, newsz
/* all args already passed through a() or ar ptrs */
- ret = (syscall(Sys__sysctl, mibp, mibsz, oldp, a(&oldsz), newp, newsz) : int)
-
- old# = o[:oldsz]
- -> ret
+ -> (syscall(Sys__sysctl, \
+ (mib : int#), a(mib.len), old, oldsz, new, newsz) : int)
}
const clockid = {clk