Merge pull request #1031 from Sonicadvance1/fix_epoll

Use epoll syscalls directly
This commit is contained in:
Stefanos Kornilios Mitsis Poiitidis authored and GitHub committed 2021-05-12 09:33:59 +03:00
commit 27b6497bee
2 files changed
+16 -10

No files matched your search

+8 -5
View File
@@ -15,6 +15,8 @@ $end_info$
#include <stdint.h>
#include <sys/epoll.h>
#include <vector>
#include <sys/syscall.h>
#include <unistd.h>
ARG_TO_STR(FEX::HLE::x32::compat_ptr<FEX::HLE::epoll_event_x86>, "%lx")
@@ -23,7 +25,7 @@ namespace FEX::HLE::x32 {
REGISTER_SYSCALL_IMPL_X32(epoll_wait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr<epoll_event_x86> events, int maxevents, int timeout) -> uint64_t {
std::vector<struct epoll_event> Events;
Events.resize(maxevents);
uint64_t Result = epoll_wait(epfd, &Events.at(0), maxevents, timeout);
uint64_t Result = ::syscall(SYS_epoll_pwait, epfd, &Events.at(0), maxevents, timeout, nullptr);
if (Result != -1) {
for (size_t i = 0; i < Result; ++i) {
@@ -35,23 +37,24 @@ namespace FEX::HLE::x32 {
REGISTER_SYSCALL_IMPL_X32(epoll_ctl, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, int op, int fd, epoll_event_x86 *event) -> uint64_t {
struct epoll_event Event = *event;
uint64_t Result = epoll_ctl(epfd, op, fd, &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<epoll_event_x86> events, int maxevent, int timeout, const void* sigmask) -> uint64_t {
REGISTER_SYSCALL_IMPL_X32(epoll_pwait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, compat_ptr<epoll_event_x86> events, int maxevent, int timeout, const uint64_t* sigmask, size_t sigsetsize) -> uint64_t {
std::vector<struct epoll_event> Events;
Events.resize(maxevent);
uint64_t Result = epoll_pwait(
uint64_t Result = ::syscall(SYS_epoll_pwait,
epfd,
&Events.at(0),
maxevent,
timeout,
reinterpret_cast<const sigset_t*>(sigmask));
sigmask,
sigsetsize);
if (Result != -1) {
for (size_t i = 0; i < Result; ++i) {
+8 -5
View File
@@ -15,13 +15,15 @@ $end_info$
#include <stdint.h>
#include <sys/epoll.h>
#include <vector>
#include <sys/syscall.h>
#include <unistd.h>
namespace FEX::HLE::x64 {
void RegisterEpoll() {
REGISTER_SYSCALL_IMPL_X64(epoll_wait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, epoll_event_x86 *events, int maxevents, int timeout) -> uint64_t {
std::vector<struct epoll_event> Events;
Events.resize(maxevents);
uint64_t Result = epoll_wait(epfd, &Events.at(0), maxevents, timeout);
uint64_t Result = ::syscall(SYS_epoll_pwait, epfd, &Events.at(0), maxevents, timeout, nullptr, 8);
if (Result != -1) {
for (size_t i = 0; i < Result; ++i) {
@@ -38,23 +40,24 @@ namespace FEX::HLE::x64 {
Event = *event;
EventPtr = &Event;
}
uint64_t Result = epoll_ctl(epfd, op, fd, EventPtr);
uint64_t Result = ::syscall(SYS_epoll_ctl, epfd, op, fd, EventPtr);
if (Result != -1 && event) {
*event = Event;
}
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL_X64(epoll_pwait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, epoll_event_x86 *events, int maxevent, int timeout, const void* sigmask) -> uint64_t {
REGISTER_SYSCALL_IMPL_X64(epoll_pwait, [](FEXCore::Core::CpuStateFrame *Frame, int epfd, epoll_event_x86 *events, int maxevent, int timeout, const uint64_t* sigmask, size_t sigsetsize) -> uint64_t {
std::vector<struct epoll_event> Events;
Events.resize(maxevent);
uint64_t Result = epoll_pwait(
uint64_t Result = ::syscall(SYS_epoll_pwait,
epfd,
&Events.at(0),
maxevent,
timeout,
reinterpret_cast<const sigset_t*>(sigmask));
sigmask,
sigsetsize);
if (Result != -1) {
for (size_t i = 0; i < Result; ++i) {