Browse Source

+ implemented do_write for WASI. Error handling is not yet done.

git-svn-id: branches/wasm@48299 -
nickysn 4 years ago
parent
commit
5794afac54
2 changed files with 12 additions and 5 deletions
  1. 7 1
      rtl/wasi/sysfile.inc
  2. 5 4
      rtl/wasi/system.pp

+ 7 - 1
rtl/wasi/sysfile.inc

@@ -34,8 +34,14 @@ begin
 end;
 
 function Do_Write(Handle:thandle;Addr:Pointer;Len:Longint):longint;
+var
+  our_iov: __wasi_ciovec_t;
+  our_nwritten: longint;
 begin
-  DebugWriteLn('Do_Write');
+  our_iov.buf := Addr;
+  our_iov.buf_len := Len;
+  fd_write(Handle, @our_iov, 1, @our_nwritten);
+  Do_Write:=our_nwritten;
 end;
 
 function Do_Read(Handle:thandle;Addr:Pointer;Len:Longint):Longint;

+ 5 - 4
rtl/wasi/system.pp

@@ -71,6 +71,11 @@ type
     buf_len: __wasi_size_t;
   end;
 
+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_unstable';
+
 {$ifdef FULL_RTL}
 
 {$I system.inc}
@@ -127,10 +132,6 @@ begin
 end;
 {$endif FULL_RTL}
 
-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_unstable';
 
 procedure DebugWrite(const P: PChar);
 var