summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2016-03-02 22:34:18 +1300
committerOri Bernstein <ori@eigenstate.org>2016-05-08 17:20:44 +1200
commit15127e35827c55fcb3310e8b71351bd4420b2b0d (patch)
tree2c29c6fe57d65762a9c8f8a244d8b5d3b12e837d
parent2c4ac1330705a7358cd9946ac5af3308ba1cef23 (diff)
downloadmc-15127e35827c55fcb3310e8b71351bd4420b2b0d.tar.gz
Fix several openbsd syscalls.
-rw-r--r--lib/std/dir+openbsd.myr25
-rw-r--r--lib/std/syswrap-ss+openbsd.myr14
-rw-r--r--lib/sys/sys+openbsd-x64.myr39
-rw-r--r--mbld/deps.myr2
4 files changed, 35 insertions, 45 deletions
diff --git a/lib/std/dir+openbsd.myr b/lib/std/dir+openbsd.myr
index 6190b56..e4c677c 100644
--- a/lib/std/dir+openbsd.myr
+++ b/lib/std/dir+openbsd.myr
@@ -1,12 +1,13 @@
use sys
-use "alloc.use"
-use "die.use"
-use "option.use"
-use "result.use"
-use "slcp.use"
-use "sldup.use"
-use "types.use"
+use "alloc"
+use "die"
+use "memops"
+use "option"
+use "result"
+use "slcp"
+use "sldup"
+use "types"
pkg std =
type dir = struct
@@ -14,7 +15,6 @@ pkg std =
buf : byte[16384]
len : int64
off : int64
- base : int64
;;
const diropen : (p : byte[:] -> std.result(dir#, byte[:]))
@@ -38,9 +38,10 @@ const diropen = {p
const dirread = {d
var len
var dent
+ var namelen
if d.off >= d.len
- len = sys.getdirentries(d.fd, d.buf[:], &d.base)
+ len = sys.getdents(d.fd, d.buf[:])
if len <= 0
-> `None
;;
@@ -49,8 +50,12 @@ const dirread = {d
;;
dent = &d.buf[d.off] castto(sys.dirent#)
+ namelen = 0
d.off += dent.reclen castto(int64)
- -> `Some sldup(dent.name[:dent.namelen])
+ while dent.name[namelen] != 0
+ namelen++
+ ;;
+ -> `Some sldup(dent.name[:namelen])
}
const dirclose = {d
diff --git a/lib/std/syswrap-ss+openbsd.myr b/lib/std/syswrap-ss+openbsd.myr
index 15bb6fa..0d6e3fb 100644
--- a/lib/std/syswrap-ss+openbsd.myr
+++ b/lib/std/syswrap-ss+openbsd.myr
@@ -5,20 +5,12 @@ use "slcp.use"
use "die.use"
pkg std =
- const exit : (status:int -> void)
+ $noret const exit : (status:int -> void)
pkglocal const bgetcwd : (buf : byte[:] -> errno)
;;
const exit = {status; sys.exit(status)}
-const bgetcwd = {buf
- var res
- res = sys.__getcwd(buf) castto(errno)
- if res == 0
- -> cstrlen(buf) castto(errno)
- elif res == Enomem
- -> Erange
- else
- -> res
- ;;
+const bgetcwd = {buf
+ -> sys.__getcwd(buf) castto(errno)
}
diff --git a/lib/sys/sys+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index 8efb7de..72269bc 100644
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -69,9 +69,9 @@ pkg sys =
type statbuf = struct
dev : uint32
- ino : uint32
+ ino : uint64
mode : filemode
- nlink : uint16
+ nlink : uint32
uid : uint32
gid : uint32
rdev : uint32
@@ -118,6 +118,12 @@ pkg sys =
scope : uint32
;;
+ type sockaddr_un = struct
+ len : uint8
+ fam : sockfam
+ path : byte[104]
+ ;;
+
type sockaddr_storage = struct
len : byte
fam : sockfam
@@ -127,12 +133,13 @@ pkg sys =
;;
type dirent = struct
- fileno : uint32
+ fileno : uint64
+ off : uint64
reclen : uint16
- ftype : filetype
- namelen : uint8
+ ftype : uint8
+ namlen : uint8
name : byte[256]
- ;;
+ ;;
type rtprio = struct
rttype : uint16
@@ -500,12 +507,6 @@ pkg sys =
/* wrappers to extract wait status */
const waitstatus : (st : int32 -> waitstatus)
- /* thread control */
- const thr_new : (param : thrparam#, paramsz : int -> int)
- const thr_exit : (state : int64# -> void)
- const umtx_op : (obj : void#, op : umtxop, val : uint64, a1 : void#, a2 : void# -> int)
- const yield : (-> int)
-
/* fd manipulation */
const open : (path:byte[:], opts:fdopt -> fd)
const openmode : (path:byte[:], opts:fdopt, mode:int64 -> fd)
@@ -520,7 +521,7 @@ pkg sys =
const fstat : (fd:fd, sb:statbuf# -> int64)
const mkdir : (path : byte[:], mode : int64 -> int64)
generic ioctl : (fd:fd, req : int64, arg:@a# -> int64)
- const getdirentries : (fd : fd, buf : byte[:], basep : int64# -> int64)
+ const getdents : (fd : fd, buf : byte[:] -> int64)
const chdir : (p : byte[:] -> int64)
const __getcwd : (buf : byte[:] -> int64)
@@ -621,13 +622,6 @@ const execve = {cmd, args, env
-> syscall(Sysexecve, cstring(cmd), a(p), a(cenv))
}
-/* thread management */
-
-const thr_new = {param, sz; -> -1}
-const thr_exit = {state; -> void}
-const umtx_op = {obj, op, val, a1, a2; -> -1}
-const yield = {; -> -1}
-
/* fd manipulation */
const open = {path, opts; -> syscall(Sysopen, cstring(path), a(opts), a(0o777)) castto(fd)}
const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), a(opts), a(mode)) castto(fd)}
@@ -641,11 +635,10 @@ const stat = {path, sb; -> syscall(Sysstat, cstring(path), a(sb))}
const lstat = {path, sb; -> syscall(Syslstat, cstring(path), a(sb))}
const fstat = {fd, sb; -> syscall(Sysfstat, a(fd), a(sb))}
const mkdir = {path, mode; -> syscall(Sysmkdir, cstring(path), a(mode)) castto(int64)}
-generic ioctl = {fd, req, arg; -> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)
-}
-const getdirentries = {fd, buf, basep; -> -1}
+generic ioctl = {fd, req, arg; -> syscall(Sysioctl, a(fd), a(req), a(arg)) castto(int64)}
const chdir = {dir; -> syscall(Syschdir, cstring(dir))}
const __getcwd = {buf; -> syscall(Sys__getcwd, a(buf), a(buf.len))}
+const getdents = {fd, buf; -> syscall(Sysgetdents, a(buf), a(buf.len)) castto(int64)}
/* file stuff */
const pipe = {fds; -> __freebsd_pipe(fds)}
diff --git a/mbld/deps.myr b/mbld/deps.myr
index 9d2d14a..4368205 100644
--- a/mbld/deps.myr
+++ b/mbld/deps.myr
@@ -386,7 +386,7 @@ const openlib = {lib, incs
;;
std.fput(std.Err, "could not find library {}\n", lib)
- :error
+:error
std.fput(std.Err, "search path is:\n")
for p in incs
std.fput(std.Err, "\t{}\n", p)