diff --git a/Scripts/StructPackVerifier.py b/Scripts/StructPackVerifier.py index 372acd6de..25dd4096e 100755 --- a/Scripts/StructPackVerifier.py +++ b/Scripts/StructPackVerifier.py @@ -244,7 +244,7 @@ def HandleVarDeclElements(Arch, VarDecl, Cursor): logging.critical ("Can't handle alias type '{0}'".format(Child.spelling)) Arch.Parsed = False elif (Child.spelling == "fex-match"): - VarDecl.ExpectedFEXMatch = True + VarDecl.ExpectFEXMatch = True else: # Unknown annotation pass @@ -317,7 +317,7 @@ def HandleStructElements(Arch, Struct, Cursor): Arch.Parsed = False elif (Child.spelling == "fex-match"): - Struct.ExpectedFEXMatch = True + Struct.ExpectFEXMatch = True else: # Unknown annotation pass diff --git a/Source/Tests/LinuxSyscalls/x32/EPoll.cpp b/Source/Tests/LinuxSyscalls/x32/EPoll.cpp index 623b0db8d..bae5ee906 100644 --- a/Source/Tests/LinuxSyscalls/x32/EPoll.cpp +++ b/Source/Tests/LinuxSyscalls/x32/EPoll.cpp @@ -18,7 +18,7 @@ $end_info$ #include #include -ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") +ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") namespace FEXCore::Core { @@ -27,9 +27,9 @@ namespace FEXCore::Core { namespace FEX::HLE::x32 { void RegisterEpoll(FEX::HLE::SyscallHandler *const Handler) { - REGISTER_SYSCALL_IMPL_X32(epoll_wait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr events, int maxevents, int timeout) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(epoll_wait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr events, int maxevents, int timeout) -> uint64_t { std::vector Events(std::max(0, maxevents)); - uint64_t Result = ::syscall(SYS_epoll_pwait, epfd, Events.data(), maxevents, timeout, nullptr); + uint64_t Result = ::syscall(SYS_epoll_pwait, epfd, Events.data(), maxevents, timeout, nullptr, 8); if (Result != -1) { for (size_t i = 0; i < Result; ++i) { @@ -39,16 +39,13 @@ namespace FEX::HLE::x32 { SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32(epoll_ctl, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, int op, int fd, compat_ptr event) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(epoll_ctl, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, int op, int fd, compat_ptr event) -> uint64_t { struct epoll_event Event = *event; uint64_t Result = ::syscall(SYS_epoll_ctl, epfd, op, fd, &Event); - if (Result != -1) { - *event = Event; - } SYSCALL_ERRNO(); }); - REGISTER_SYSCALL_IMPL_X32(epoll_pwait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr events, int maxevent, int timeout, const uint64_t* sigmask, size_t sigsetsize) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(epoll_pwait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr events, int maxevent, int timeout, const uint64_t* sigmask, size_t sigsetsize) -> uint64_t { std::vector Events(std::max(0, maxevent)); uint64_t Result = ::syscall(SYS_epoll_pwait, @@ -72,7 +69,7 @@ namespace FEX::HLE::x32 { #ifndef SYS_epoll_pwait2 #define SYS_epoll_pwait2 354 #endif - REGISTER_SYSCALL_IMPL_X32(epoll_pwait2, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr events, int maxevent, compat_ptr timeout, const uint64_t* sigmask, size_t sigsetsize) -> uint64_t { + REGISTER_SYSCALL_IMPL_X32(epoll_pwait2, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr events, int maxevent, compat_ptr timeout, const uint64_t* sigmask, size_t sigsetsize) -> uint64_t { std::vector Events(std::max(0, maxevent)); struct timespec tp64{}; diff --git a/Source/Tests/LinuxSyscalls/x32/Info.cpp b/Source/Tests/LinuxSyscalls/x32/Info.cpp index ef94cefd6..ba22629c6 100644 --- a/Source/Tests/LinuxSyscalls/x32/Info.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Info.cpp @@ -21,6 +21,9 @@ namespace FEXCore::Core { struct CpuStateFrame; } +ARG_TO_STR(FEX::HLE::x32::compat_ptr>, "%lx") +ARG_TO_STR(FEX::HLE::x32::compat_ptr>, "%lx") + namespace FEX::HLE::x32 { struct sysinfo32 { int32_t uptime; diff --git a/Source/Tests/LinuxSyscalls/x32/Msg.cpp b/Source/Tests/LinuxSyscalls/x32/Msg.cpp index d50c83a5f..2c9681c69 100644 --- a/Source/Tests/LinuxSyscalls/x32/Msg.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Msg.cpp @@ -14,6 +14,9 @@ $end_info$ #include #include +ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") +ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") + namespace FEX::HLE::x32 { void RegisterMsg() { REGISTER_SYSCALL_IMPL_X32(mq_timedsend, [](FEXCore::Core::CpuStateFrame *Frame, mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec32 *abs_timeout) -> uint64_t { diff --git a/Source/Tests/LinuxSyscalls/x32/Signals.cpp b/Source/Tests/LinuxSyscalls/x32/Signals.cpp index 3e323a548..bb61d832e 100644 --- a/Source/Tests/LinuxSyscalls/x32/Signals.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Signals.cpp @@ -20,6 +20,8 @@ namespace FEXCore::Core { struct CpuStateFrame; } +ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") + namespace FEX::HLE::x32 { void CopySigInfo(FEXCore::x86::siginfo_t *Info, siginfo_t const &Host) { // Copy the basic things first diff --git a/Source/Tests/LinuxSyscalls/x32/Time.cpp b/Source/Tests/LinuxSyscalls/x32/Time.cpp index 4153eae0f..2136300a7 100644 --- a/Source/Tests/LinuxSyscalls/x32/Time.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Time.cpp @@ -19,6 +19,7 @@ $end_info$ #include ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") +ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") struct timespec; namespace FEXCore::Core { diff --git a/Source/Tests/LinuxSyscalls/x32/Timer.cpp b/Source/Tests/LinuxSyscalls/x32/Timer.cpp index 21624e799..5fc897a2e 100644 --- a/Source/Tests/LinuxSyscalls/x32/Timer.cpp +++ b/Source/Tests/LinuxSyscalls/x32/Timer.cpp @@ -19,6 +19,8 @@ namespace FEXCore::Core { struct CpuStateFrame; } +ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") + namespace FEX::HLE::x32 { void RegisterTimer() { REGISTER_SYSCALL_IMPL_X32(timer_settime, [](FEXCore::Core::CpuStateFrame *Frame, diff --git a/Source/Tests/LinuxSyscalls/x32/Types.h b/Source/Tests/LinuxSyscalls/x32/Types.h index 31ec75132..5c4cf0b43 100644 --- a/Source/Tests/LinuxSyscalls/x32/Types.h +++ b/Source/Tests/LinuxSyscalls/x32/Types.h @@ -36,7 +36,6 @@ using compat_long_t = int32_t; using compat_uptr_t = uint32_t; using compat_size_t = uint32_t; using compat_off_t = uint32_t; -using compat_loff_t = int64_t; using compat_pid_t = int32_t; using compat_dev_t = uint16_t; using compat_ino_t = uint32_t; @@ -51,6 +50,7 @@ using compat_clock_t = int32_t; // Can't use using with aligned attributes, clang doesn't honour it typedef FEX_ALIGNED(4) uint64_t compat_uint64_t; typedef FEX_ALIGNED(4) int64_t compat_int64_t; +typedef FEX_ALIGNED(4) int64_t compat_loff_t; template class compat_ptr { @@ -645,8 +645,8 @@ static_assert(sizeof(flock64_32) == 24, "Incorrect size"); struct FEX_ANNOTATE("fex-match") linux_dirent { - uint64_t d_ino; - int64_t d_off; + compat_uint64_t d_ino; + compat_int64_t d_off; uint16_t d_reclen; uint8_t _pad[6]; char d_name[]; @@ -673,8 +673,8 @@ static_assert(sizeof(linux_dirent_32) == 12, "Incorrect size"); struct FEX_ANNOTATE("fex-match") linux_dirent_64 { - uint64_t d_ino; - uint64_t d_off; + compat_uint64_t d_ino; + compat_uint64_t d_off; uint16_t d_reclen; uint8_t d_type; uint8_t _pad[5]; @@ -1156,4 +1156,40 @@ mq_attr32 { static_assert(std::is_trivial::value, "Needs to be trivial"); static_assert(sizeof(mq_attr32) == 32, "Incorrect size"); + +union +FEX_ANNOTATE("alias-x86_32-epoll_data_t") +FEX_ANNOTATE("fex-match") +epoll_data32 { + compat_ptr ptr; + int fd; + uint32_t u32; + compat_uint64_t u64; +}; + +struct +FEX_PACKED +FEX_ANNOTATE("alias-x86_32-epoll_event") +FEX_ANNOTATE("fex-match") +epoll_event32 { + uint32_t events; + epoll_data32 data; + + epoll_event32() = delete; + + operator struct epoll_event() const { + epoll_event event{}; + event.events = events; + event.data.u64 = data.u64; + return event; + } + + epoll_event32(struct epoll_event event) + : data { event.data.u64 }{ + events = event.events; + } +}; +static_assert(std::is_trivial::value, "Needs to be trivial"); +static_assert(sizeof(epoll_event32) == 12, "Incorrect size"); + } diff --git a/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp b/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp index 263a342b1..02a9b5361 100644 --- a/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp +++ b/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp @@ -16,6 +16,8 @@ namespace FEXCore::Core { struct CpuStateFrame; } +ARG_TO_STR(FEX::HLE::x64::semun, "%lx") + namespace FEX::HLE::x64 { void RegisterSemaphore() { REGISTER_SYSCALL_IMPL_X64(semop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops) -> uint64_t {