summaryrefslogtreecommitdiff
path: root/lib/sys
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2017-06-24 22:51:30 -0700
committerOri Bernstein <ori@eigenstate.org>2017-06-25 01:08:54 -0700
commitde496a920339b8285ca2e9225b1abff7af54698a (patch)
tree83e687c294b897909d326bfe30631e59a2dfdaee /lib/sys
parentad0ad265bd4ec05c365a821df171df9d60cd224d (diff)
downloadmc-de496a920339b8285ca2e9225b1abff7af54698a.tar.gz
Use an iovec struct for readv/writev
This avoids the assumption that iovec and byte[:] are laid out the same way in memory.
Diffstat (limited to 'lib/sys')
-rw-r--r--lib/sys/sys+freebsd-x64.myr13
-rw-r--r--lib/sys/sys+netbsd-x64.myr13
-rw-r--r--lib/sys/sys+openbsd-x64.myr13
3 files changed, 27 insertions, 12 deletions
diff --git a/lib/sys/sys+freebsd-x64.myr b/lib/sys/sys+freebsd-x64.myr
index 9225965..368359c 100644
--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -178,6 +178,11 @@ pkg sys =
spare : void#[3] /* padding */
;;
+ type iovec = struct
+ base : byte#
+ len : uint64
+ ;;
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
@@ -829,10 +834,10 @@ pkg sys =
const unlink : (path:byte[:] -> int)
const read : (fd:fd, buf:byte[:] -> size)
const pread : (fd:fd, buf:byte[:], off : off -> size)
- const readv : (fd:fd, iov:byte[:][:] -> size)
+ const readv : (fd:fd, iov:iovec[:] -> size)
const write : (fd:fd, buf:byte[:] -> size)
const pwrite : (fd:fd, buf:byte[:], off : off -> size)
- const writev : (fd:fd, iov : byte[:][:] -> size)
+ const writev : (fd:fd, iov : iovec[:] -> size)
const lseek : (fd:fd, off : off, whence : whence -> int64)
const stat : (path:byte[:], sb:statbuf# -> int64)
const lstat : (path:byte[:], sb:statbuf# -> int64)
@@ -962,10 +967,10 @@ const creat = {path, mode; -> (openmode(path, Ocreat | Otrunc | Owronly, mode)
const unlink = {path; -> (syscall(Sysunlink, cstring(path)) : int)}
const read = {fd, buf; -> (syscall(Sysread, a(fd), (buf : byte#), a(buf.len)) : size)}
const pread = {fd, buf, off; -> (syscall(Syspread, a(fd), (buf : byte#), a(buf.len), a(off)) : size)}
-const readv = {fd, vec; -> (syscall(Sysreadv, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
+const readv = {fd, vec; -> (syscall(Sysreadv, a(fd), (vec : iovec#), a(vec.len)) : size)}
const write = {fd, buf; -> (syscall(Syswrite, a(fd), (buf : byte#), a(buf.len)) : size)}
const pwrite = {fd, buf, off; -> (syscall(Syspwrite, a(fd), (buf : byte#), a(buf.len), a(off)) : size)}
-const writev = {fd, vec; -> (syscall(Syswritev, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
+const writev = {fd, vec; -> (syscall(Syswritev, a(fd), (vec : iovec#), a(vec.len)) : size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, a(fd), a(off), a(whence))}
const stat = {path, sb; -> syscall(Sysstat, cstring(path), a(sb))}
const lstat = {path, sb; -> syscall(Syslstat, cstring(path), a(sb))}
diff --git a/lib/sys/sys+netbsd-x64.myr b/lib/sys/sys+netbsd-x64.myr
index b5285ac..8c0a7c1 100644
--- a/lib/sys/sys+netbsd-x64.myr
+++ b/lib/sys/sys+netbsd-x64.myr
@@ -170,6 +170,11 @@ pkg sys =
spare : void#[3] /* padding */
;;
+ type iovec = struct
+ base : byte#
+ len : uint64
+ ;;
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
@@ -848,10 +853,10 @@ pkg sys =
const unlink : (path:byte[:] -> int)
const read : (fd:fd, buf:byte[:] -> size)
const pread : (fd:fd, buf:byte[:], off : off -> size)
- const readv : (fd:fd, iov:byte[:][:] -> size)
+ const readv : (fd:fd, iov:iovec[:] -> size)
const write : (fd:fd, buf:byte[:] -> size)
const pwrite : (fd:fd, buf:byte[:], off : off -> size)
- const writev : (fd:fd, iov : byte[:][:] -> size)
+ const writev : (fd:fd, iov:iovec[:] -> size)
const lseek : (fd:fd, off : off, whence : whence -> int64)
const stat : (path:byte[:], sb:statbuf# -> int64)
const lstat : (path:byte[:], sb:statbuf# -> int64)
@@ -980,10 +985,10 @@ const creat = {path, mode; -> (openmode(path, Ocreat | Otrunc | Owronly, mode)
const unlink = {path; -> (syscall(Sysunlink, cstring(path)) : int)}
const read = {fd, buf; -> (syscall(Sysread, a(fd), (buf : byte#), a(buf.len)) : size)}
const pread = {fd, buf, off; -> (syscall(Syspread, a(fd), (buf : byte#), a(buf.len), a(off)) : size)}
-const readv = {fd, vec; -> (syscall(Sysreadv, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
+const readv = {fd, vec; -> (syscall(Sysreadv, a(fd), (vec : iovec#), a(vec.len)) : size)}
const write = {fd, buf; -> (syscall(Syswrite, a(fd), (buf : byte#), a(buf.len)) : size)}
const pwrite = {fd, buf, off; -> (syscall(Syspwrite, a(fd), (buf : byte#), a(buf.len), a(off)) : size)}
-const writev = {fd, vec; -> (syscall(Syswritev, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
+const writev = {fd, vec; -> (syscall(Syswritev, a(fd), (vec : iovec#), a(vec.len)) : size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, a(fd), a(off), a(whence))}
const stat = {path, sb; -> syscall(Sys__stat50, cstring(path), a(sb))}
const lstat = {path, sb; -> syscall(Sys__lstat50, cstring(path), a(sb))}
diff --git a/lib/sys/sys+openbsd-x64.myr b/lib/sys/sys+openbsd-x64.myr
index aa3a140..b5d951a 100644
--- a/lib/sys/sys+openbsd-x64.myr
+++ b/lib/sys/sys+openbsd-x64.myr
@@ -156,6 +156,11 @@ pkg sys =
name : byte[256]
;;
+ type iovec = struct
+ base : byte#
+ len : uint64
+ ;;
+
/* open options */
const Ordonly : fdopt = 0x0
const Owronly : fdopt = 0x1
@@ -566,10 +571,10 @@ pkg sys =
const unlink : (path:byte[:] -> int)
const read : (fd:fd, buf:byte[:] -> size)
const pread : (fd:fd, buf:byte[:], off : off -> size)
- const readv : (fd:fd, iov:byte[:][:] -> size)
+ const readv : (fd:fd, iov:iovec[:] -> size)
const write : (fd:fd, buf:byte[:] -> size)
const pwrite : (fd:fd, buf:byte[:], off : off -> size)
- const writev : (fd:fd, iov : byte[:][:] -> size)
+ const writev : (fd:fd, iov:iovec[:] -> size)
const lseek : (fd:fd, off : off, whence : whence -> int64)
const stat : (path:byte[:], sb:statbuf# -> int64)
const lstat : (path:byte[:], sb:statbuf# -> int64)
@@ -694,10 +699,10 @@ const creat = {path, mode; -> (openmode(path, Ocreat | Otrunc | Owronly, mode)
const unlink = {path; -> (syscall(Sysunlink, cstring(path)) : int)}
const read = {fd, buf; -> (syscall(Sysread, a(fd), (buf : byte#), a(buf.len)) : size)}
const pread = {fd, buf, off; -> (syscall(Syspread, a(fd), (buf : byte#), a(buf.len), a(off)) : size)}
-const readv = {fd, vec; -> (syscall(Sysreadv, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
+const readv = {fd, vec; -> (syscall(Sysreadv, a(fd), (vec : iovec#), a(vec.len)) : size)}
const write = {fd, buf; -> (syscall(Syswrite, a(fd), (buf : byte#), a(buf.len)) : size)}
const pwrite = {fd, buf, off; -> (syscall(Syspwrite, a(fd), (buf : byte#), a(buf.len), a(off)) : size)}
-const writev = {fd, vec; -> (syscall(Syswritev, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
+const writev = {fd, vec; -> (syscall(Syswritev, a(fd), (vec : iovec#), a(vec.len)) : size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, a(fd), a(off), a(whence))}
const stat = {path, sb; -> syscall(Sysstat, cstring(path), a(sb))}
const lstat = {path, sb; -> syscall(Syslstat, cstring(path), a(sb))}