Files
FEX-Emu--FEX/Source/Tests/LinuxSyscalls/Syscalls/Timer.cpp
T
Ryan Houdek 3679156dd7 Fixes timer syscall API
The glibc and kernel timer interfaces are sufficiently different enough
that unwrapping this through glibc is impossible.
Pass it directly through to the kernel.
2021-01-26 05:02:44 -08:00

57 lines
2.2 KiB
C++

#include "Tests/LinuxSyscalls/Syscalls.h"
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
#include "Tests/LinuxSyscalls/x32/Syscalls.h"
#include <stddef.h>
#include <stdint.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#include <sys/syscall.h>
#include <unistd.h>
namespace FEX::HLE {
void RegisterTimer() {
REGISTER_SYSCALL_IMPL(alarm, [](FEXCore::Core::InternalThreadState *Thread, unsigned int seconds) -> uint64_t {
uint64_t Result = ::alarm(seconds);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(timer_create, [](FEXCore::Core::InternalThreadState *Thread, clockid_t clockid, struct sigevent *sevp, timer_t *timerid) -> uint64_t {
uint64_t Result = ::syscall(SYS_timer_create, clockid, sevp, timerid);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(timer_settime, [](FEXCore::Core::InternalThreadState *Thread, timer_t timerid, int flags, const struct itimerspec *new_value, struct itimerspec *old_value) -> uint64_t {
uint64_t Result = ::syscall(SYS_timer_settime, timerid, flags, new_value, old_value);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(timer_gettime, [](FEXCore::Core::InternalThreadState *Thread, timer_t timerid, struct itimerspec *curr_value) -> uint64_t {
uint64_t Result = ::syscall(SYS_timer_gettime, timerid, curr_value);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(timer_getoverrun, [](FEXCore::Core::InternalThreadState *Thread, timer_t timerid) -> uint64_t {
uint64_t Result = ::syscall(SYS_timer_getoverrun, timerid);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(timer_delete, [](FEXCore::Core::InternalThreadState *Thread, timer_t timerid) -> uint64_t {
uint64_t Result = ::syscall(SYS_timer_delete, timerid);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(getitimer, [](FEXCore::Core::InternalThreadState *Thread, int which, struct itimerval *curr_value) -> uint64_t {
uint64_t Result = ::getitimer(which, curr_value);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(setitimer, [](FEXCore::Core::InternalThreadState *Thread, int which, const struct itimerval *new_value, struct itimerval *old_value) -> uint64_t {
uint64_t Result = ::setitimer(which, new_value, old_value);
SYSCALL_ERRNO();
});
}
}