@@ -36,6 +36,7 @@ using v8::FastApiCallbackOptions;
3636using v8::FunctionCallbackInfo;
3737using v8::FunctionTemplate;
3838using v8::HandleScope;
39+ using v8::Int32;
3940using v8::Integer;
4041using v8::Isolate;
4142using v8::Local;
@@ -306,6 +307,16 @@ uint32_t ConvertType(Local<Value> value) {
306307 return value.As <Uint32>()->Value ();
307308}
308309
310+ template <>
311+ bool CheckType<int32_t >(Local<Value> value) {
312+ return value->IsInt32 ();
313+ }
314+
315+ template <>
316+ int32_t ConvertType (Local<Value> value) {
317+ return value.As <Int32>()->Value ();
318+ }
319+
309320template <>
310321bool CheckType<uint64_t >(Local<Value> value) {
311322 return value->IsBigInt ();
@@ -486,14 +497,17 @@ uint32_t WASI::ClockTimeGet(WASI& wasi,
486497 WasmMemory memory,
487498 uint32_t clock_id,
488499 uint64_t precision,
489- uint32_t time_ptr) {
490- Debug (wasi, " clock_time_get(%d, %d, %d)\n " , clock_id, precision, time_ptr);
491- CHECK_BOUNDS_OR_RETURN (memory.size , time_ptr, UVWASI_SERDES_SIZE_timestamp_t);
500+ int32_t time_ptr) {
501+ const auto time_ptr_u32 = static_cast <uint32_t >(time_ptr);
502+ Debug (
503+ wasi, " clock_time_get(%d, %d, %d)\n " , clock_id, precision, time_ptr_u32);
504+ CHECK_BOUNDS_OR_RETURN (
505+ memory.size , time_ptr_u32, UVWASI_SERDES_SIZE_timestamp_t);
492506 uvwasi_timestamp_t time;
493507 uvwasi_errno_t err =
494508 uvwasi_clock_time_get (&wasi.uvw_ , clock_id, precision, &time);
495509 if (err == UVWASI_ESUCCESS)
496- uvwasi_serdes_write_timestamp_t (memory.data , time_ptr , time);
510+ uvwasi_serdes_write_timestamp_t (memory.data , time_ptr_u32 , time);
497511
498512 return err;
499513}
0 commit comments