@@ -136,41 +136,37 @@ var WasiLibrary = {
136136  } , 
137137#endif
138138
139-   $checkWasiClock: ( clock_id )  =>  { 
140-     return  clock_id  ==  { { {  cDefs . __WASI_CLOCKID_REALTIME  } } }  || 
141-            clock_id  ==  { { {  cDefs . __WASI_CLOCKID_MONOTONIC  } } }  || 
142-            clock_id  ==  { { {  cDefs . __WASI_CLOCKID_PROCESS_CPUTIME_ID  } } }  || 
143-            clock_id  ==  { { {  cDefs . __WASI_CLOCKID_THREAD_CPUTIME_ID  } } } ; 
144-   } , 
139+   $checkWasiClock : ( clock_id )  =>  clock_id  >=  { { {  cDefs . __WASI_CLOCKID_REALTIME  } } }  &&  clock_id  <=  { { {  cDefs . __WASI_CLOCKID_THREAD_CPUTIME_ID  } } } , 
145140
146141  // TODO: the i64 in the API here must be legalized for this JS code to run, 
147142  // but the wasm file can't be legalized in standalone mode, which is where 
148143  // this is needed. To get this code to be usable as a JS shim we need to 
149144  // either wait for BigInt support or to legalize on the client. 
150145  clock_time_get__i53abi : true , 
151146  clock_time_get__nothrow : true , 
152-   clock_time_get__deps : [ 'emscripten_get_now' ,  '$nowIsMonotonic' ,  '$checkWasiClock' ] , 
147+   clock_time_get__proxy : 'none' , 
148+   clock_time_get__deps : [ 'emscripten_get_now' ,  'emscripten_date_now' ,  '$nowIsMonotonic' ,  '$checkWasiClock' ] , 
153149  clock_time_get : ( clk_id ,  ignored_precision ,  ptime )  =>  { 
154150    if  ( ! checkWasiClock ( clk_id ) )  { 
155151      return  { { {  cDefs . EINVAL  } } } ; 
156152    } 
157153    var  now ; 
158154    // all wasi clocks but realtime are monotonic 
159155    if  ( clk_id  ===  { { {  cDefs . __WASI_CLOCKID_REALTIME  } } } )  { 
160-       now =  Date . now ( ) ; 
156+       now =  _emscripten_date_now ( ) ; 
161157    }  else  if  ( nowIsMonotonic )  { 
162158      now =  _emscripten_get_now ( ) ; 
163159    }  else  { 
164160      return  { { {  cDefs . ENOSYS  } } } ; 
165161    } 
166162    // "now" is in ms, and wasi times are in ns. 
167163    var  nsec  =  Math . round ( now  *  1000  *  1000 ) ; 
168-     { { {  makeSetValue ( 'ptime' ,  0 ,  'nsec >>> 0' ,  'i32' )  } } } ; 
169-     { { {  makeSetValue ( 'ptime' ,  4 ,  '(nsec / Math.pow(2, 32)) >>> 0' ,  'i32' )  } } } ; 
164+     { { {  makeSetValue ( 'ptime' ,  0 ,  'nsec' ,  'i64' )  } } } ; 
170165    return  0 ; 
171166  } , 
172167
173168  clock_res_get__nothrow : true , 
169+   clock_res_get__proxy : 'none' , 
174170  clock_res_get__deps : [ 'emscripten_get_now' ,  'emscripten_get_now_res' ,  '$nowIsMonotonic' ,  '$checkWasiClock' ] , 
175171  clock_res_get : ( clk_id ,  pres )  =>  { 
176172    if  ( ! checkWasiClock ( clk_id ) )  { 
@@ -185,8 +181,7 @@ var WasiLibrary = {
185181    }  else  { 
186182      return  { { {  cDefs . ENOSYS  } } } ; 
187183    } 
188-     { { {  makeSetValue ( 'pres' ,  0 ,  'nsec >>> 0' ,  'i32' )  } } } ; 
189-     { { {  makeSetValue ( 'pres' ,  4 ,  '(nsec / Math.pow(2, 32)) >>> 0' ,  'i32' )  } } } ; 
184+     { { {  makeSetValue ( 'pres' ,  0 ,  'nsec' ,  'i64' )  } } } ; 
190185    return  0 ; 
191186  } , 
192187
0 commit comments