ref: 0a249c24c7dd73fbc47ea3eeb097da814f54bfe0
parent: 5262bed1d0a0f153c7c4103d059ac9e7f955bc11
author: Ori Bernstein <orib@google.com>
date: Mon Nov 5 10:42:36 EST 2012
Make the return types of 'read' and 'write' more useful.
They return memory sizes, so do the right cast. Ugh.
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -377,8 +377,8 @@
const open : (path:byte[:], opts:fdopt, mode:int64 -> int64)
const close : (fd:int64 -> int64)
const creat : (path:byte[:], mode:int64 -> int64)
- const read : (fd:int64, buf:byte[:] -> int64)
- const write : (fd:int64, buf:byte[:] -> int64)
+ const read : (fd:int64, buf:byte[:] -> size)
+ const write : (fd:int64, buf:byte[:] -> size)
const lseek : (fd:int64, off:uint64, whence:int64 -> int64)
const fstat : (fd:int64, sb:statbuf* -> int64)
const munmap : (addr:byte*, len:size -> int64)
@@ -385,15 +385,15 @@
const mmap : (addr:byte*, len:size, prot:mprot, flags:mopt, fd:int64, off:off -> byte*)
;;
-const exit = {status; syscall(Sysexit, 1);}-const getpid = {; -> syscall(Sysgetpid, 1);}-const kill = {pid, sig; -> syscall(Syskill, pid, sig);}-const open = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode);}-const close = {fd; -> syscall(Sysclose, fd);}-const creat = {path, mode; -> syscall(Syscreat, cstring(path), mode);}-const read = {fd, buf; -> syscall(Sysread, fd, buf castto(char*), buf.len);}-const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(char*), buf.len castto(size));}-const lseek = {fd, off, whence; -> syscall(Syslseek, fd, off, whence);}-const fstat = {fd, sb; -> syscall(Sysfstat, fd, sb);}-const munmap = {addr, len; -> syscall(Sysmunmap, addr, len);}-const mmap = {addr, len, prot, flags, fd, off; -> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte*);}+const exit = {status; syscall(Sysexit, 1)}+const getpid = {; -> syscall(Sysgetpid, 1)}+const kill = {pid, sig; -> syscall(Syskill, pid, sig)}+const open = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode)}+const close = {fd; -> syscall(Sysclose, fd)}+const creat = {path, mode; -> syscall(Syscreat, cstring(path), mode)}+const read = {fd, buf; -> syscall(Sysread, fd, buf castto(char*), buf.len) castto(size)}+const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(char*), buf.len castto(size)) castto(size)}+const lseek = {fd, off, whence; -> syscall(Syslseek, fd, off, whence)}+const fstat = {fd, sb; -> syscall(Sysfstat, fd, sb)}+const munmap = {addr, len; -> syscall(Sysmunmap, addr, len)}+const mmap = {addr, len, prot, flags, fd, off; -> syscall(Sysmmap, addr, len, prot, flags, fd, off) castto(byte*)}--
⑨