diff --git a/runtime/syscalls/SyscallWasi.cpp b/runtime/syscalls/SyscallWasi.cpp index f3720a6..4c71c1c 100644 --- a/runtime/syscalls/SyscallWasi.cpp +++ b/runtime/syscalls/SyscallWasi.cpp @@ -27,6 +27,14 @@ # define NOP_SYSCALL(sysnum) ; #endif +#if defined(__wasm32__) +typedef uint32_t _ecv_long; +#elif defined(__wasm64__) +typedef uint64_t _ecv_long; +#else +typedef uint32_t _ecv_long; +#endif + /* for ioctl syscall */ @@ -180,11 +188,17 @@ void RuntimeManager::SVCWasiCall(void) { { struct _ecv__clockid { uint32_t id; - } which_clock; - which_clock.id = state_gpr.x0.dword; + } which_clock = {.id = state_gpr.x0.dword}; struct timespec emu_tp; int clock_time = clock_gettime((clockid_t) &which_clock, &emu_tp); - memcpy(TranslateVMA(state_gpr.x1.qword), &emu_tp, sizeof(timespec)); + struct { + uint64_t tv_sec; /* time_t */ + uint64_t tv_nsec; /* long (assume that the from target architecture is 64bit) */ + } tp = { + .tv_sec = (uint64_t) emu_tp.tv_sec, + .tv_nsec = (uint64_t) (_ecv_long) emu_tp.tv_nsec, + }; + memcpy(TranslateVMA(state_gpr.x1.qword), &tp, sizeof(tp)); state_gpr.x0.qword = (_ecv_reg64_t) clock_time; } break; case AARCH64_SYS_TGKILL: /* tgkill (pid_t tgid, pid_t pid, int sig) */ @@ -204,7 +218,7 @@ void RuntimeManager::SVCWasiCall(void) { break; case AARCH64_SYS_UNAME: /* uname (struct old_utsname* buf) */ { - struct __my_utsname { + struct __ecv_utsname { char sysname[65]; char nodename[65]; char relase[65];