General: Fix compilation for GCC

This commit is contained in:
Liam White
2022-04-13 21:02:55 +02:00
committed by Fernando Sahmkow
parent fd7afda1e8
commit afab6c143c
16 changed files with 56 additions and 42 deletions

View File

@ -22,7 +22,8 @@ struct EmptyStruct {};
*/
template <typename VaType, VaType UnmappedVa, typename PaType, PaType UnmappedPa,
bool PaContigSplit, size_t AddressSpaceBits, typename ExtraBlockInfo = EmptyStruct>
requires AddressSpaceValid<VaType, AddressSpaceBits> class FlatAddressSpaceMap {
requires AddressSpaceValid<VaType, AddressSpaceBits>
class FlatAddressSpaceMap {
private:
std::function<void(VaType, VaType)>
unmapCallback{}; //!< Callback called when the mappings in an region have changed
@ -40,8 +41,8 @@ protected:
Block() = default;
Block(VaType virt, PaType phys, ExtraBlockInfo extraInfo)
: virt(virt), phys(phys), extraInfo(extraInfo) {}
Block(VaType virt_, PaType phys_, ExtraBlockInfo extraInfo_)
: virt(virt_), phys(phys_), extraInfo(extraInfo_) {}
constexpr bool Valid() {
return virt != UnmappedVa;
@ -102,7 +103,8 @@ public:
* initial, fast linear pass and a subsequent slower pass that iterates until it finds a free block
*/
template <typename VaType, VaType UnmappedVa, size_t AddressSpaceBits>
requires AddressSpaceValid<VaType, AddressSpaceBits> class FlatAllocator
requires AddressSpaceValid<VaType, AddressSpaceBits>
class FlatAllocator
: public FlatAddressSpaceMap<VaType, UnmappedVa, bool, false, false, AddressSpaceBits> {
private:
using Base = FlatAddressSpaceMap<VaType, UnmappedVa, bool, false, false, AddressSpaceBits>;

View File

@ -27,7 +27,7 @@ template <class ForwardIt, class T, class Compare = std::less<>>
template <typename T, typename Func, typename... Args>
T FoldRight(T initial_value, Func&& func, Args&&... args) {
T value{initial_value};
const auto high_func = [&value, &func]<typename T>(T x) { value = func(value, x); };
const auto high_func = [&value, &func]<typename U>(U x) { value = func(value, x); };
(std::invoke(high_func, std::forward<Args>(args)), ...);
return value;
}

View File

@ -127,14 +127,11 @@ public:
}
}
BitField(T val) {
Assign(val);
}
BitField& operator=(T val) {
Assign(val);
return *this;
}
// This constructor and assignment operator might be considered ambiguous:
// Would they initialize the storage or just the bitfield?
// Hence, delete them. Use the Assign method to set bitfield values!
BitField(T val) = delete;
BitField& operator=(T val) = delete;
constexpr BitField() noexcept = default;

View File

@ -1,8 +1,6 @@
#include "common/multi_level_page_table.inc"
namespace Common {
template class Common::MultiLevelPageTable<GPUVAddr>;
template class Common::MultiLevelPageTable<VAddr>;
template class Common::MultiLevelPageTable<PAddr>;
template class Common::MultiLevelPageTable<u64>;
template class Common::MultiLevelPageTable<u32>;
} // namespace Common

View File

@ -30,7 +30,7 @@ MultiLevelPageTable<BaseAddr>::MultiLevelPageTable(std::size_t address_space_bit
#ifdef _WIN32
void* base{VirtualAlloc(nullptr, alloc_size, MEM_RESERVE, PAGE_READWRITE)};
#else
void* base{mmap(nullptr, alloc_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)};
void* base{mmap(nullptr, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)};
if (base == MAP_FAILED) {
base = nullptr;