diff --git a/External/FEXCore/Source/Common/BitSet.h b/External/FEXCore/Source/Common/BitSet.h index 24e14b821..f95530c9e 100644 --- a/External/FEXCore/Source/Common/BitSet.h +++ b/External/FEXCore/Source/Common/BitSet.h @@ -1,5 +1,6 @@ #pragma once #include "Common/MathUtils.h" +#include #include #include @@ -17,15 +18,15 @@ struct BitSet final { void Allocate(size_t Elements) { size_t AllocateSize = AlignUp(Elements, MinimumSizeBits) / MinimumSize; LOGMAN_THROW_A((AllocateSize * MinimumSize) >= Elements, "Fail"); - Memory = static_cast(malloc(AllocateSize)); + Memory = static_cast(FEXCore::Allocator::malloc(AllocateSize)); } void Realloc(size_t Elements) { size_t AllocateSize = AlignUp(Elements, MinimumSizeBits) / MinimumSize; LOGMAN_THROW_A((AllocateSize * MinimumSize) >= Elements, "Fail"); - Memory = static_cast(realloc(Memory, AllocateSize)); + Memory = static_cast(FEXCore::Allocator::realloc(Memory, AllocateSize)); } void Free() { - free(Memory); + FEXCore::Allocator::free(Memory); Memory = nullptr; } bool Get(T Element) { diff --git a/External/FEXCore/Source/Interface/Core/Core.cpp b/External/FEXCore/Source/Interface/Core/Core.cpp index 03343362c..4c3b4eb17 100644 --- a/External/FEXCore/Source/Interface/Core/Core.cpp +++ b/External/FEXCore/Source/Interface/Core/Core.cpp @@ -28,6 +28,7 @@ $end_info$ #include #include #include +#include #include "Interface/HLE/Thunks/Thunks.h" #include "FEXCore/Utils/Allocator.h" @@ -180,7 +181,7 @@ namespace FEXCore::Context { for (auto &Mod: AOTIRCaptureCache) { for (auto &Entry: Mod.second) { delete Entry.second.IR; - free(Entry.second.RAData); + FEXCore::Allocator::free(Entry.second.RAData); } } @@ -436,7 +437,7 @@ namespace FEXCore::Context { static void *ThreadHandler(void* Data) { ExecutionThreadHandler *Handler = reinterpret_cast(Data); Handler->This->ExecutionThread(Handler->Thread); - free(Handler); + FEXCore::Allocator::free(Handler); return nullptr; } @@ -444,7 +445,7 @@ namespace FEXCore::Context { InitializeThreadData(Thread); // This will create the execution thread but it won't actually start executing - ExecutionThreadHandler *Arg = reinterpret_cast(malloc(sizeof(ExecutionThreadHandler))); + ExecutionThreadHandler *Arg = reinterpret_cast(FEXCore::Allocator::malloc(sizeof(ExecutionThreadHandler))); Arg->This = this; Arg->Thread = Thread; Thread->ExecutionThread = FEXCore::Threads::Thread::Create(ThreadHandler, Arg); diff --git a/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp b/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp index 8984a8f23..c7381bd20 100644 --- a/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp +++ b/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp @@ -8,6 +8,7 @@ $end_info$ #include "Interface/IR/Passes/RegisterAllocationPass.h" #include "Interface/IR/Passes.h" #include "Interface/Core/OpcodeDispatcher.h" +#include #include #include @@ -262,7 +263,7 @@ namespace { Graph->Nodes.resize(NodeCount); Graph->VisitedNodePredecessors.clear(); Graph->AllocData.reset(); - Graph->AllocData.reset((FEXCore::IR::RegisterAllocationData*)malloc(FEXCore::IR::RegisterAllocationData::Size(NodeCount))); + Graph->AllocData.reset((FEXCore::IR::RegisterAllocationData*)FEXCore::Allocator::malloc(FEXCore::IR::RegisterAllocationData::Size(NodeCount))); memset(&Graph->AllocData->Map[0], INVALID_REGCLASS.Raw, NodeCount); Graph->AllocData->MapCount = NodeCount; Graph->AllocData->IsShared = false; // not shared by default diff --git a/External/FEXCore/include/FEXCore/IR/IntrusiveIRList.h b/External/FEXCore/include/FEXCore/IR/IntrusiveIRList.h index 3b7da1409..6468d8ed8 100644 --- a/External/FEXCore/include/FEXCore/IR/IntrusiveIRList.h +++ b/External/FEXCore/include/FEXCore/IR/IntrusiveIRList.h @@ -1,6 +1,7 @@ #pragma once #include "FEXCore/IR/IR.h" +#include #include #include @@ -25,12 +26,13 @@ class DualIntrusiveAllocator final { DualIntrusiveAllocator(DualIntrusiveAllocator &&) = delete; DualIntrusiveAllocator(size_t Size) : MemorySize {Size} { - Data = reinterpret_cast(malloc(Size * 2)); + Data = reinterpret_cast(FEXCore::Allocator::malloc(Size * 2)); List = reinterpret_cast(Data + Size); } + ~DualIntrusiveAllocator() { - free(reinterpret_cast(Data)); + FEXCore::Allocator::free(reinterpret_cast(Data)); } bool DataCheckSize(size_t Size) { diff --git a/External/FEXCore/include/FEXCore/IR/RegisterAllocationData.h b/External/FEXCore/include/FEXCore/IR/RegisterAllocationData.h index d448798d9..b43e02000 100644 --- a/External/FEXCore/include/FEXCore/IR/RegisterAllocationData.h +++ b/External/FEXCore/include/FEXCore/IR/RegisterAllocationData.h @@ -1,5 +1,6 @@ #pragma once #include "IR.h" +#include namespace FEXCore::IR { @@ -47,9 +48,9 @@ class RegisterAllocationData { struct RegisterAllocationDataDeleter { void operator()(RegisterAllocationData* r) { if (!r->IsShared) { - free(r); + FEXCore::Allocator::free(r); } } }; -} +} diff --git a/Source/Tests/LinuxSyscalls/SignalDelegator.cpp b/Source/Tests/LinuxSyscalls/SignalDelegator.cpp index c36e864d5..cc9846bd8 100644 --- a/Source/Tests/LinuxSyscalls/SignalDelegator.cpp +++ b/Source/Tests/LinuxSyscalls/SignalDelegator.cpp @@ -10,6 +10,7 @@ $end_info$ #include "Tests/LinuxSyscalls/SignalDelegator.h" #include +#include #include #include @@ -341,7 +342,7 @@ namespace FEX::HLE { // Set up our signal alternative stack // This is per thread rather than per signal - ThreadData.AltStackPtr = malloc(SIGSTKSZ); + ThreadData.AltStackPtr = FEXCore::Allocator::malloc(SIGSTKSZ); stack_t altstack{}; altstack.ss_sp = ThreadData.AltStackPtr; altstack.ss_size = SIGSTKSZ;