File tree 3 files changed +13
-6
lines changed
3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -7,12 +7,21 @@ import { WASIOptions } from "../options";
7
7
export function useClock ( options : WASIOptions , abi : WASIAbi , memoryView : ( ) => DataView ) : WebAssembly . ModuleImports {
8
8
return {
9
9
clock_res_get : ( clockId : number , resolution : number ) => {
10
- // There is no standard way to guarantee monotonicity in JavaScript,
11
- if ( clockId !== WASIAbi . WASI_CLOCK_REALTIME ) {
12
- return WASIAbi . WASI_ENOSYS ;
10
+ let resolutionValue : number ;
11
+ switch ( clockId ) {
12
+ case WASIAbi . WASI_CLOCK_MONOTONIC : {
13
+ resolutionValue = 1 ;
14
+ break ;
15
+ }
16
+ case WASIAbi . WASI_CLOCK_REALTIME : {
17
+ resolutionValue = 1000 ;
18
+ break ;
19
+ }
20
+ default : return WASIAbi . WASI_ENOSYS ;
13
21
}
14
22
const view = memoryView ( ) ;
15
- view . setBigUint64 ( resolution , BigInt ( 1000 ) , true ) ;
23
+ // 64-bit integer, but only the lower 32 bits are used.
24
+ view . setUint32 ( resolution , resolutionValue , true ) ;
16
25
return WASIAbi . WASI_ESUCCESS ;
17
26
} ,
18
27
clock_time_get : ( clockId : number , precision : number , time : number ) => {
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ describe("wasi-test-suite-core", () => {
6
6
const suiteDir = pathJoin ( __dirname , "../../third_party/wasi-test-suite/core" ) ;
7
7
const entries = readdirSync ( suiteDir ) ;
8
8
const UNSUPPORTED = [
9
- "clock_get_res-monotonic.wasm" ,
10
9
"fd_stat_get-stderr.wasm" ,
11
10
"fd_stat_get-stdin.wasm" ,
12
11
"fd_stat_get-stdout.wasm" ,
Original file line number Diff line number Diff line change @@ -6,7 +6,6 @@ describe("wasi-test-suite-libc", () => {
6
6
const suiteDir = pathJoin ( __dirname , "../../third_party/wasi-test-suite/libc" ) ;
7
7
const entries = readdirSync ( suiteDir ) ;
8
8
const UNSUPPORTED = [
9
- "clock_getres-monotonic.wasm" ,
10
9
"clock_gettime-monotonic.wasm" ,
11
10
"ftruncate.wasm" ,
12
11
]
You can’t perform that action at this time.
0 commit comments