+ implemented do_read for WASI

git-svn-id: branches/wasm@48307 -
This commit is contained in:
nickysn 2021-01-22 01:04:19 +00:00
parent f585b2d846
commit d6038c5709
2 changed files with 17 additions and 1 deletions

View File

@ -45,8 +45,14 @@ begin
end;
function Do_Read(Handle:thandle;Addr:Pointer;Len:Longint):Longint;
var
our_iov: __wasi_iovec_t;
our_nread: __wasi_size_t;
begin
DebugWriteLn('Do_Read');
our_iov.buf:=Addr;
our_iov.buf_len:=Len;
fd_read(Handle,@our_iov,1,@our_nread);
Do_Read:=our_nread;
end;
function Do_FilePos(Handle: thandle):Int64;

View File

@ -50,6 +50,12 @@ type
size_t = longint;
__wasi_errno_t = longint;
P__wasi_iovec_t = ^__wasi_iovec_t;
__wasi_iovec_t = record
buf: PUInt8;
buf_len: __wasi_size_t;
end;
P__wasi_ciovec_t = ^__wasi_ciovec_t;
__wasi_ciovec_t = record
buf: pointer;
@ -62,6 +68,10 @@ function fd_write(fd: __wasi_fd_t;
iovs: P__wasi_ciovec_t;
iovs_len: size_t;
nwritten: P__wasi_size_t): __wasi_errno_t; external 'wasi_snapshot_preview1';
function fd_read(fd: __wasi_fd_t;
iovs: P__wasi_iovec_t;
iovs_len: size_t;
nread: P__wasi_size_t): __wasi_errno_t; external 'wasi_snapshot_preview1';
procedure proc_exit(rval: __wasi_exitcode_t); noreturn; external 'wasi_snapshot_preview1';
{$I system.inc}