Browse Source

+ implemented SysUtils.GetTickCount64 for WASI

Nikolay Nikolov 3 years ago
parent
commit
d134fc1ddf
1 changed files with 12 additions and 0 deletions
  1. 12 0
      rtl/wasi/sysutils.pp

+ 12 - 0
rtl/wasi/sysutils.pp

@@ -29,6 +29,7 @@ uses
   wasiapi;
   wasiapi;
 
 
 {$DEFINE HAS_SLEEP}
 {$DEFINE HAS_SLEEP}
+{$DEFINE HAS_GETTICKCOUNT64}
 
 
 { used OS file system APIs use ansistring }
 { used OS file system APIs use ansistring }
 {$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
 {$define SYSUTILS_HAS_ANSISTR_FILEUTIL_IMPL}
@@ -54,6 +55,17 @@ implementation
 {$i sysutils.inc}
 {$i sysutils.inc}
 
 
 
 
+function GetTickCount64: QWord;
+var
+  NanoSecsPast: __wasi_timestamp_t;
+begin
+  if __wasi_clock_time_get(__WASI_CLOCKID_MONOTONIC,1000000,@NanoSecsPast)=__WASI_ERRNO_SUCCESS then
+    Result:=NanoSecsPast div 1000000
+  else
+    Result:=0;
+end;
+
+
 {****************************************************************************
 {****************************************************************************
                               File Functions
                               File Functions
 ****************************************************************************}
 ****************************************************************************}