mirror of
https://github.com/matrix-construct/construct
synced 2024-12-25 15:04:10 +01:00
ircd::allocator: Add msync(2) wrapping.
This commit is contained in:
parent
13052f7090
commit
73cd22c7d0
3 changed files with 43 additions and 0 deletions
|
@ -1188,6 +1188,7 @@ AC_CHECK_FUNCS([ \
|
|||
mlock \
|
||||
mlock2 \
|
||||
mmap \
|
||||
msync \
|
||||
posix_fadvise \
|
||||
posix_madvise \
|
||||
preadv2 \
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace ircd::allocator
|
|||
size_t advise(const const_buffer &, const int &);
|
||||
size_t prefetch(const const_buffer &);
|
||||
size_t evict(const const_buffer &);
|
||||
size_t flush(const const_buffer &, const bool invd = false);
|
||||
size_t sync(const const_buffer &, const bool invd = false);
|
||||
|
||||
void protect(const const_buffer &, const bool = true);
|
||||
void readonly(const mutable_buffer &, const bool = true);
|
||||
|
|
|
@ -165,6 +165,46 @@ ircd::allocator::protect(const const_buffer &buf,
|
|||
sys::call(::mprotect, ptr, size(buf), prot);
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::allocator::sync(const const_buffer &buf,
|
||||
const bool invd)
|
||||
{
|
||||
assert(aligned(data(buf), info::page_size));
|
||||
const prof::syscall_usage_warning message
|
||||
{
|
||||
"msync(2) MS_SYNC MS_INVALIDATE:%b", invd
|
||||
};
|
||||
|
||||
#if defined(HAVE_MSYNC)
|
||||
int flags {MS_SYNC};
|
||||
flags |= invd? MS_INVALIDATE: 0;
|
||||
sys::call(::msync, mutable_cast(data(buf)), size(buf), flags);
|
||||
return size(buf);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::allocator::flush(const const_buffer &buf,
|
||||
const bool invd)
|
||||
{
|
||||
assert(aligned(data(buf), info::page_size));
|
||||
const prof::syscall_usage_warning message
|
||||
{
|
||||
"msync(2) MS_ASYNC MS_INVALIDATE:%b", invd
|
||||
};
|
||||
|
||||
#if defined(HAVE_MSYNC)
|
||||
int flags {MS_ASYNC};
|
||||
flags |= invd? MS_INVALIDATE: 0;
|
||||
sys::call(::msync, mutable_cast(data(buf)), size(buf), flags);
|
||||
return size(buf);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::allocator::evict(const const_buffer &buf)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue