Answers for "centos7 mlock2"

C++
0

centos7 mlock2

#define _GNU_SOURCE
#include <unistd.h>
#include <errno.h>
#include <asm-generic/mman-common.h>
#include <sys/syscall.h>
#include <sys/mman.h>

inline int mlock2(const void* addr, size_t length, unsigned int flags) noexcept
{
    if (flags == 0)
    {
        return mlock(addr, length);
    }
    int ret = syscall(SYS_mlock2, addr, length, flags);
    return (ret == 0 || errno != ENOSYS) ? ret : -1;
}
Posted by: Guest on June-03-2020

Browse Popular Code Answers by Language