diff --git a/Source/Windows/Common/IntervalList.h b/FEXCore/include/FEXCore/Utils/IntervalList.h similarity index 94% rename from Source/Windows/Common/IntervalList.h rename to FEXCore/include/FEXCore/Utils/IntervalList.h index 086e2f297..729e57e58 100644 --- a/Source/Windows/Common/IntervalList.h +++ b/FEXCore/include/FEXCore/Utils/IntervalList.h @@ -6,6 +6,7 @@ #include +namespace FEXCore { template class IntervalList { public: @@ -66,8 +67,8 @@ public: FirstIt->End = End; } - void Insert(const IntervalList &Other) { - for (const auto &Interval : Other.Intervals) { + void Insert(const IntervalList& Other) { + for (const auto& Interval : Other.Intervals) { Insert(Interval); } } @@ -127,7 +128,7 @@ public: Intervals.erase(EraseStartIt, EraseEndIt); } - QueryResult Query(SizeType Offset) { + QueryResult Query(SizeType Offset) const { const auto It = std::upper_bound(Intervals.begin(), Intervals.end(), Offset, [](const auto& LHS, const auto& RHS) { return LHS < RHS.End; }); // Lowest offset interval that (maybe) overlaps with the query offset @@ -141,7 +142,7 @@ public: } } - bool Intersect(Interval Entry) { + bool Intersect(Interval Entry) const { const auto It = std::upper_bound(Intervals.begin(), Intervals.end(), Entry, [](const auto& LHS, const auto& RHS) { return LHS.Offset < RHS.End; }); // Lowest offset interval that (maybe) overlaps with the query offset @@ -149,7 +150,7 @@ public: return It != Intervals.end() && It->Offset < Entry.End; } - bool Contains(Interval Entry) { + bool Contains(Interval Entry) const { const auto It = std::upper_bound(Intervals.begin(), Intervals.end(), Entry, [](const auto& LHS, const auto& RHS) { return LHS.Offset < RHS.End; }); // Lowest offset interval that (maybe) overlaps with the query offset @@ -157,3 +158,5 @@ public: return It != Intervals.end() && It->Offset <= Entry.Offset && It->End >= Entry.End; } }; + +} // namespace FEXCore diff --git a/Source/Windows/Common/InvalidationTracker.h b/Source/Windows/Common/InvalidationTracker.h index 771b352e4..75d89c7a6 100644 --- a/Source/Windows/Common/InvalidationTracker.h +++ b/Source/Windows/Common/InvalidationTracker.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT #pragma once -#include "IntervalList.h" +#include #include #include @@ -28,7 +28,7 @@ public: bool HandleRWXAccessViolation(uint64_t FaultAddress); private: - IntervalList RWXIntervals; + FEXCore::IntervalList RWXIntervals; std::mutex RWXIntervalsLock; FEXCore::Context::Context& CTX; const std::unordered_map& Threads; diff --git a/Source/Windows/Common/OvercommitTracker.h b/Source/Windows/Common/OvercommitTracker.h index 797c4c748..ba521e8a8 100644 --- a/Source/Windows/Common/OvercommitTracker.h +++ b/Source/Windows/Common/OvercommitTracker.h @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT #pragma once -#include "IntervalList.h" +#include #include #include @@ -13,7 +13,7 @@ namespace FEX::Windows { class OvercommitTracker { private: bool IsWine; - IntervalList OvercommitIntervals; + FEXCore::IntervalList OvercommitIntervals; std::shared_mutex OvercommitIntervalsMutex; public: