diff --git a/Source/Tests/LinuxSyscalls/Syscalls/Time.cpp b/Source/Tests/LinuxSyscalls/Syscalls/Time.cpp index 68c28b56f..69af3f778 100644 --- a/Source/Tests/LinuxSyscalls/Syscalls/Time.cpp +++ b/Source/Tests/LinuxSyscalls/Syscalls/Time.cpp @@ -8,14 +8,7 @@ $end_info$ #include "Tests/LinuxSyscalls/x64/Syscalls.h" #include "Tests/LinuxSyscalls/x32/Syscalls.h" -#include -#include -#include -#include -#include -#include #include -#include namespace FEX::HLE { void RegisterTime() { @@ -23,15 +16,5 @@ namespace FEX::HLE { uint64_t Result = ::pause(); SYSCALL_ERRNO(); }); - - REGISTER_SYSCALL_IMPL(adjtimex, [](FEXCore::Core::CpuStateFrame *Frame, struct timex *buf) -> uint64_t { - uint64_t Result = ::adjtimex(buf); - SYSCALL_ERRNO(); - }); - - REGISTER_SYSCALL_IMPL(clock_adjtime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, struct timex *buf) -> uint64_t { - uint64_t Result = ::clock_adjtime(clk_id, buf); - SYSCALL_ERRNO(); - }); } } diff --git a/Source/Tests/LinuxSyscalls/x32/Time.cpp b/Source/Tests/LinuxSyscalls/x32/Time.cpp index d0394bf33..4153eae0f 100644 --- a/Source/Tests/LinuxSyscalls/x32/Time.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Time.cpp @@ -13,6 +13,7 @@ $end_info$ #include #include #include +#include #include #include #include @@ -229,5 +230,25 @@ namespace FEX::HLE::x32 { } SYSCALL_ERRNO(); }); + + REGISTER_SYSCALL_IMPL_X32(adjtimex, [](FEXCore::Core::CpuStateFrame *Frame, compat_ptr buf) -> uint64_t { + struct timex Host{}; + Host = *buf; + uint64_t Result = ::adjtimex(&Host); + if (Result != -1) { + *buf = Host; + } + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL_X32(clock_adjtime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, compat_ptr buf) -> uint64_t { + struct timex Host{}; + Host = *buf; + uint64_t Result = ::clock_adjtime(clk_id, &Host); + if (Result != -1) { + *buf = Host; + } + SYSCALL_ERRNO(); + }); } } diff --git a/Source/Tests/LinuxSyscalls/x32/Types.h b/Source/Tests/LinuxSyscalls/x32/Types.h index c1a0a6ec7..ec20f8992 100644 --- a/Source/Tests/LinuxSyscalls/x32/Types.h +++ b/Source/Tests/LinuxSyscalls/x32/Types.h @@ -962,4 +962,90 @@ rlimit32 { static_assert(std::is_trivial>::value, "Needs to be trivial"); static_assert(sizeof(rlimit32) == 8, "Incorrect size"); + +struct +FEX_ANNOTATE("alias-x86_32-timex") +FEX_ANNOTATE("fex-match") +timex32 { + uint32_t modes; + compat_long_t offset; + compat_long_t freq; + compat_long_t maxerror; + compat_long_t esterror; + int32_t status; + compat_long_t constant; + compat_long_t precision; + compat_long_t tolerance; + timeval32 time; + compat_long_t tick; + compat_long_t ppsfreq; + compat_long_t jitter; + int32_t shift; + compat_long_t stabil; + compat_long_t jitcnt; + compat_long_t calcnt; + compat_long_t errcnt; + compat_long_t stbcnt; + + int32_t tai; + + // Padding + int32_t :32; int32_t :32; int32_t :32; int32_t :32; + int32_t :32; int32_t :32; int32_t :32; int32_t :32; + int32_t :32; int32_t :32; int32_t :32; + + timex32() = delete; + + operator timex() const { + timex val{}; + val.modes = modes; + val.offset = offset; + val.freq = freq; + val.maxerror = maxerror; + val.esterror = esterror; + val.status = status; + val.constant = constant; + val.precision = precision; + val.tolerance = tolerance; + val.time = time; + val.tick = tick; + val.ppsfreq = ppsfreq; + val.jitter = jitter; + val.shift = shift; + val.stabil = stabil; + val.jitcnt = jitcnt; + val.calcnt = calcnt; + val.errcnt = errcnt; + val.stbcnt = stbcnt; + val.tai = tai; + return val; + } + + timex32(struct timex val) + : time { val.time } { + modes = val.modes; + offset = val.offset; + freq = val.freq; + maxerror = val.maxerror; + esterror = val.esterror; + status = val.status; + constant = val.constant; + precision = val.precision; + tolerance = val.tolerance; + tick = val.tick; + ppsfreq = val.ppsfreq; + jitter = val.jitter; + shift = val.shift; + stabil = val.stabil; + jitcnt = val.jitcnt; + calcnt = val.calcnt; + errcnt = val.errcnt; + stbcnt = val.stbcnt; + tai = val.tai; + } +}; + +static_assert(std::is_trivial::value, "Needs to be trivial"); +static_assert(sizeof(timex32) == 128, "Incorrect size"); + } diff --git a/Source/Tests/LinuxSyscalls/x64/Time.cpp b/Source/Tests/LinuxSyscalls/x64/Time.cpp index f74c0ca4e..c3c595cd6 100644 --- a/Source/Tests/LinuxSyscalls/x64/Time.cpp +++ b/Source/Tests/LinuxSyscalls/x64/Time.cpp @@ -94,6 +94,15 @@ namespace FEX::HLE::x64 { uint64_t Result = ::syscall(SYS_timer_gettime, timerid, curr_value); SYSCALL_ERRNO(); }); + REGISTER_SYSCALL_IMPL_X64(adjtimex, [](FEXCore::Core::CpuStateFrame *Frame, struct timex *buf) -> uint64_t { + uint64_t Result = ::adjtimex(buf); + SYSCALL_ERRNO(); + }); + + REGISTER_SYSCALL_IMPL_X64(clock_adjtime, [](FEXCore::Core::CpuStateFrame *Frame, clockid_t clk_id, struct timex *buf) -> uint64_t { + uint64_t Result = ::clock_adjtime(clk_id, buf); + SYSCALL_ERRNO(); + }); } }