From e9fe4f33bb04ca5c050d04ea4ba24e3b9deb7a53 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 21 Feb 2022 11:03:21 -0800 Subject: [PATCH] configure: Check for mprotect(2). --- configure.ac | 1 + ircd/allocator.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/configure.ac b/configure.ac index 4a29b2195..8be2d6dac 100644 --- a/configure.ac +++ b/configure.ac @@ -1188,6 +1188,7 @@ AC_CHECK_FUNCS([ \ mlock \ mlock2 \ mmap \ + mprotect \ msync \ posix_fadvise \ posix_madvise \ diff --git a/ircd/allocator.cc b/ircd/allocator.cc index 16f8983b0..e43bbdd16 100644 --- a/ircd/allocator.cc +++ b/ircd/allocator.cc @@ -138,6 +138,7 @@ catch(const std::exception &e) void ircd::allocator::readonly(const mutable_buffer &buf, const bool enable) +#if defined(HAVE_MPROTECT) { const int prot { @@ -149,7 +150,13 @@ ircd::allocator::readonly(const mutable_buffer &buf, void *const ptr(mutable_cast(data(buf))); sys::call(::mprotect, ptr, size(buf), prot); } +#else +{ + #warning "mprotect(2) not available for this compilation." +} +#endif +#if defined(HAVE_MPROTECT) void ircd::allocator::protect(const const_buffer &buf, const bool enable) @@ -164,6 +171,11 @@ ircd::allocator::protect(const const_buffer &buf, void *const ptr(mutable_cast(data(buf))); sys::call(::mprotect, ptr, size(buf), prot); } +#else +{ + #warning "mprotect(2) not available for this compilation." +} +#endif size_t ircd::allocator::sync(const const_buffer &buf,