shithub: mc

Download patch

ref: fbafcadef80bcb3f2ecdd7c6162c2eea5b3ed8b4
parent: 96203fff1cc3c06bea79801d9af38c40e556d74a
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Dec 7 09:25:25 EST 2016

Add readv()/writev()

	Turns out that an iovec is abi compatible with a slice.
	That makes using it nice.

--- a/lib/sys/sys+freebsd-x64.myr
+++ b/lib/sys/sys+freebsd-x64.myr
@@ -821,7 +821,9 @@
 	const creat	: (path:byte[:], mode:int64 -> fd)
 	const unlink	: (path:byte[:] -> int)
 	const read	: (fd:fd, buf:byte[:] -> size)
+	const readv	: (fd:fd, iov:byte[:][:] -> size)
 	const write	: (fd:fd, buf:byte[:] -> size)
+	const writev	: (fd:fd, iov : byte[:][:] -> size)
 	const lseek	: (fd:fd, off : off, whence : whence -> int64)
 	const stat	: (path:byte[:], sb:statbuf# -> int64)
 	const lstat	: (path:byte[:], sb:statbuf# -> int64)
@@ -951,7 +953,9 @@
 const creat	= {path, mode;		-> (openmode(path, Ocreat | Otrunc | Owronly, mode) : fd)}
 const unlink	= {path;		-> (syscall(Sysunlink, cstring(path)) : int)}
 const read	= {fd, buf;		-> (syscall(Sysread, a(fd), (buf : byte#), a(buf.len)) : size)}
+const readv	= {fd, vec;		-> (syscall(Sysreadv, a(fd), (vec : byte[:]#), a(vec.len)) : size)}
 const write	= {fd, buf;		-> (syscall(Syswrite, a(fd), (buf : byte#), a(buf.len)) : size)}
+const writev	= {fd, vec;		-> (syscall(Syswritev, a(fd), (vec : byte[:]#), 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))}