From a28eb39f4bbf9613e05b4080f678f1e5cb87b759 Mon Sep 17 00:00:00 2001 From: nickysn Date: Sat, 23 Jan 2021 07:04:32 +0000 Subject: [PATCH] + implemented WASI file close git-svn-id: branches/wasm@48344 - --- rtl/wasi/sysfile.inc | 10 +++++++++- rtl/wasi/system.pp | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/rtl/wasi/sysfile.inc b/rtl/wasi/sysfile.inc index a1a5df87d5..5b01ae1659 100644 --- a/rtl/wasi/sysfile.inc +++ b/rtl/wasi/sysfile.inc @@ -14,8 +14,16 @@ **********************************************************************} procedure Do_Close(Handle:thandle); +var + res: __wasi_errno_t; begin - DebugWriteLn('Do_Close'); + repeat + res:=fd_close(Handle); + until (res=__WASI_ERRNO_SUCCESS) or (res<>__WASI_ERRNO_INTR); + if res=__WASI_ERRNO_SUCCESS then + InOutRes:=0 + else + InOutRes:=Errno2InoutRes(res); end; procedure Do_Erase(p: pchar; pchangeable: boolean); diff --git a/rtl/wasi/system.pp b/rtl/wasi/system.pp index e1ffea5738..ec1cb2230c 100644 --- a/rtl/wasi/system.pp +++ b/rtl/wasi/system.pp @@ -244,6 +244,7 @@ function path_open(fd: __wasi_fd_t; fs_rights_inherting: __wasi_rights_t; fdflags: __wasi_fdflags_t; opened_fd: P__wasi_fd_t): __wasi_errno_t; external 'wasi_snapshot_preview1'; +function fd_close(fd: __wasi_fd_t): __wasi_errno_t; external 'wasi_snapshot_preview1'; {$I system.inc}