Files
FEX-Emu--FEX/Source/Tests/LinuxSyscalls/Syscalls/Socket.cpp
T
Ryan Houdek 37983006f0 Moves FEXCore's SignalDelegator and SyscallHandler to the frontend
Sadly these things can't be split without breaking functionality so it
turns in to a bit of a mess.

SyscallHandler is very much something that is a Linux only construct and
shouldn't be in FEXCore itself. Lets the frontend register a
Syscallhandler with FEXCore. FEXCore itself is then aware of the current
syscall ABI and handles the ABI in an optimal fashion.
So it is not a 100% clean break otherwise we would lose performance.

The SignalDelegator then needs to move to the frontend since the
SyscallHandler requires it for signal based syscalls.
The CPU backend signal handling still needs to happen in FEXCore because
it is a very tight coupling with the CPU backend.
Once we need to support more Signal handling we can give the backends
cleaner support to select which specific OS handler to handle.
2020-12-13 22:38:04 -08:00

88 lines
3.9 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 <sys/socket.h>
namespace FEX::HLE {
void RegisterSocket() {
REGISTER_SYSCALL_IMPL(socket, [](FEXCore::Core::InternalThreadState *Thread, int domain, int type, int protocol) -> uint64_t {
uint64_t Result = ::socket(domain, type, protocol);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(connect, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, const struct sockaddr *addr, socklen_t addrlen) -> uint64_t {
uint64_t Result = ::connect(sockfd, addr, addrlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(accept4, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, struct sockaddr *addr, socklen_t *addrlen, int flags) -> uint64_t {
uint64_t Result = ::accept4(sockfd, addr, addrlen, flags);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(sendto, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dest_addr, socklen_t addrlen) -> uint64_t {
uint64_t Result = ::sendto(sockfd, buf, len, flags, dest_addr, addrlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(recvfrom, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen) -> uint64_t {
uint64_t Result = ::recvfrom(sockfd, buf, len, flags, src_addr, addrlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(sendmsg, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, const struct msghdr *msg, int flags) -> uint64_t {
uint64_t Result = ::sendmsg(sockfd, msg, flags);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(recvmsg, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, struct msghdr *msg, int flags) -> uint64_t {
uint64_t Result = ::recvmsg(sockfd, msg, flags);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(shutdown, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, int how) -> uint64_t {
uint64_t Result = ::shutdown(sockfd, how);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(bind, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, const struct sockaddr *addr, socklen_t addrlen) -> uint64_t {
uint64_t Result = ::bind(sockfd, addr, addrlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(listen, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, int backlog) -> uint64_t {
uint64_t Result = ::listen(sockfd, backlog);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(getsockname, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, struct sockaddr *addr, socklen_t *addrlen) -> uint64_t {
uint64_t Result = ::getsockname(sockfd, addr, addrlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(getpeername, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, struct sockaddr *addr, socklen_t *addrlen) -> uint64_t {
uint64_t Result = ::getpeername(sockfd, addr, addrlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(socketpair, [](FEXCore::Core::InternalThreadState *Thread, int domain, int type, int protocol, int sv[2]) -> uint64_t {
uint64_t Result = ::socketpair(domain, type, protocol, sv);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(setsockopt, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, int level, int optname, const void *optval, socklen_t optlen) -> uint64_t {
uint64_t Result = ::setsockopt(sockfd, level, optname, optval, optlen);
SYSCALL_ERRNO();
});
REGISTER_SYSCALL_IMPL(getsockopt, [](FEXCore::Core::InternalThreadState *Thread, int sockfd, int level, int optname, void *optval, socklen_t *optlen) -> uint64_t {
uint64_t Result = ::getsockopt(sockfd, level, optname, optval, optlen);
SYSCALL_ERRNO();
});
}
}