Luna/kernel/src/sys/Syscall.cpp
apio d27ffce5db
kernel: Move the signal handling logic to after a syscall sets its return value
When a signal was caught after a syscall, it was doing so without preserving the return value of the syscall.
2023-07-12 13:34:30 +02:00

21 lines
480 B
C++

#include "sys/Syscall.h"
#include "thread/Scheduler.h"
#include <luna/SystemError.h>
syscall_func_t syscalls[] = {
#undef __enumerate
#define __enumerate(name) sys_##name,
enumerate_syscalls(__enumerate)
#undef __enumerate
};
i64 invoke_syscall(Registers* regs, SyscallArgs args, u64 syscall)
{
if (syscall >= Syscalls::__count) { return -ENOSYS; }
auto rc = syscalls[syscall](regs, args);
if (rc.has_error()) return -rc.error();
return (i64)rc.value();
}