mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Common/MemArena: Add function for getting page size
This commit is contained in:
@@ -115,6 +115,11 @@ public:
|
||||
///
|
||||
void UnmapFromMemoryRegion(void* view, size_t size);
|
||||
|
||||
///
|
||||
/// Return the system's page size or required page alignment, whichever is larger.
|
||||
///
|
||||
size_t GetPageSize() const;
|
||||
|
||||
private:
|
||||
#ifdef _WIN32
|
||||
WindowsMemoryRegion* EnsureSplitRegionForMapping(void* address, size_t size);
|
||||
|
||||
@@ -144,6 +144,11 @@ void MemArena::UnmapFromMemoryRegion(void* view, size_t size)
|
||||
NOTICE_LOG_FMT(MEMMAP, "mmap failed");
|
||||
}
|
||||
|
||||
size_t MemArena::GetPageSize() const
|
||||
{
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
LazyMemoryRegion::LazyMemoryRegion() = default;
|
||||
|
||||
LazyMemoryRegion::~LazyMemoryRegion()
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "Common/MemArena.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include "Common/Assert.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
|
||||
@@ -163,6 +165,11 @@ void MemArena::UnmapFromMemoryRegion(void* view, size_t size)
|
||||
}
|
||||
}
|
||||
|
||||
size_t MemArena::GetPageSize() const
|
||||
{
|
||||
return getpagesize();
|
||||
}
|
||||
|
||||
LazyMemoryRegion::LazyMemoryRegion() = default;
|
||||
|
||||
LazyMemoryRegion::~LazyMemoryRegion()
|
||||
|
||||
@@ -108,6 +108,11 @@ void MemArena::UnmapFromMemoryRegion(void* view, size_t size)
|
||||
NOTICE_LOG_FMT(MEMMAP, "mmap failed");
|
||||
}
|
||||
|
||||
size_t MemArena::GetPageSize() const
|
||||
{
|
||||
return sysconf(_SC_PAGESIZE);
|
||||
}
|
||||
|
||||
LazyMemoryRegion::LazyMemoryRegion() = default;
|
||||
|
||||
LazyMemoryRegion::~LazyMemoryRegion()
|
||||
|
||||
@@ -438,6 +438,21 @@ void MemArena::UnmapFromMemoryRegion(void* view, size_t size)
|
||||
UnmapViewOfFile(view);
|
||||
}
|
||||
|
||||
size_t MemArena::GetPageSize() const
|
||||
{
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
|
||||
if (!m_memory_functions.m_address_MapViewOfFile3)
|
||||
{
|
||||
// In this case, we can only map pages that are 64K aligned.
|
||||
// See https://devblogs.microsoft.com/oldnewthing/20031008-00/?p=42223
|
||||
return std::max<size_t>(si.dwPageSize, 64 * 1024);
|
||||
}
|
||||
|
||||
return si.dwPageSize;
|
||||
}
|
||||
|
||||
LazyMemoryRegion::LazyMemoryRegion()
|
||||
{
|
||||
InitWindowsMemoryFunctions(&m_memory_functions);
|
||||
|
||||
Reference in New Issue
Block a user