|
Date: Thu, 10 Dec 2015 16:49:44 +0000 From: "Tottenham, Max" <mtottenh@...mai.com> To: "musl@...ts.openwall.com" <musl@...ts.openwall.com> Subject: [PATCH] [PATCH V1] Add mlock2 syscall wrapper The mlock2 syscall has been accepted upstream for kernel v4.4. This patch adds a simple syscall wrapper to libc for x86_64 and i386. -- Max Tottenham --- arch/i386/bits/mman.h | 1 + arch/i386/bits/syscall.h | 2 ++ arch/x86_64/bits/mman.h | 1 + arch/x86_64/bits/syscall.h | 2 ++ include/sys/mman.h | 1 + src/mman/mlock2.c | 7 +++++++ 6 files changed, 14 insertions(+) create mode 100644 src/mman/mlock2.c diff --git a/arch/i386/bits/mman.h b/arch/i386/bits/mman.h index 0f53acb..0c9022f 100644 --- a/arch/i386/bits/mman.h +++ b/arch/i386/bits/mman.h @@ -38,6 +38,7 @@ #define MCL_CURRENT 1 #define MCL_FUTURE 2 +#define MCL_ONFAULT 4 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define MADV_NORMAL 0 diff --git a/arch/i386/bits/syscall.h b/arch/i386/bits/syscall.h index 2902f80..168ccd7 100644 --- a/arch/i386/bits/syscall.h +++ b/arch/i386/bits/syscall.h @@ -357,6 +357,7 @@ #define __NR_memfd_create 356 #define __NR_bpf 357 #define __NR_execveat 358 +#define __NR_mlock2 376 /* Repeated with SYS_ prefix */ @@ -720,3 +721,4 @@ #define SYS_memfd_create 356 #define SYS_bpf 357 #define SYS_execveat 358 +#define SYS_mlock2 376 diff --git a/arch/x86_64/bits/mman.h b/arch/x86_64/bits/mman.h index 846b7ea..f3235f4 100644 --- a/arch/x86_64/bits/mman.h +++ b/arch/x86_64/bits/mman.h @@ -38,6 +38,7 @@ #define MCL_CURRENT 1 #define MCL_FUTURE 2 +#define MCL_ONFAULT 4 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define MADV_NORMAL 0 diff --git a/arch/x86_64/bits/syscall.h b/arch/x86_64/bits/syscall.h index 96ec51f..ae27522 100644 --- a/arch/x86_64/bits/syscall.h +++ b/arch/x86_64/bits/syscall.h @@ -321,6 +321,7 @@ #define __NR_kexec_file_load 320 #define __NR_bpf 321 #define __NR_execveat 322 +#define __NR_mlock2 325 @@ -649,3 +650,4 @@ #define SYS_kexec_file_load 320 #define SYS_bpf 321 #define SYS_execveat 322 +#define SYS_mlock2 325 diff --git a/include/sys/mman.h b/include/sys/mman.h index 9fc2db5..3c767ad 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -27,6 +27,7 @@ int msync (void *, size_t, int); int posix_madvise (void *, size_t, int); int mlock (const void *, size_t); +int mlock2 (const void *, size_t, int); int munlock (const void *, size_t); int mlockall (int); int munlockall (void); diff --git a/src/mman/mlock2.c b/src/mman/mlock2.c new file mode 100644 index 0000000..a317f8a --- /dev/null +++ b/src/mman/mlock2.c @@ -0,0 +1,7 @@ +#include <sys/mman.h> +#include "syscall.h" + +int mlock2(const void *addr, size_t len, int flags) +{ + return syscall(SYS_mlock2, addr, len, flags); +} -- 2.6.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.