Skip to content

Commit

Permalink
Merge pull request #58 from yomaytk/llvm-opt2
Browse files Browse the repository at this point in the history
Fxi clock syscall.
  • Loading branch information
yomaytk authored Sep 22, 2024
2 parents 98648c9 + 757734d commit 3f083b2
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions runtime/syscalls/SyscallWasi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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) */
Expand All @@ -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];
Expand Down

0 comments on commit 3f083b2

Please sign in to comment.