ref: 764fd41f08380207107ec05f65d0d0bf5b76797c
parent: 74a19268887ba997f0ebb65c0572f74f524db2e1
author: Ori Bernstein <ori@markovcorp.com>
date: Tue May 16 08:25:40 EDT 2017
Add std.pread/std.pwrite All the systems have it, and it's useful -- why not?
--- a/lib/std/syswrap+plan9.myr
+++ b/lib/std/syswrap+plan9.myr
@@ -42,7 +42,9 @@
const openmode : (path : byte[:], opts : fdopt, mode : int64 -> result(fd, errno))
const close : (fd : fd -> errno)
const read : (fd : fd, buf : byte[:] -> result(size, errno))
+ const pread : (fd : fd, buf : byte[:], off : off -> result(size, errno))
const write : (fd : fd, buf : byte[:] -> result(size, errno))
+ const pwrite : (fd : fd, buf : byte[:], off : off -> result(size, errno))
const seek : (fd : fd, delta : off, whence : whence -> result(off, errno))
const pipe : (fds : fd[2]# -> errno)
const dup2 : (ofd : fd, nfd : fd -> result(fd, errno))
@@ -184,7 +186,9 @@
const close = {fd; -> (sys.close((fd : sys.fd)) : errno)}
const read = {fd, buf; -> check(sys.pread((fd : sys.fd), buf, -1))}
+const pread = {fd, buf,off; -> check(sys.pread((fd : sys.fd), buf, (off : sys.off)))}
const write = {fd, buf; -> check(sys.pwrite((fd : sys.fd), buf, -1))}
+const pwrite = {fd, buf,off; -> check(sys.pwrite((fd : sys.fd), buf, (off : sys.off)))}
const seek = {fd, off, whence; -> check(sys.seek((fd : sys.fd), (off : sys.off), (whence : int64)))}
const pipe = {fds; -> (sys.pipe((fds : sys.fd[2]#)) : errno)}
const dup2 = {ofd, nfd; -> check(sys.dup((ofd : sys.fd), (nfd : sys.fd)))}
--- a/lib/std/syswrap+posixy.myr
+++ b/lib/std/syswrap+posixy.myr
@@ -38,7 +38,9 @@
const close : (fd : fd -> errno)
const creat : (path : byte[:], mode : int64 -> result(fd, errno))
const read : (fd : fd, buf : byte[:] -> result(size, errno))
+ const pread : (fd : fd, buf : byte[:], off : off -> result(size, errno))
const write : (fd : fd, buf : byte[:] -> result(size, errno))
+ const pwrite : (fd : fd, buf : byte[:], off : off -> result(size, errno))
const pipe : (fds : fd[2]# -> errno)
const seek : (fd : fd, delta : off, whence : whence -> result(off, errno))
const dup2 : (ofd : fd, nfd : fd -> result(fd, errno))
@@ -78,7 +80,9 @@
const creat = {path, mode; -> check(sys.creat(path, mode))}
const read = {fd, buf; -> check(sys.read((fd : sys.fd), buf))}
+const pread = {fd, buf,off; -> check(sys.pread((fd : sys.fd), buf, (off : sys.off)))}
const write = {fd, buf; -> check(sys.write((fd : sys.fd), buf))}
+const pwrite = {fd, buf,off; -> check(sys.pwrite((fd : sys.fd), buf, (off : sys.off)))}
const pipe = {fds; -> (sys.pipe((fds : sys.fd[2]#)) : errno)}
const seek = {fd, delta, whence; -> check(sys.lseek((fd : sys.fd), (delta : sys.off), (whence : sys.whence)))}
const dup2 = {ofd, nfd; -> check((sys.dup2((ofd : sys.fd), (nfd : sys.fd)) : fd))}