mirror of
https://github.com/matrix-construct/construct
synced 2024-09-26 18:38:52 +02:00
ircd::allocator: Add mlock2(2) interface wrapping.
This commit is contained in:
parent
e9fe4f33bb
commit
8bb8c19cda
2 changed files with 20 additions and 0 deletions
|
@ -53,6 +53,7 @@ namespace ircd::allocator
|
|||
size_t flush(const const_buffer &, const bool invd = false);
|
||||
size_t sync(const const_buffer &, const bool invd = false);
|
||||
|
||||
void lock(const const_buffer &, const bool = true);
|
||||
void protect(const const_buffer &, const bool = true);
|
||||
void readonly(const mutable_buffer &, const bool = true);
|
||||
|
||||
|
|
|
@ -177,6 +177,25 @@ ircd::allocator::protect(const const_buffer &buf,
|
|||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
ircd::allocator::lock(const const_buffer &buf,
|
||||
const bool enable)
|
||||
#if defined(HAVE_MLOCK2) && defined(MLOCK_ONFAULT)
|
||||
{
|
||||
int flags {0};
|
||||
flags |= MLOCK_ONFAULT;
|
||||
|
||||
if(enable)
|
||||
syscall(::mlock2, data(buf), size(buf), flags);
|
||||
else
|
||||
syscall(::munlock, data(buf), size(buf));
|
||||
}
|
||||
#else
|
||||
{
|
||||
#warning "mlock2(2) not available for this compilation."
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t
|
||||
ircd::allocator::sync(const const_buffer &buf,
|
||||
const bool invd)
|
||||
|
|
Loading…
Reference in a new issue