Skip to content

Commit

Permalink
Merge pull request #44 from yomaytk/fix-syscall
Browse files Browse the repository at this point in the history
Fix clock_gettime for WASI.
  • Loading branch information
yomaytk authored May 18, 2024
2 parents 17d8e31 + 6c36628 commit 10174a2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions runtime/syscalls/SyscallWasi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,16 @@ void __svc_wasi_call(void) {
errno = _ECV_EACCESS;
break;
case AARCH64_SYS_CLOCK_GETTIME: /* clock_gettime (clockid_t which_clock, struct __kernel_timespace *tp) */
EMPTY_SYSCALL(AARCH64_SYS_CLOCK_GETTIME);
state_gpr.x0.qword = -1;
errno = _ECV_EACCESS;
break;
{
struct _ecv__clockid {
uint32_t id;
} which_clock;
which_clock.id = state_gpr.x0.dword;
struct timespec emu_tp;
int clock_time = clock_gettime((clockid_t) &which_clock, &emu_tp);
memcpy(_ecv_translate_ptr(state_gpr.x1.qword), &emu_tp, sizeof(timespec));
state_gpr.x0.qword = (_ecv_reg64_t) clock_time;
} break;
case AARCH64_SYS_TGKILL: /* tgkill (pid_t tgid, pid_t pid, int sig) */
EMPTY_SYSCALL(AARCH64_SYS_TGKILL);
state_gpr.x0.qword = -1;
Expand Down

0 comments on commit 10174a2

Please sign in to comment.