mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-25 09:00:49 +01:00
Merge pull request #2640 from Sonicadvance1/mingw_more
Get mingw compiling libFEXCore
This commit is contained in:
17 files changed
+145
-12
No files matched your search
+8
@@ -229,6 +229,8 @@ set (LIBS fmt::fmt vixl xxhash tiny-json FEXHeaderUtils)
|
||||
|
||||
if (NOT MINGW_BUILD)
|
||||
list (APPEND LIBS dl)
|
||||
else()
|
||||
list (APPEND LIBS synchronization)
|
||||
endif()
|
||||
|
||||
if (ENABLE_JEMALLOC)
|
||||
@@ -399,6 +401,12 @@ function(AddLibrary Name Type)
|
||||
if (MINGW_BUILD)
|
||||
# Mingw build isn't building a linux shared library, so it can't have a SONAME.
|
||||
set_target_properties(${Name} PROPERTIES NO_SONAME ON)
|
||||
# Change the suffixes otherwise cmake continues using .a and .so
|
||||
if (${Type} STREQUAL SHARED)
|
||||
set_target_properties(${Name} PROPERTIES SUFFIX ".dll")
|
||||
elseif(${Type} STREQUAL STATIC)
|
||||
set_target_properties(${Name} PROPERTIES SUFFIX ".lib")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
AddDefaultOptionsToTarget(${Name})
|
||||
|
||||
+4
@@ -445,6 +445,7 @@ struct FEX_PACKED X80SoftFloat {
|
||||
return FEXCore::BitCast<double>(Result);
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
operator BIGFLOAT() const {
|
||||
#if BIGFLOATSIZE == 16
|
||||
const float128_t Result = extF80_to_f128(*this);
|
||||
@@ -455,6 +456,7 @@ struct FEX_PACKED X80SoftFloat {
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
operator int16_t() const {
|
||||
auto rv = extF80_to_i32(*this, softfloat_roundingMode, false);
|
||||
@@ -523,6 +525,7 @@ struct FEX_PACKED X80SoftFloat {
|
||||
*this = f64_to_extF80(FEXCore::BitCast<float64_t>(rhs));
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
X80SoftFloat(BIGFLOAT rhs) {
|
||||
#if BIGFLOATSIZE == 16
|
||||
*this = f128_to_extF80(FEXCore::BitCast<float128_t>(rhs));
|
||||
@@ -530,6 +533,7 @@ struct FEX_PACKED X80SoftFloat {
|
||||
*this = FEXCore::BitCast<long double>(rhs);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
X80SoftFloat(const int16_t rhs) {
|
||||
*this = i32_to_extF80(rhs);
|
||||
|
||||
+2
-2
@@ -66,9 +66,7 @@ $end_info$
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <string_view>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <type_traits>
|
||||
#include <unistd.h>
|
||||
#include <unordered_map>
|
||||
@@ -714,6 +712,7 @@ namespace FEXCore::Context {
|
||||
}
|
||||
|
||||
static void IRDumper(FEXCore::Core::InternalThreadState *Thread, IR::IREmitter *IREmitter, uint64_t GuestRIP, IR::RegisterAllocationData* RA) {
|
||||
#ifndef _WIN32
|
||||
int FD {-1};
|
||||
bool CloseAfter = false;
|
||||
const auto DumpIRStr = static_cast<ContextImpl*>(Thread->CTX)->Config.DumpIR();
|
||||
@@ -742,6 +741,7 @@ namespace FEXCore::Context {
|
||||
close(FD);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
static void ValidateIR(ContextImpl *ctx, IR::IREmitter *IREmitter) {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <FEXCore/Config/Config.h>
|
||||
#include <FEXCore/Core/CoreState.h>
|
||||
#include <FEXCore/Core/SignalDelegator.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/Debug/InternalThreadState.h>
|
||||
#include <FEXCore/Utils/Event.h>
|
||||
|
||||
@@ -23,7 +23,6 @@ $end_info$
|
||||
#include "Utils/MemberFunctionToPointer.h"
|
||||
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Utils/Allocator.h>
|
||||
#include <FEXCore/Utils/CompilerDefs.h>
|
||||
#include <FEXCore/Utils/EnumUtils.h>
|
||||
@@ -31,7 +30,6 @@ $end_info$
|
||||
|
||||
#include "Interface/Core/Interpreter/InterpreterOps.h"
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -4,7 +4,10 @@ tags: backend|arm64
|
||||
$end_info$
|
||||
*/
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <syscall.h>
|
||||
#endif
|
||||
|
||||
#include "Interface/Core/ArchHelpers/CodeEmitter/Emitter.h"
|
||||
#include "Interface/Core/JIT/Arm64/JITClass.h"
|
||||
#include "FEXCore/Debug/InternalThreadState.h"
|
||||
@@ -34,6 +37,7 @@ DEF_OP(Fence) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
DEF_OP(Break) {
|
||||
auto Op = IROp->C<IR::IROp_Break>();
|
||||
|
||||
@@ -73,6 +77,11 @@ DEF_OP(Break) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
DEF_OP(Break) {
|
||||
ERROR_AND_DIE_FMT("Unsupported");
|
||||
}
|
||||
#endif
|
||||
|
||||
DEF_OP(GetRoundingMode) {
|
||||
auto Dst = GetReg(Node);
|
||||
@@ -157,6 +166,7 @@ DEF_OP(Print) {
|
||||
PopDynamicRegsAndLR();
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
DEF_OP(ProcessorID) {
|
||||
// We always need to spill x8 since we can't know if it is live at this SSA location
|
||||
uint32_t SpillMask = 1U << 8;
|
||||
@@ -207,6 +217,11 @@ DEF_OP(ProcessorID) {
|
||||
// Node is in w1
|
||||
orr(ARMEmitter::Size::i64Bit, GetReg(Node), ARMEmitter::Reg::r0, ARMEmitter::Reg::r1, ARMEmitter::ShiftType::LSL, 12);
|
||||
}
|
||||
#else
|
||||
DEF_OP(ProcessorID) {
|
||||
ERROR_AND_DIE_FMT("Unsupported");
|
||||
}
|
||||
#endif
|
||||
|
||||
DEF_OP(RDRAND) {
|
||||
auto Op = IROp->C<IR::IROp_RDRAND>();
|
||||
|
||||
@@ -35,7 +35,6 @@ $end_info$
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <signal.h>
|
||||
#include <sys/mman.h>
|
||||
#include <tuple>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
+1
-1
@@ -9,9 +9,9 @@ $end_info$
|
||||
#include <FEXCore/fextl/fmt.h>
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
#include <alloca.h>
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <malloc.h>
|
||||
|
||||
namespace LogMan {
|
||||
|
||||
|
||||
+2
@@ -2,9 +2,11 @@
|
||||
#include <cstdint>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#ifndef _WIN32
|
||||
#include <linux/magic.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/vfs.h>
|
||||
#endif
|
||||
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/Utils/Profiler.h>
|
||||
|
||||
@@ -4,8 +4,14 @@
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <cstdint>
|
||||
#ifndef _WIN32
|
||||
#include <linux/futex.h>
|
||||
#include <sys/syscall.h>
|
||||
#else
|
||||
#include <errhandlingapi.h>
|
||||
#include <synchapi.h>
|
||||
#include <winerror.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
namespace FEXCore {
|
||||
@@ -17,6 +23,7 @@ namespace FEXCore {
|
||||
* call can leave the condition variable in an invalid state that breaks later
|
||||
* uses of that object and may cause hangs as a consequence.
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
class InterruptableConditionVariable final {
|
||||
public:
|
||||
bool Wait(struct timespec *Timeout = nullptr) {
|
||||
@@ -86,4 +93,68 @@ namespace FEXCore {
|
||||
}
|
||||
}
|
||||
};
|
||||
#else
|
||||
class InterruptableConditionVariable final {
|
||||
public:
|
||||
bool Wait(struct timespec *Timeout = nullptr) {
|
||||
while (true) {
|
||||
uint32_t Expected = SIGNALED;
|
||||
uint32_t Desired = UNSIGNALED;
|
||||
|
||||
// If the mutex was already signaled then we can early exit
|
||||
if (Mutex.compare_exchange_strong(Expected, Desired)) {
|
||||
return true;
|
||||
}
|
||||
// Windows only supports millisecond granularity.
|
||||
const uint32_t TimeoutMS = Timeout ? Timeout->tv_sec * 1000 + (Timeout->tv_nsec / 1000000) : 0;
|
||||
|
||||
// WaitOnAddress returns when the value at `Address` differs from the value at `CompareAddress`.
|
||||
bool Result = WaitOnAddress(&Mutex, &Desired, 4, TimeoutMS);
|
||||
|
||||
if (Timeout && Result == false && GetLastError() == ERROR_TIMEOUT) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class Rep, class Period>
|
||||
bool WaitFor(std::chrono::duration<Rep, Period> const& time) {
|
||||
struct timespec Timeout{};
|
||||
auto SecondsDuration = std::chrono::duration_cast<std::chrono::seconds>(time);
|
||||
Timeout.tv_sec = SecondsDuration.count();
|
||||
Timeout.tv_nsec = std::chrono::duration_cast<std::chrono::nanoseconds>(time - SecondsDuration).count();
|
||||
return Wait(&Timeout);
|
||||
}
|
||||
|
||||
void NotifyOne() {
|
||||
DoNotify(false);
|
||||
}
|
||||
|
||||
void NotifyAll() {
|
||||
// Maximum number of waiters
|
||||
DoNotify(true);
|
||||
}
|
||||
|
||||
private:
|
||||
std::atomic<uint32_t> Mutex{};
|
||||
constexpr static uint32_t SIGNALED = 1;
|
||||
constexpr static uint32_t UNSIGNALED = 0;
|
||||
|
||||
void DoNotify(bool All) {
|
||||
uint32_t Expected = UNSIGNALED;
|
||||
uint32_t Desired = SIGNALED;
|
||||
|
||||
// If the mutex was in an unsignaled state then signal
|
||||
if (Mutex.compare_exchange_strong(Expected, Desired)) {
|
||||
if (All) {
|
||||
WakeByAddressAll(&Mutex);
|
||||
}
|
||||
else {
|
||||
WakeByAddressSingle(&Mutex);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -6,8 +6,10 @@
|
||||
#include <cstdint>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#ifndef _WIN32
|
||||
#include <signal.h>
|
||||
#include <sys/syscall.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
namespace FHU {
|
||||
@@ -30,6 +32,7 @@ namespace FHU {
|
||||
* 1) Unlock Mutex
|
||||
* 2) Unmask signals
|
||||
*/
|
||||
#ifndef _WIN32
|
||||
template<typename MutexType, void (MutexType::*lock_fn)(), void (MutexType::*unlock_fn)()>
|
||||
class ScopedSignalMaskWithMutexBase final {
|
||||
public:
|
||||
@@ -66,6 +69,39 @@ namespace FHU {
|
||||
uint64_t OriginalMask{};
|
||||
MutexType *Mutex;
|
||||
};
|
||||
#else
|
||||
// TODO: Doesn't block signals which may or may not cause issues.
|
||||
template<typename MutexType, void (MutexType::*lock_fn)(), void (MutexType::*unlock_fn)()>
|
||||
class ScopedSignalMaskWithMutexBase final {
|
||||
public:
|
||||
|
||||
ScopedSignalMaskWithMutexBase(MutexType &_Mutex, [[maybe_unused]] uint64_t Mask = ~0ULL)
|
||||
: Mutex {&_Mutex} {
|
||||
// Lock the mutex
|
||||
(Mutex->*lock_fn)();
|
||||
}
|
||||
|
||||
// No copy or assignment possible
|
||||
ScopedSignalMaskWithMutexBase(const ScopedSignalMaskWithMutexBase&) = delete;
|
||||
ScopedSignalMaskWithMutexBase& operator=(ScopedSignalMaskWithMutexBase&) = delete;
|
||||
|
||||
// Only move
|
||||
ScopedSignalMaskWithMutexBase(ScopedSignalMaskWithMutexBase &&rhs)
|
||||
: Mutex {rhs.Mutex} {
|
||||
rhs.Mutex = nullptr;
|
||||
}
|
||||
|
||||
~ScopedSignalMaskWithMutexBase() {
|
||||
if (Mutex != nullptr) {
|
||||
// Unlock the mutex
|
||||
(Mutex->*unlock_fn)();
|
||||
}
|
||||
}
|
||||
private:
|
||||
MutexType *Mutex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
using ScopedSignalMaskWithMutex = ScopedSignalMaskWithMutexBase<std::mutex, &std::mutex::lock, &std::mutex::unlock>;
|
||||
using ScopedSignalMaskWithSharedLock = ScopedSignalMaskWithMutexBase<std::shared_mutex, &std::shared_mutex::lock_shared, &std::shared_mutex::unlock_shared>;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "Common/FDUtils.h"
|
||||
#include "FEXCore/Utils/Allocator.h"
|
||||
#include "LinuxSyscalls/Syscalls.h"
|
||||
#include "LinuxSyscalls/UContext.h"
|
||||
#include "VDSO_Emulation.h"
|
||||
#include "Linux/Utils/ELFParser.h"
|
||||
#include "Linux/Utils/ELFSymbolDatabase.h"
|
||||
@@ -18,7 +19,6 @@
|
||||
#include <FEXCore/Core/CodeLoader.h>
|
||||
#include <FEXCore/Core/CoreState.h>
|
||||
#include <FEXCore/Utils/MathUtils.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/fextl/list.h>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "LinuxSyscalls/UContext.h"
|
||||
|
||||
#include <FEXCore/Utils/LogManager.h>
|
||||
#include <FEXCore/Core/CoreState.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
File renamed without changes.
@@ -6,12 +6,12 @@ $end_info$
|
||||
|
||||
#include "LinuxSyscalls/SignalDelegator.h"
|
||||
#include "LinuxSyscalls/Syscalls.h"
|
||||
#include "LinuxSyscalls/UContext.h"
|
||||
#include "LinuxSyscalls/x64/Syscalls.h"
|
||||
#include "LinuxSyscalls/x32/Syscalls.h"
|
||||
#include "LinuxSyscalls/x32/Types.h"
|
||||
|
||||
#include <FEXCore/Core/SignalDelegator.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -6,6 +6,7 @@ $end_info$
|
||||
|
||||
#include "LinuxSyscalls/SignalDelegator.h"
|
||||
#include "LinuxSyscalls/Syscalls.h"
|
||||
#include "LinuxSyscalls/UContext.h"
|
||||
#include "LinuxSyscalls/x32/Syscalls.h"
|
||||
#include "LinuxSyscalls/x32/Thread.h"
|
||||
#include "LinuxSyscalls/x32/Types.h"
|
||||
@@ -13,7 +14,6 @@ $end_info$
|
||||
#include "LinuxSyscalls/x64/Syscalls.h"
|
||||
|
||||
#include <FEXCore/Core/CoreState.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Debug/InternalThreadState.h>
|
||||
#include <FEXCore/HLE/Linux/ThreadManagement.h>
|
||||
#include <FEXCore/fextl/vector.h>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "LinuxSyscalls/SignalDelegator.h"
|
||||
#include "LinuxSyscalls/UContext.h"
|
||||
#include <FEXCore/Config/Config.h>
|
||||
#include <FEXCore/Core/CPUBackend.h>
|
||||
#include <FEXCore/Core/Context.h>
|
||||
#include <FEXCore/Core/CoreState.h>
|
||||
#include <FEXCore/Core/UContext.h>
|
||||
#include <FEXCore/Core/X86Enums.h>
|
||||
#include <FEXCore/Debug/InternalThreadState.h>
|
||||
#include <FEXCore/fextl/list.h>
|
||||
|
||||
Reference in new issue
Block a user