Skip to content

Commit

Permalink
Merge pull request #1551 from Sonicadvance1/fix_older_env
Browse files Browse the repository at this point in the history
Some fixes for older environments
  • Loading branch information
lioncash authored Feb 6, 2022
2 parents 8c956e6 + 9a64e7f commit 1b99495
Show file tree
Hide file tree
Showing 25 changed files with 36 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include <atomic>
#include <condition_variable>
#include <bits/types/siginfo_t.h>
#include <csignal>
#include <cstring>
#include <signal.h>

namespace FEXCore::CPU {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include "Interface/Context/Context.h"
#include "Interface/Core/ArchHelpers/MContext.h"

#include <bits/types/stack_t.h>
#include <cstdint>
#include <signal.h>
#include <stddef.h>
#include <stack>
#include <tuple>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <FEXCore/Utils/LogManager.h>

#include <memory>
#include <bits/types/stack_t.h>
#include <signal.h>
#include <stdint.h>
#include <unordered_map>
Expand Down
1 change: 0 additions & 1 deletion External/FEXCore/Source/Interface/Core/JIT/x86_64/JIT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ desc: Main glue logic of the x86-64 splatter backend

#include <algorithm>
#include <array>
#include <bits/types/stack_t.h>
#include <memory>
#include <stddef.h>
#include <stdint.h>
Expand Down
3 changes: 1 addition & 2 deletions External/FEXCore/include/FEXCore/Core/SignalDelegator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
#include <FEXCore/Utils/CompilerDefs.h>

#include <array>
#include <bits/types/siginfo_t.h>
#include <bits/types/stack_t.h>
#include <cstdint>
#include <functional>
#include <utility>
#include <signal.h>
#include <stddef.h>

namespace FEXCore {
Expand Down
1 change: 1 addition & 0 deletions External/FEXCore/include/FEXCore/Utils/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <cstdint>
#include <functional>
#include <sys/types.h>

namespace FEXCore::Allocator {
using MMAP_Hook = void*(*)(void*, size_t, int, int, int, off_t);
Expand Down
4 changes: 4 additions & 0 deletions Source/Common/SocketLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include <sys/un.h>
#include <unistd.h>

// For older build environments
#ifndef POLLREMOVE
#define POLLREMOVE 0x1000
#endif
namespace FEX::SocketLogging {
namespace Common {
enum class PacketTypes : uint32_t {
Expand Down
6 changes: 3 additions & 3 deletions Source/Tests/LinuxSyscalls/Arm64/SyscallsEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ enum Syscalls_Arm64 {
SYSCALL_Arm64_write = 64,
SYSCALL_Arm64_readv = 65,
SYSCALL_Arm64_writev = 66,
SYSCALL_Arm64_pread64 = 67,
SYSCALL_Arm64_pwrite64 = 68,
SYSCALL_Arm64_pread_64 = 67,
SYSCALL_Arm64_pwrite_64 = 68,
SYSCALL_Arm64_preadv = 69,
SYSCALL_Arm64_pwritev = 70,
SYSCALL_Arm64_sendfile = 71,
Expand Down Expand Up @@ -255,7 +255,7 @@ enum Syscalls_Arm64 {
SYSCALL_Arm64_accept4 = 242,
SYSCALL_Arm64_recvmmsg = 243,
SYSCALL_Arm64_wait4 = 260,
SYSCALL_Arm64_prlimit64 = 261,
SYSCALL_Arm64_prlimit_64 = 261,
SYSCALL_Arm64_fanotify_init = 262,
SYSCALL_Arm64_fanotify_mark = 263,
SYSCALL_Arm64_name_to_handle_at = 264,
Expand Down
7 changes: 5 additions & 2 deletions Source/Tests/LinuxSyscalls/SignalDelegator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@ desc: Handles host -> host and host -> guest signal routing, emulates procmask &
#include <exception>
#include <functional>
#include <linux/futex.h>
#include <bits/types/stack_t.h>
#include <signal.h>
#include <syscall.h>
#include <sys/mman.h>
#include <sys/signalfd.h>
#include <unistd.h>
#include <utility>

// For older build environments
#ifndef SS_AUTODISARM
#define SS_AUTODISARM (1U << 31)
#endif

namespace FEX::HLE {
#ifdef _M_X86_64
__attribute__((naked))
Expand All @@ -42,7 +46,6 @@ namespace FEX::HLE {
}
#endif

constexpr static uint32_t SS_AUTODISARM = (1U << 31);
constexpr static uint32_t X86_MINSIGSTKSZ = 0x2000U;

// We can only have one delegator per process
Expand Down
3 changes: 1 addition & 2 deletions Source/Tests/LinuxSyscalls/SignalDelegator.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ tags: LinuxSyscalls|common

#include <array>
#include <atomic>
#include <bits/types/siginfo_t.h>
#include <bits/types/stack_t.h>
#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <mutex>
Expand Down
6 changes: 3 additions & 3 deletions Source/Tests/LinuxSyscalls/Syscalls/Key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ namespace FEX::HLE {

REGISTER_SYSCALL_IMPL_PASS(pkey_mprotect, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t len, int prot, int pkey) -> uint64_t {
// Added in Linux 4.9
uint64_t Result = ::pkey_mprotect(addr, len, prot, pkey);
uint64_t Result = ::syscall(SYSCALL_DEF(pkey_mprotect), addr, len, prot, pkey);
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL_PASS(pkey_alloc, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int flags, unsigned int access_rights) -> uint64_t {
// Added in Linux 4.9
uint64_t Result = ::pkey_alloc(flags, access_rights);
uint64_t Result = ::syscall(SYSCALL_DEF(pkey_alloc), flags, access_rights);
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL_PASS(pkey_free, [](FEXCore::Core::CpuStateFrame *Frame, int pkey) -> uint64_t {
// Added in Linux 4.9
uint64_t Result = ::pkey_free(pkey);
uint64_t Result = ::syscall(SYSCALL_DEF(pkey_free), pkey);
SYSCALL_ERRNO();
});
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Tests/LinuxSyscalls/Syscalls/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ namespace FEX::HLE {
std::terminate();
});

REGISTER_SYSCALL_IMPL_PASS(prlimit64, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) -> uint64_t {
uint64_t Result = ::prlimit(pid, (enum __rlimit_resource)(resource), new_limit, old_limit);
REGISTER_SYSCALL_IMPL_PASS(prlimit_64, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) -> uint64_t {
uint64_t Result = ::syscall(SYSCALL_DEF(prlimit_64), pid, resource, new_limit, old_limit);
SYSCALL_ERRNO();
});

Expand Down
5 changes: 2 additions & 3 deletions Source/Tests/LinuxSyscalls/x32/FD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ tags: LinuxSyscalls|syscalls-x86-32
#include <FEXCore/Utils/MathUtils.h>

#include <algorithm>
#include <bits/types/struct_iovec.h>
#include <cstdint>
#include <fcntl.h>
#include <limits>
Expand Down Expand Up @@ -961,7 +960,7 @@ namespace FEX::HLE::x32 {
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL_X32(pread64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, uint32_t count, uint32_t offset_low, uint32_t offset_high) -> uint64_t {
REGISTER_SYSCALL_IMPL_X32(pread_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, uint32_t count, uint32_t offset_low, uint32_t offset_high) -> uint64_t {
uint64_t Offset = offset_high;
Offset <<= 32;
Offset |= offset_low;
Expand All @@ -970,7 +969,7 @@ namespace FEX::HLE::x32 {
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL_X32(pwrite64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, uint32_t count, uint32_t offset_low, uint32_t offset_high) -> uint64_t {
REGISTER_SYSCALL_IMPL_X32(pwrite_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, uint32_t count, uint32_t offset_low, uint32_t offset_high) -> uint64_t {
uint64_t Offset = offset_high;
Offset <<= 32;
Offset |= offset_low;
Expand Down
2 changes: 0 additions & 2 deletions Source/Tests/LinuxSyscalls/x32/Info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ tags: LinuxSyscalls|syscalls-x86-32

#include <algorithm>
#include <asm/posix_types.h>
#include <bits/types/struct_rusage.h>
#include <limits>
#include <linux/sysinfo.h>
#include <linux/utsname.h>
#include <stdint.h>
#include <sys/resource.h>
Expand Down
1 change: 0 additions & 1 deletion Source/Tests/LinuxSyscalls/x32/Signals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tags: LinuxSyscalls|syscalls-x86-32
#include <FEXCore/Core/SignalDelegator.h>
#include <FEXCore/Core/UContext.h>
#include <errno.h>
#include <bits/types/siginfo_t.h>
#include <signal.h>
#include <stdint.h>
#include <sys/syscall.h>
Expand Down
1 change: 0 additions & 1 deletion Source/Tests/LinuxSyscalls/x32/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ tags: LinuxSyscalls|syscalls-x86-32
#include <FEXCore/Utils/LogManager.h>

#include <alloca.h>
#include <bits/types/struct_iovec.h>
#include <cstdint>
#include <cstring>
#include <memory>
Expand Down
6 changes: 3 additions & 3 deletions Source/Tests/LinuxSyscalls/x32/SyscallsEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ enum Syscalls_x86 {
SYSCALL_x86_rt_sigtimedwait = 177,
SYSCALL_x86_rt_sigqueueinfo = 178,
SYSCALL_x86_rt_sigsuspend = 179,
SYSCALL_x86_pread64 = 180,
SYSCALL_x86_pwrite64 = 181,
SYSCALL_x86_pread_64 = 180,
SYSCALL_x86_pwrite_64 = 181,
SYSCALL_x86_chown = 182,
SYSCALL_x86_getcwd = 183,
SYSCALL_x86_capget = 184,
Expand Down Expand Up @@ -361,7 +361,7 @@ enum Syscalls_x86 {
SYSCALL_x86_recvmmsg = 337,
SYSCALL_x86_fanotify_init = 338,
SYSCALL_x86_fanotify_mark = 339,
SYSCALL_x86_prlimit64 = 340,
SYSCALL_x86_prlimit_64 = 340,
SYSCALL_x86_name_to_handle_at = 341,
SYSCALL_x86_open_by_handle_at = 342,
SYSCALL_x86_clock_adjtime = 343,
Expand Down
5 changes: 2 additions & 3 deletions Source/Tests/LinuxSyscalls/x32/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ tags: LinuxSyscalls|syscalls-x86-32
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/HLE/Linux/ThreadManagement.h>

#include <bits/types/siginfo_t.h>
#include <bits/types/stack_t.h>
#include <bits/types/struct_rusage.h>
#include <errno.h>
#include <grp.h>
#include <linux/futex.h>
#include <sched.h>
#include <signal.h>
#include <sys/fsuid.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <syscall.h>
#include <time.h>
Expand Down
1 change: 0 additions & 1 deletion Source/Tests/LinuxSyscalls/x32/Time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ tags: LinuxSyscalls|syscalls-x86-32

#include "Tests/LinuxSyscalls/x64/Syscalls.h"

#include <bits/types/clockid_t.h>
#include <stdint.h>
#include <syscall.h>
#include <sys/stat.h>
Expand Down
1 change: 0 additions & 1 deletion Source/Tests/LinuxSyscalls/x32/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ tags: LinuxSyscalls|syscalls-x86-32

#include "Tests/LinuxSyscalls/x64/Syscalls.h"

#include <bits/types/timer_t.h>
#include <stdint.h>
#include <syscall.h>
#include <sys/time.h>
Expand Down
4 changes: 1 addition & 3 deletions Source/Tests/LinuxSyscalls/x32/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ tags: LinuxSyscalls|syscalls-x86-32
#include <FEXCore/Core/SignalDelegator.h>
#include <FEXCore/Utils/CompilerDefs.h>

#include <linux/types.h>
#include <asm/ipcbuf.h>
#include <asm/shmbuf.h>
#include <bits/types/stack_t.h>
#include <cstdint>
#include <cstring>
#include <fcntl.h>
Expand All @@ -27,8 +25,8 @@ tags: LinuxSyscalls|syscalls-x86-32
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/timex.h>
#include <sys/uio.h>
#include <time.h>
#include <type_traits>
Expand Down
4 changes: 2 additions & 2 deletions Source/Tests/LinuxSyscalls/x64/FD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,12 @@ namespace FEX::HLE::x64 {
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL_X64_PASS(pread64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count, off_t offset) -> uint64_t {
REGISTER_SYSCALL_IMPL_X64_PASS(pread_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count, off_t offset) -> uint64_t {
uint64_t Result = ::pread64(fd, buf, count, offset);
SYSCALL_ERRNO();
});

REGISTER_SYSCALL_IMPL_X64_PASS(pwrite64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count, off_t offset) -> uint64_t {
REGISTER_SYSCALL_IMPL_X64_PASS(pwrite_64, [](FEXCore::Core::CpuStateFrame *Frame, int fd, void *buf, size_t count, off_t offset) -> uint64_t {
uint64_t Result = ::pwrite64(fd, buf, count, offset);
SYSCALL_ERRNO();
});
Expand Down
6 changes: 3 additions & 3 deletions Source/Tests/LinuxSyscalls/x64/SyscallsEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ enum Syscalls_x64 {
SYSCALL_x64_rt_sigprocmask = 14,
SYSCALL_x64_rt_sigreturn = 15,
SYSCALL_x64_ioctl = 16,
SYSCALL_x64_pread64 = 17,
SYSCALL_x64_pwrite64 = 18,
SYSCALL_x64_pread_64 = 17,
SYSCALL_x64_pwrite_64 = 18,
SYSCALL_x64_readv = 19,
SYSCALL_x64_writev = 20,
SYSCALL_x64_access = 21,
Expand Down Expand Up @@ -324,7 +324,7 @@ enum Syscalls_x64 {
SYSCALL_x64_recvmmsg = 299,
SYSCALL_x64_fanotify_init = 300,
SYSCALL_x64_fanotify_mark = 301,
SYSCALL_x64_prlimit64 = 302,
SYSCALL_x64_prlimit_64 = 302,
SYSCALL_x64_name_to_handle_at = 303,
SYSCALL_x64_open_by_handle_at = 304,
SYSCALL_x64_clock_adjtime = 305,
Expand Down
3 changes: 1 addition & 2 deletions Source/Tests/LinuxSyscalls/x64/Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ tags: LinuxSyscalls|syscalls-x86-64
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/HLE/Linux/ThreadManagement.h>

#include <bits/types/siginfo_t.h>
#include <bits/types/stack_t.h>
#include <sched.h>
#include <signal.h>
#include <stddef.h>
#include <syscall.h>
#include <stdint.h>
Expand Down
1 change: 0 additions & 1 deletion Source/Tools/FEXMountDaemon/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include <FEXHeaderUtils/Syscalls.h>

#include <atomic>
#include <bits/types/siginfo_t.h>
#include <chrono>
#include <condition_variable>
#include <cstdlib>
Expand Down

0 comments on commit 1b99495

Please sign in to comment.