0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-16 08:58:20 +02:00

configure: Check for mprotect(2).

This commit is contained in:
Jason Volk 2022-02-21 11:03:21 -08:00
parent d029de6a7a
commit e9fe4f33bb
2 changed files with 13 additions and 0 deletions

View file

@ -1188,6 +1188,7 @@ AC_CHECK_FUNCS([ \
mlock \ mlock \
mlock2 \ mlock2 \
mmap \ mmap \
mprotect \
msync \ msync \
posix_fadvise \ posix_fadvise \
posix_madvise \ posix_madvise \

View file

@ -138,6 +138,7 @@ catch(const std::exception &e)
void void
ircd::allocator::readonly(const mutable_buffer &buf, ircd::allocator::readonly(const mutable_buffer &buf,
const bool enable) const bool enable)
#if defined(HAVE_MPROTECT)
{ {
const int prot const int prot
{ {
@ -149,7 +150,13 @@ ircd::allocator::readonly(const mutable_buffer &buf,
void *const ptr(mutable_cast(data(buf))); void *const ptr(mutable_cast(data(buf)));
sys::call(::mprotect, ptr, size(buf), prot); sys::call(::mprotect, ptr, size(buf), prot);
} }
#else
{
#warning "mprotect(2) not available for this compilation."
}
#endif
#if defined(HAVE_MPROTECT)
void void
ircd::allocator::protect(const const_buffer &buf, ircd::allocator::protect(const const_buffer &buf,
const bool enable) const bool enable)
@ -164,6 +171,11 @@ ircd::allocator::protect(const const_buffer &buf,
void *const ptr(mutable_cast(data(buf))); void *const ptr(mutable_cast(data(buf)));
sys::call(::mprotect, ptr, size(buf), prot); sys::call(::mprotect, ptr, size(buf), prot);
} }
#else
{
#warning "mprotect(2) not available for this compilation."
}
#endif
size_t size_t
ircd::allocator::sync(const const_buffer &buf, ircd::allocator::sync(const const_buffer &buf,