Implement utils::memory_lock
This commit is contained in:
@@ -39,6 +39,9 @@ namespace utils
|
|||||||
// Set memory protection
|
// Set memory protection
|
||||||
void memory_protect(void* pointer, std::size_t size, protection prot);
|
void memory_protect(void* pointer, std::size_t size, protection prot);
|
||||||
|
|
||||||
|
// Lock pages in memory
|
||||||
|
void memory_lock(void* pointer, std::size_t size);
|
||||||
|
|
||||||
// Shared memory handle
|
// Shared memory handle
|
||||||
class shm
|
class shm
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -180,6 +180,15 @@ namespace utils
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void memory_lock(void* pointer, std::size_t size)
|
||||||
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
verify("VirtualLock" HERE), ::VirtualLock(pointer, size);
|
||||||
|
#else
|
||||||
|
verify("mlock" HERE), !::mlock(pointer, size);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
shm::shm(u32 size, u32 flags)
|
shm::shm(u32 size, u32 flags)
|
||||||
: m_size(::align(size, 0x10000))
|
: m_size(::align(size, 0x10000))
|
||||||
, m_flags(flags)
|
, m_flags(flags)
|
||||||
|
|||||||
Reference in New Issue
Block a user