new package: fex

This commit is contained in:
Tee KOBAYASHI 2022-01-15 18:47:28 +09:00 committed by Leonid Pliushch
parent 42d0ec08db
commit 2fb88aa50e
39 changed files with 788 additions and 0 deletions

View File

@ -0,0 +1,11 @@
--- a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp
+++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp
@@ -16,7 +16,7 @@
#include <atomic>
#include <condition_variable>
-#include <bits/types/siginfo_t.h>
+#include <asm-generic/siginfo.h>
#include <csignal>
#include <cstring>

View File

@ -0,0 +1,11 @@
--- a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h
+++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h
@@ -5,7 +5,7 @@
#include "Interface/Context/Context.h"
#include "Interface/Core/ArchHelpers/MContext.h"
-#include <bits/types/stack_t.h>
+#include <asm-generic/signal.h>
#include <cstdint>
#include <stddef.h>
#include <stack>

View File

@ -0,0 +1,11 @@
--- a/External/FEXCore/Source/Interface/Core/Interpreter/InterpreterCore.cpp
+++ b/External/FEXCore/Source/Interface/Core/Interpreter/InterpreterCore.cpp
@@ -11,7 +11,7 @@
#include <FEXCore/Utils/LogManager.h>
#include <memory>
-#include <bits/types/stack_t.h>
+#include <asm-generic/signal.h>
#include <signal.h>
#include <stdint.h>
#include <unordered_map>

View File

@ -0,0 +1,18 @@
--- a/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp
+++ b/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp
@@ -23,7 +23,6 @@
#include <utility>
static constexpr uint64_t PAGE_SHIFT = 12;
-static constexpr uint64_t PAGE_MASK = (1 << PAGE_SHIFT) - 1;
namespace Alloc::OSAllocator {
class OSAllocator_64Bit final : public Alloc::HostAllocator {
@@ -37,7 +36,6 @@
int Munmap(void *addr, size_t length) override;
private:
- constexpr static uint64_t PAGE_SIZE = 4096;
// Upper bound is the maximum virtual address space of the host processor
uintptr_t UPPER_BOUND = (1ULL << 57);

View File

@ -0,0 +1,11 @@
--- a/External/FEXCore/Source/Utils/Allocator/HostAllocator.h
+++ b/External/FEXCore/Source/Utils/Allocator/HostAllocator.h
@@ -5,8 +5,6 @@
#include <memory>
#include <sys/types.h>
-constexpr static uint64_t PAGE_SIZE = 4096;
-
namespace Alloc {
// HostAllocator is just a page pased slab allocator
// Similar to mmap and munmap only mapping at the page level

View File

@ -0,0 +1,19 @@
--- a/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h
+++ b/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h
@@ -7,10 +7,15 @@
#include <bitset>
#include <cstddef>
-#include <memory_resource>
+#include <experimental/list>
+#include <experimental/memory_resource>
#include <mutex>
#include <vector>
+namespace std {
+ namespace pmr = experimental::pmr;
+}
+
namespace Alloc {
class ForwardOnlyIntrusiveArenaAllocator final : public std::pmr::memory_resource {
public:

View File

@ -0,0 +1,13 @@
--- a/External/FEXCore/include/FEXCore/Core/SignalDelegator.h
+++ b/External/FEXCore/include/FEXCore/Core/SignalDelegator.h
@@ -3,8 +3,8 @@
#include <FEXCore/Utils/CompilerDefs.h>
#include <array>
-#include <bits/types/siginfo_t.h>
-#include <bits/types/stack_t.h>
+#include <asm-generic/siginfo.h>
+#include <asm-generic/signal.h>
#include <cstdint>
#include <functional>
#include <utility>

View File

@ -0,0 +1,17 @@
--- a/External/FEXCore/include/FEXCore/Core/UContext.h
+++ b/External/FEXCore/include/FEXCore/Core/UContext.h
@@ -163,12 +163,14 @@
val.si_errno = si_errno;
val.si_code = si_code;
+#ifndef __ANDROID__
// Host siginfo has a pad member that is set to zeros
val.__pad0 = 0;
// Copy over the union
// The union is different sizes on 64-bit versus 32-bit
memcpy(val._sifields._pad, _sifields.pad, std::min(sizeof(val._sifields._pad), sizeof(_sifields.pad)));
+#endif
return val;
}

View File

@ -0,0 +1,10 @@
--- a/Source/Common/SocketLogging.cpp
+++ b/Source/Common/SocketLogging.cpp
@@ -7,6 +7,7 @@
#include <atomic>
#include <fcntl.h>
#include <netdb.h>
+#include <netinet/in.h>
#include <poll.h>
#include <sstream>
#include <string>

View File

@ -0,0 +1,11 @@
--- a/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp
+++ b/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp
@@ -19,8 +19,6 @@
class MemAllocator32Bit final : public FEX::HLE::MemAllocator {
private:
static constexpr uint64_t PAGE_SHIFT = 12;
- static constexpr uint64_t PAGE_SIZE = 1 << PAGE_SHIFT;
- static constexpr uint64_t PAGE_MASK = (1 << PAGE_SHIFT) - 1;
static constexpr uint64_t BASE_KEY = 16;
const uint64_t TOP_KEY = 0xFFFF'F000ULL >> PAGE_SHIFT;
const uint64_t TOP_KEY32BIT = 0x1F'F000ULL >> PAGE_SHIFT;

View File

@ -0,0 +1,19 @@
--- a/Source/Tests/LinuxSyscalls/SignalDelegator.cpp
+++ b/Source/Tests/LinuxSyscalls/SignalDelegator.cpp
@@ -24,7 +24,7 @@
#include <exception>
#include <functional>
#include <linux/futex.h>
-#include <bits/types/stack_t.h>
+#include <asm-generic/signal.h>
#include <signal.h>
#include <syscall.h>
#include <sys/mman.h>
@@ -42,7 +42,6 @@
}
#endif
- constexpr static uint32_t SS_AUTODISARM = (1U << 31);
constexpr static uint32_t X86_MINSIGSTKSZ = 0x2000U;
// We can only have one delegator per process

View File

@ -0,0 +1,13 @@
--- a/Source/Tests/LinuxSyscalls/SignalDelegator.h
+++ b/Source/Tests/LinuxSyscalls/SignalDelegator.h
@@ -9,8 +9,8 @@
#include <array>
#include <atomic>
-#include <bits/types/siginfo_t.h>
-#include <bits/types/stack_t.h>
+#include <asm-generic/siginfo.h>
+#include <asm-generic/signal.h>
#include <stddef.h>
#include <stdint.h>
#include <mutex>

View File

@ -0,0 +1,46 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/FD.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/FD.cpp
@@ -257,11 +257,13 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
REGISTER_SYSCALL_IMPL_PASS(memfd_create, [](FEXCore::Core::CpuStateFrame *Frame, const char *name, uint32_t flags) -> uint64_t {
// Flags don't need remapped
uint64_t Result = ::memfd_create(name, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL(statx, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, int flags, uint32_t mask, struct statx *statxbuf) -> uint64_t {
// Flags don't need remapped
@@ -269,6 +271,7 @@
SYSCALL_ERRNO();
});
+#ifndef __ANDROID__
REGISTER_SYSCALL_IMPL_PASS(name_to_handle_at, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, struct file_handle *handle, int *mount_id, int flags) -> uint64_t {
// Flags don't need remapped
uint64_t Result = ::name_to_handle_at(dirfd, pathname, handle, mount_id, flags);
@@ -280,6 +283,7 @@
uint64_t Result = ::open_by_handle_at(mount_fd, handle, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_PASS(eventfd2, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int count, int flags) -> uint64_t {
// Flags don't need remapped
@@ -287,11 +291,13 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_PASS(copy_file_range, [](FEXCore::Core::CpuStateFrame *Frame, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t {
// Flags don't need remapped
uint64_t Result = ::copy_file_range(fd_in, off_in, fd_out, off_out, len, flags);
SYSCALL_ERRNO();
});
+#endif
if (Handler->IsHostKernelVersionAtLeast(5, 3, 0)) {
REGISTER_SYSCALL_IMPL_PASS(pidfd_open, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, unsigned int flags) -> uint64_t {

View File

@ -0,0 +1,40 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/FS.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/FS.cpp
@@ -10,7 +10,7 @@
#include <stddef.h>
#include <stdint.h>
-#include <sys/fanotify.h>
+#include <linux/fanotify.h>
#include <sys/mount.h>
#include <sys/swap.h>
#include <sys/syscall.h>
@@ -149,10 +149,12 @@
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 28
REGISTER_SYSCALL_IMPL_PASS(syncfs, [](FEXCore::Core::CpuStateFrame *Frame, int fd) -> uint64_t {
uint64_t Result = ::syncfs(fd);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_PASS(setxattr, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, const char *name, const void *value, size_t size, int flags) -> uint64_t {
uint64_t Result = ::setxattr(path, name, value, size, flags);
@@ -214,6 +216,7 @@
SYSCALL_ERRNO();
});
+#ifndef __ANDROID__
REGISTER_SYSCALL_IMPL_PASS(fanotify_init, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int flags, unsigned int event_f_flags) -> uint64_t {
uint64_t Result = ::fanotify_init(flags, event_f_flags);
SYSCALL_ERRNO();
@@ -223,6 +226,7 @@
uint64_t Result = ::fanotify_mark(fanotify_fd, flags, mask, dirfd, pathname);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_PASS(pivot_root, [](FEXCore::Core::CpuStateFrame *Frame, const char *new_root, const char *put_old) -> uint64_t {
uint64_t Result = ::syscall(SYSCALL_DEF(pivot_root), new_root, put_old);

View File

@ -0,0 +1,15 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/Info.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/Info.cpp
@@ -63,10 +63,12 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 28
REGISTER_SYSCALL_IMPL_PASS(getrandom, [](FEXCore::Core::CpuStateFrame *Frame, void *buf, size_t buflen, unsigned int flags) -> uint64_t {
uint64_t Result = ::getrandom(buf, buflen, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_PASS(capget, [](FEXCore::Core::CpuStateFrame *Frame, cap_user_header_t hdrp, cap_user_data_t datap) -> uint64_t {
uint64_t Result = ::syscall(SYSCALL_DEF(capget), hdrp, datap);

View File

@ -0,0 +1,17 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/Key.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/Key.cpp
@@ -30,6 +30,7 @@
SYSCALL_ERRNO();
});
+#ifndef __ANDROID__
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);
@@ -47,5 +48,6 @@
uint64_t Result = ::pkey_free(pkey);
SYSCALL_ERRNO();
});
+#endif
}
}

View File

@ -0,0 +1,23 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/Memory.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/Memory.cpp
@@ -46,16 +46,20 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
REGISTER_SYSCALL_IMPL_PASS(mlock2, [](FEXCore::Core::CpuStateFrame *Frame, const void *addr, size_t len, int flags) -> uint64_t {
uint64_t Result = ::mlock2(addr, len, flags);
SYSCALL_ERRNO();
});
+#endif
+#ifndef __ANDROID__
REGISTER_SYSCALL_IMPL_PASS(remap_file_pages, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t size, int prot, size_t pgoff, int flags) -> uint64_t {
// This syscall is deprecated, not sure when it will end up being removed
uint64_t Result = ::remap_file_pages(addr, size, prot, pgoff, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_PASS(mbind, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags) -> uint64_t {
uint64_t Result = ::syscall(SYSCALL_DEF(mbind), addr, len, mode, nodemask, maxnode, flags);

View File

@ -0,0 +1,27 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/Msg.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/Msg.cpp
@@ -8,7 +8,7 @@
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
#include "Tests/LinuxSyscalls/x32/Syscalls.h"
-#include <mqueue.h>
+#include <linux/mqueue.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
@@ -17,6 +17,7 @@
namespace FEX::HLE {
void RegisterMsg() {
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_PASS(msgget, [](FEXCore::Core::CpuStateFrame *Frame, key_t key, int msgflg) -> uint64_t {
uint64_t Result = ::msgget(key, msgflg);
SYSCALL_ERRNO();
@@ -40,6 +41,7 @@
uint64_t Result = ::msgctl(msqid, cmd, buf);
SYSCALL_ERRNO();
});
+#endif
// last two parameters are optional
REGISTER_SYSCALL_IMPL_PASS(mq_unlink, [](FEXCore::Core::CpuStateFrame *Frame, const char *name) -> uint64_t {

View File

@ -0,0 +1,20 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/Semaphore.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/Semaphore.cpp
@@ -10,14 +10,16 @@
#include <sys/types.h>
#include <sys/ipc.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
namespace FEX::HLE {
void RegisterSemaphore() {
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_PASS(semget, [](FEXCore::Core::CpuStateFrame *Frame, key_t key, int nsems, int semflg) -> uint64_t {
uint64_t Result = ::semget(key, nsems, semflg);
SYSCALL_ERRNO();
});
+#endif
}
}

View File

@ -0,0 +1,11 @@
--- a/Source/Tests/LinuxSyscalls/Syscalls/Thread.cpp
+++ b/Source/Tests/LinuxSyscalls/Syscalls/Thread.cpp
@@ -465,7 +465,7 @@
});
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);
+ uint64_t Result = ::prlimit(pid, resource, new_limit, old_limit);
SYSCALL_ERRNO();
});

View File

@ -0,0 +1,27 @@
--- a/Source/Tests/LinuxSyscalls/x32/FD.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/FD.cpp
@@ -17,7 +17,7 @@
#include <FEXCore/Utils/MathUtils.h>
#include <algorithm>
-#include <bits/types/struct_iovec.h>
+#include <linux/uio.h>
#include <cstdint>
#include <fcntl.h>
#include <limits>
@@ -988,6 +988,7 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_X32(sync_file_range, [](FEXCore::Core::CpuStateFrame *Frame,
int fd,
uint32_t offset_low,
@@ -1007,6 +1008,7 @@
uint64_t Result = ::sync_file_range(fd, Offset, Len, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_X32(fallocate, [](FEXCore::Core::CpuStateFrame *Frame,
int fd,

View File

@ -0,0 +1,11 @@
--- a/Source/Tests/LinuxSyscalls/x32/Info.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Info.cpp
@@ -10,7 +10,7 @@
#include <algorithm>
#include <asm/posix_types.h>
-#include <bits/types/struct_rusage.h>
+#include <linux/resource.h>
#include <limits>
#include <linux/sysinfo.h>
#include <linux/utsname.h>

View File

@ -0,0 +1,15 @@
--- a/Source/Tests/LinuxSyscalls/x32/Memory.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Memory.cpp
@@ -83,10 +83,12 @@
mremap(old_address, old_size, new_size, flags, new_address));
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 30
REGISTER_SYSCALL_IMPL_X32(mlockall, [](FEXCore::Core::CpuStateFrame *Frame, int flags) -> uint64_t {
uint64_t Result = ::mlock2(reinterpret_cast<void*>(0x1'0000), 0x1'0000'0000ULL - 0x1'0000, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_X32(munlockall, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t {
uint64_t Result = ::munlock(reinterpret_cast<void*>(0x1'0000), 0x1'0000'0000ULL - 0x1'0000);

View File

@ -0,0 +1,20 @@
--- a/Source/Tests/LinuxSyscalls/x32/Msg.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Msg.cpp
@@ -10,12 +10,16 @@
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
-#include <mqueue.h>
+#include <linux/mqueue.h>
#include <stdint.h>
#include <syscall.h>
#include <time.h>
#include <unistd.h>
+#ifdef __ANDROID__
+typedef int mqd_t;
+#endif
+
ARG_TO_STR(FEX::HLE::x32::compat_ptr<FEX::HLE::x32::mq_attr32>, "%lx")
ARG_TO_STR(FEX::HLE::x32::compat_ptr<FEX::HLE::x32::sigevent32>, "%lx")

View File

@ -0,0 +1,43 @@
--- a/Source/Tests/LinuxSyscalls/x32/Semaphore.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Semaphore.cpp
@@ -19,7 +19,7 @@
#include <string.h>
#include <sys/ipc.h>
#include <sys/msg.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
#include <sys/shm.h>
#include <time.h>
#include <type_traits>
@@ -90,6 +90,7 @@
uint64_t Result{};
switch (static_cast<IPCOp>(call)) {
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
case OP_SEMOP: {
Result = ::semop(first, reinterpret_cast<struct sembuf*>(ptr), second);
break;
@@ -280,6 +281,7 @@
}
break;
}
+#endif
case OP_SHMAT: {
Result = static_cast<FEX::HLE::x32::x32SyscallHandler*>(FEX::HLE::_SyscallHandler)->GetAllocator()->
shmat(first, reinterpret_cast<const void*>(ptr), second, reinterpret_cast<uint32_t*>(third));
@@ -377,6 +379,7 @@
void RegisterSemaphore() {
REGISTER_SYSCALL_IMPL_X32(ipc, _ipc);
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(semtimedop_time64, semtimedop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) -> uint64_t {
uint64_t Result = ::semtimedop(semid, sops, nsops, timeout);
SYSCALL_ERRNO();
@@ -454,6 +457,7 @@
}
SYSCALL_ERRNO();
});
+#endif
}
}

View File

@ -0,0 +1,11 @@
--- a/Source/Tests/LinuxSyscalls/x32/Signals.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Signals.cpp
@@ -13,7 +13,7 @@
#include <FEXCore/Core/SignalDelegator.h>
#include <FEXCore/Core/UContext.h>
#include <errno.h>
-#include <bits/types/siginfo_t.h>
+#include <asm-generic/siginfo.h>
#include <signal.h>
#include <stdint.h>
#include <sys/syscall.h>

View File

@ -0,0 +1,11 @@
--- a/Source/Tests/LinuxSyscalls/x32/Socket.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Socket.cpp
@@ -11,7 +11,7 @@
#include <FEXCore/Utils/LogManager.h>
#include <alloca.h>
-#include <bits/types/struct_iovec.h>
+#include <linux/uio.h>
#include <cstdint>
#include <cstring>
#include <memory>

View File

@ -0,0 +1,15 @@
--- a/Source/Tests/LinuxSyscalls/x32/Thread.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Thread.cpp
@@ -16,9 +16,9 @@
#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 <asm-generic/siginfo.h>
+#include <asm-generic/signal.h>
+#include <linux/resource.h>
#include <errno.h>
#include <grp.h>
#include <linux/futex.h>

View File

@ -0,0 +1,26 @@
--- a/Source/Tests/LinuxSyscalls/x32/Time.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Time.cpp
@@ -10,7 +10,6 @@
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
-#include <bits/types/clockid_t.h>
#include <stdint.h>
#include <syscall.h>
#include <sys/stat.h>
@@ -165,6 +164,7 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_X32(futimesat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const timeval32 times[2]) -> uint64_t {
uint64_t Result = 0;
if (times) {
@@ -177,6 +177,7 @@
}
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_X32(utimensat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const compat_ptr<timespec32> times, int flags) -> uint64_t {
uint64_t Result = 0;

View File

@ -0,0 +1,10 @@
--- a/Source/Tests/LinuxSyscalls/x32/Timer.cpp
+++ b/Source/Tests/LinuxSyscalls/x32/Timer.cpp
@@ -11,7 +11,6 @@
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
-#include <bits/types/timer_t.h>
#include <stdint.h>
#include <syscall.h>
#include <sys/time.h>

View File

@ -0,0 +1,55 @@
--- a/Source/Tests/LinuxSyscalls/x32/Types.h
+++ b/Source/Tests/LinuxSyscalls/x32/Types.h
@@ -12,23 +12,25 @@
#include <linux/types.h>
#include <asm/ipcbuf.h>
#include <asm/shmbuf.h>
-#include <bits/types/stack_t.h>
+#include <asm-generic/signal.h>
#include <cstdint>
#include <cstring>
#include <fcntl.h>
#include <limits>
#include <sys/ipc.h>
-#include <mqueue.h>
+#include <linux/mqueue.h>
#include <signal.h>
#include <sys/msg.h>
#include <sys/resource.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
+#define semid_ds semid64_ds
#include <sys/shm.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/time.h>
#include <sys/times.h>
+#include <linux/timex.h>
#include <sys/uio.h>
#include <time.h>
#include <type_traits>
@@ -387,10 +389,13 @@
uint32_t st_blksize;
uint32_t st_blocks; /* Number 512-byte blocks allocated. */
uint32_t st_atime_;
+#undef st_atime_nsec
uint32_t st_atime_nsec;
uint32_t st_mtime_;
+#undef st_mtime_nsec
uint32_t st_mtime_nsec;
uint32_t st_ctime_;
+#undef st_ctime_nsec
uint32_t st_ctime_nsec;
uint32_t __unused4;
uint32_t __unused5;
@@ -1164,9 +1169,6 @@
static_assert(std::is_trivial<sigval32>::value, "Needs to be trivial");
static_assert(sizeof(sigval32) == 4, "Incorrect size");
-constexpr size_t SIGEV_MAX_SIZE = 64;
-constexpr size_t SIGEV_PAD_SIZE = (SIGEV_MAX_SIZE - (sizeof(int32_t) * 2 + sizeof(sigval32))) / sizeof(int32_t);
-
struct
FEX_ANNOTATE("fex-match")
sigevent32 {

View File

@ -0,0 +1,29 @@
--- a/Source/Tests/LinuxSyscalls/x64/FD.cpp
+++ b/Source/Tests/LinuxSyscalls/x64/FD.cpp
@@ -56,10 +56,12 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_X64_PASS(futimesat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timeval times[2]) -> uint64_t {
uint64_t Result = ::futimesat(dirfd, pathname, times);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_X64_PASS(utimensat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timespec times[2], int flags) -> uint64_t {
uint64_t Result = ::syscall(SYSCALL_DEF(utimensat), dirfd, pathname, times, flags);
@@ -241,11 +243,13 @@
SYSCALL_ERRNO();
});
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_X64_PASS(sync_file_range, [](FEXCore::Core::CpuStateFrame *Frame, int fd, off64_t offset, off64_t nbytes, unsigned int flags) -> uint64_t {
// Flags don't need remapped
uint64_t Result = ::sync_file_range(fd, offset, nbytes, flags);
SYSCALL_ERRNO();
});
+#endif
REGISTER_SYSCALL_IMPL_X64_PASS(fallocate, [](FEXCore::Core::CpuStateFrame *Frame, int fd, int mode, off_t offset, off_t len) -> uint64_t {
uint64_t Result = ::fallocate(fd, mode, offset, len);

View File

@ -0,0 +1,20 @@
--- a/Source/Tests/LinuxSyscalls/x64/Msg.cpp
+++ b/Source/Tests/LinuxSyscalls/x64/Msg.cpp
@@ -7,12 +7,16 @@
#include "Tests/LinuxSyscalls/Syscalls.h"
#include "Tests/LinuxSyscalls/x64/Syscalls.h"
-#include <mqueue.h>
+#include <linux/mqueue.h>
#include <stddef.h>
#include <stdint.h>
#include <syscall.h>
#include <unistd.h>
+#ifdef __ANDROID__
+typedef int mqd_t;
+#endif
+
namespace FEXCore::Core {
struct CpuStateFrame;
}

View File

@ -0,0 +1,26 @@
--- a/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp
+++ b/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp
@@ -12,7 +12,7 @@
#include <stddef.h>
#include <stdint.h>
-#include <sys/sem.h>
+#include <linux/sem.h>
namespace FEXCore::Core {
struct CpuStateFrame;
@@ -22,6 +22,7 @@
namespace FEX::HLE::x64 {
void RegisterSemaphore() {
+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26
REGISTER_SYSCALL_IMPL_X64_PASS(semop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops) -> uint64_t {
uint64_t Result = ::semop(semid, sops, nsops);
SYSCALL_ERRNO();
@@ -87,5 +88,6 @@
}
SYSCALL_ERRNO();
});
+#endif
}
}

View File

@ -0,0 +1,13 @@
--- a/Source/Tests/LinuxSyscalls/x64/Thread.cpp
+++ b/Source/Tests/LinuxSyscalls/x64/Thread.cpp
@@ -14,8 +14,8 @@
#include <FEXCore/Debug/InternalThreadState.h>
#include <FEXCore/HLE/Linux/ThreadManagement.h>
-#include <bits/types/siginfo_t.h>
-#include <bits/types/stack_t.h>
+#include <asm-generic/siginfo.h>
+#include <asm-generic/signal.h>
#include <sched.h>
#include <stddef.h>
#include <syscall.h>

View File

@ -0,0 +1,29 @@
--- a/Source/Tests/LinuxSyscalls/x64/Types.h
+++ b/Source/Tests/LinuxSyscalls/x64/Types.h
@@ -13,7 +13,9 @@
#include <asm/posix_types.h>
#include <asm/sembuf.h>
#include <cstdint>
-#include <sys/sem.h>
+#include <linux/sem.h>
+#define semid_ds semid64_ds
+#include <sys/ipc.h>
#include <sys/stat.h>
#include <type_traits>
@@ -128,11 +130,15 @@
__kernel_long_t st_blocks; /* Number 512-byte blocks allocated. */
__kernel_ulong_t st_atime_;
+#undef st_atime_nsec
__kernel_ulong_t st_atime_nsec;
__kernel_ulong_t st_mtime_;
+#undef st_mtime_nsec
__kernel_ulong_t st_mtime_nsec;
__kernel_ulong_t st_ctime_;
+#undef st_ctime_nsec
__kernel_ulong_t st_ctime_nsec;
+#undef __unused
__kernel_long_t __unused[3];
guest_stat() = delete;

View File

@ -0,0 +1,17 @@
--- a/Source/Tools/CMakeLists.txt
+++ b/Source/Tools/CMakeLists.txt
@@ -2,11 +2,11 @@
add_subdirectory(Debugger/)
endif()
-add_subdirectory(FEXConfig/)
+#add_subdirectory(FEXConfig/)
add_subdirectory(FEXGetConfig/)
add_subdirectory(FEXMountDaemon/)
-add_subdirectory(FEXLogServer/)
-add_subdirectory(FEXRootFSFetcher/)
+#add_subdirectory(FEXLogServer/)
+#add_subdirectory(FEXRootFSFetcher/)
set(NAME Opt)
set(SRCS Opt.cpp)

View File

@ -0,0 +1,11 @@
--- a/Source/Tools/FEXMountDaemon/Main.cpp
+++ b/Source/Tools/FEXMountDaemon/Main.cpp
@@ -2,7 +2,7 @@
#include <FEXHeaderUtils/Syscalls.h>
#include <atomic>
-#include <bits/types/siginfo_t.h>
+#include <asm-generic/siginfo.h>
#include <chrono>
#include <condition_variable>
#include <cstdlib>

36
packages/fex/build.sh Normal file
View File

@ -0,0 +1,36 @@
TERMUX_PKG_HOMEPAGE=https://wiki.fex-emu.org/index.php/Main_Page
TERMUX_PKG_DESCRIPTION="Fast x86 emulation frontend"
TERMUX_PKG_LICENSE="MIT"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=2201
TERMUX_PKG_SRCURL=https://github.com/FEX-Emu/FEX.git
TERMUX_PKG_GIT_BRANCH=FEX-${TERMUX_PKG_VERSION}
TERMUX_PKG_DEPENDS="libandroid-shmem, libc++"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-DBUILD_TESTS=OFF
-DENABLE_LTO=OFF
-DENABLE_JEMALLOC=OFF
-DENABLE_OFFLINE_TELEMETRY=OFF
"
TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64"
termux_step_pre_configure() {
LDFLAGS+=" -landroid-shmem"
find $TERMUX_PKG_SRCDIR -name '*.h' -o -name '*.c' -o -name '*.cpp' | \
xargs -n 1 sed -i -e 's:"/tmp:"'$TERMUX_PREFIX'/tmp:g'
_NEED_DUMMY_LIBPTHREAD_A=
_LIBPTHREAD_A=$TERMUX_PREFIX/lib/libpthread.a
if [ ! -e $_LIBPTHREAD_A ]; then
_NEED_DUMMY_LIBPTHREAD_A=true
echo '!<arch>' > $_LIBPTHREAD_A
fi
}
termux_step_post_make_install() {
if [ $_NEED_DUMMY_LIBPTHREAD_A ]; then
rm -f $_LIBPTHREAD_A
fi
}