diff --git a/include/sys/mman.h b/include/sys/mman.h index 19dd844e7eb4c2dc1e7515795a8adb93becc4b56..80e1da756ff79fbd7e1dc5602b3ee2d00a13424e 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -94,6 +94,13 @@ extern "C" { #define MADV_SOFT_OFFLINE 101 #endif +#ifdef _GNU_SOURCE +#define MREMAP_MAYMOVE 1 +#define MREMAP_FIXED 2 + +#define MLOCK_ONFAULT 0x01 +#endif + #include void *mmap (void *, size_t, int, int, int, off_t); @@ -110,14 +117,12 @@ int mlockall (int); int munlockall (void); #ifdef _GNU_SOURCE -#define MREMAP_MAYMOVE 1 -#define MREMAP_FIXED 2 void *mremap (void *, size_t, size_t, int, ...); int remap_file_pages (void *, size_t, int, size_t, int); +int mlock2 (const void *, size_t, unsigned); #endif #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define MLOCK_ONFAULT 0x01 int madvise (void *, size_t, int); int mincore (void *, size_t, unsigned char *); #endif diff --git a/src/linux/mlock2.c b/src/linux/mlock2.c new file mode 100644 index 0000000000000000000000000000000000000000..10132742d0605f262646d708512476496c212fb8 --- /dev/null +++ b/src/linux/mlock2.c @@ -0,0 +1,10 @@ +#define _GNU_SOURCE 1 +#include +#include "syscall.h" + +int mlock2(const void *addr, size_t len, unsigned flags) +{ + if (flags == 0) + return mlock(addr, len); + return syscall(SYS_mlock2, addr, len, flags); +}