ref: 44e5ed3ebbb9c3a8e5e5d809e0f5a6991c4b9570
parent: e002242442a548429f014ec3a5c30f1d40799a7a
author: Ori Bernstein <[email protected]>
date: Wed Jul 9 18:14:00 EDT 2014
Return size from std.read
--- a/libstd/sys-linux.myr
+++ b/libstd/sys-linux.myr
@@ -494,8 +494,8 @@
const openmode : (path:byte[:], opts:fdopt, mode:int64 -> fd)
const close : (fd:fd -> int64)
const creat : (path:byte[:], mode:int64 -> fd)
- const read : (fd:fd, buf:byte[:] -> int64)
- const write : (fd:fd, buf:byte[:] -> int64)
+ const read : (fd:fd, buf:byte[:] -> size)
+ const write : (fd:fd, buf:byte[:] -> size)
const lseek : (fd:fd, off:uint64, whence:int64 -> int64)
const stat : (path:byte[:], sb:statbuf# -> int64)
const lstat : (path:byte[:], sb:statbuf# -> int64)
@@ -587,8 +587,8 @@
const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
const close = {fd; -> syscall(Sysclose, fd)}
const creat = {path, mode; -> syscall(Syscreat, cstring(path), mode) castto(fd)}
-const read = {fd, buf; -> syscall(Sysread, fd, buf castto(byte#), buf.len castto(size))}
-const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(byte#), buf.len castto(size))}
+const read = {fd, buf; -> syscall(Sysread, fd, buf castto(byte#), buf.len castto(size)) castto(size)}
+const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(byte#), buf.len castto(size)) castto(size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, fd, off, whence)}
const stat = {path, sb; -> syscall(Sysstat, cstring(path), sb)}
const fstat = {fd, sb; -> syscall(Sysfstat, fd, sb)}
--- a/libstd/sys-osx.myr
+++ b/libstd/sys-osx.myr
@@ -526,8 +526,8 @@
const openmode : (path:byte[:], opts:fdopt, mode:int64 -> fd)
const close : (fd:fd -> int64)
const creat : (path:byte[:], mode:int64 -> fd)
- const read : (fd:fd, buf:byte[:] -> int64)
- const write : (fd:fd, buf:byte[:] -> int64)
+ const read : (fd:fd, buf:byte[:] -> size)
+ const write : (fd:fd, buf:byte[:] -> size)
const lseek : (fd:fd, off:uint64, whence:int64 -> int64)
const stat : (path:byte[:], sb:statbuf# -> int64)
const lstat : (path:byte[:], sb:statbuf# -> int64)
@@ -621,8 +621,8 @@
const openmode = {path, opts, mode; -> syscall(Sysopen, cstring(path), opts, mode) castto(fd)}
const close = {fd; -> syscall(Sysclose, fd)}
const creat = {path, mode; -> openmode(path, Ocreat | Otrunc | Owronly, mode) castto(fd)}
-const read = {fd, buf; -> syscall(Sysread, fd, buf castto(byte#), buf.len castto(size))}
-const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(byte#), buf.len castto(size))}
+const read = {fd, buf; -> syscall(Sysread, fd, buf castto(byte#), buf.len castto(size)) castto(size)}
+const write = {fd, buf; -> syscall(Syswrite, fd, buf castto(byte#), buf.len castto(size)) castto(size)}
const lseek = {fd, off, whence; -> syscall(Syslseek, fd, off, whence)}
const stat = {path, sb; -> syscall(Sysstat64, cstring(path), sb)}
const lstat = {path, sb; -> syscall(Syslstat64, cstring(path), sb)}
--- a/libstd/types.myr
+++ b/libstd/types.myr
@@ -1,6 +1,6 @@
pkg std =
- type size = uint64 /* spans entire address space */
- type ssize = int64 /* signed size */
+ type size = int64 /* spans entire address space */
+ type usize = int64 /* signed size */
type off = uint64 /* file offsets */
type intptr = uint64 /* can hold any pointer losslessly */
type time = int64 /* milliseconds since epoch */