Merge pull request #1274 from Sonicadvance1/fix_timex

Linux: Fixes timex definition for 32-bit syscalls
This commit is contained in:
Ryan Houdek authored and GitHub committed 2021-09-12 17:14:36 -07:00
commit 368095f96f
4 files changed
+116 -17

No files matched your search

@@ -8,14 +8,7 @@ $end_info$
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
#include "Tests/LinuxSyscalls/x32/Syscalls.h"
#include <stddef.h>
#include <stdint.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/timex.h>
#include <unistd.h>
#include <utime.h>
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();
});
}
}
+21
View File
@@ -13,6 +13,7 @@ $end_info$
#include <syscall.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/timex.h>
#include <time.h>
#include <unistd.h>
#include <utime.h>
@@ -229,5 +230,25 @@ namespace FEX::HLE::x32 {
}
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL_X32(adjtimex, [](FEXCore::Core::CpuStateFrame *Frame, compat_ptr<FEX::HLE::x32::timex32> 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<FEX::HLE::x32::timex32> buf) -> uint64_t {
struct timex Host{};
Host = *buf;
uint64_t Result = ::clock_adjtime(clk_id, &Host);
if (Result != -1) {
*buf = Host;
}
SYSCALL_ERRNO();
});
}
}
+86
View File
@@ -962,4 +962,90 @@ rlimit32 {
static_assert(std::is_trivial<rlimit32<true>>::value, "Needs to be trivial");
static_assert(sizeof(rlimit32<true>) == 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<timex32>::value, "Needs to be trivial");
static_assert(sizeof(timex32) == 128, "Incorrect size");
}
+9
View File
@@ -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();
});
}
}