-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMemoryLock.cpp
31 lines (24 loc) · 876 Bytes
/
MemoryLock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*******************************************************************************
* libunix++: C++ wrapper for Linux system calls
* Memory locking operations
*
* © 2019—2021, Sauron <[email protected]>
******************************************************************************/
#include "exception.hppi"
#include "MemoryLock.hpp"
using namespace upp;
MemoryLock::MemoryLock(void * addr, size_t length) : MemoryRegion(addr, length) {
NORMAL_OP_WRAPPER(mlock(addr, length));
}
MemoryLock::MemoryLock(void * addr, size_t length, int flags) : MemoryRegion(addr, length) {
NORMAL_OP_WRAPPER(mlock2(addr, length, flags));
}
MemoryLock::~MemoryLock() {
munlock(getAddress(), getLength());
}
void MemoryLock::lockAll(int flags) {
NORMAL_OP_WRAPPER(mlockall(flags));
}
void MemoryLock::unlockAll() {
NORMAL_OP_WRAPPER(munlockall());
}