diff options
author | Ori Bernstein <ori@markovcorp.com> | 2017-05-16 12:25:40 -0700 |
---|---|---|
committer | Ori Bernstein <ori@markovcorp.com> | 2017-05-16 12:25:40 -0700 |
commit | 764fd41f08380207107ec05f65d0d0bf5b76797c (patch) | |
tree | dff99eb9876096ab92eeb2b4d54c914b7ce3586c | |
parent | 74a19268887ba997f0ebb65c0572f74f524db2e1 (diff) | |
download | mc-764fd41f08380207107ec05f65d0d0bf5b76797c.tar.gz |
Add std.pread/std.pwrite
All the systems have it, and it's useful -- why not?
-rw-r--r-- | lib/std/syswrap+plan9.myr | 4 | ||||
-rw-r--r-- | lib/std/syswrap+posixy.myr | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/std/syswrap+plan9.myr b/lib/std/syswrap+plan9.myr index ab1c025..1730c53 100644 --- a/lib/std/syswrap+plan9.myr +++ b/lib/std/syswrap+plan9.myr @@ -42,7 +42,9 @@ pkg std = 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 getsysinfo = {si 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)))} diff --git a/lib/std/syswrap+posixy.myr b/lib/std/syswrap+posixy.myr index e930e0f..d99eb69 100644 --- a/lib/std/syswrap+posixy.myr +++ b/lib/std/syswrap+posixy.myr @@ -38,7 +38,9 @@ pkg std = 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 close = {fd; -> (sys.close((fd : sys.fd)) : errno)} 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))} |