UserspaceEmulator: Implement clock_nanosleep

This commit is contained in:
Simon Danner 2020-11-22 12:12:21 +01:00 committed by Andreas Kling
parent c6bb3d452a
commit 751e759be2
Notes: sideshowbarker 2024-07-19 01:17:27 +09:00
2 changed files with 23 additions and 0 deletions

View file

@ -402,6 +402,8 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3)
return virt$setsid();
case SC_watch_file:
return virt$watch_file(arg1, arg2);
case SC_clock_nanosleep:
return virt$clock_nanosleep(arg1);
default:
reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function);
dump_backtrace();
@ -1501,4 +1503,24 @@ int Emulator::virt$watch_file(FlatPtr user_path_addr, size_t path_length)
return syscall(SC_watch_file, user_path.data(), user_path.size());
}
int Emulator::virt$clock_nanosleep(FlatPtr params_addr)
{
Syscall::SC_clock_nanosleep_params params;
mmu().copy_from_vm(&params, params_addr, sizeof(params));
timespec requested_sleep;
mmu().copy_from_vm(&requested_sleep, (FlatPtr)params.requested_sleep, sizeof(timespec));
params.requested_sleep = &requested_sleep;
auto remaining_vm_addr = params.remaining_sleep;
auto remaining = ByteBuffer::create_zeroed(sizeof(timespec));
params.remaining_sleep = (timespec*)remaining.data();
int rc = syscall(SC_clock_nanosleep, &params);
if (remaining_vm_addr)
mmu().copy_to_vm((FlatPtr)remaining_vm_addr, remaining.data(), sizeof(timespec));
return rc;
}
}

View file

@ -118,6 +118,7 @@ private:
int virt$set_process_icon(int);
int virt$gettimeofday(FlatPtr);
int virt$clock_gettime(int, FlatPtr);
int virt$clock_nanosleep(FlatPtr);
int virt$dbgputstr(FlatPtr characters, int length);
int virt$dbgputch(char);
int virt$chmod(FlatPtr, size_t, mode_t);