* [PATCH] [PATCH V1] Add mlock2 syscall wrapper
@ 2015-12-10 16:49 Tottenham, Max
2015-12-10 17:02 ` Szabolcs Nagy
0 siblings, 1 reply; 2+ messages in thread
From: Tottenham, Max @ 2015-12-10 16:49 UTC (permalink / raw)
To: musl
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [PATCH V1] Add mlock2 syscall wrapper
2015-12-10 16:49 [PATCH] [PATCH V1] Add mlock2 syscall wrapper Tottenham, Max
@ 2015-12-10 17:02 ` Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2015-12-10 17:02 UTC (permalink / raw)
To: musl
* Tottenham, Max <mtottenh@akamai.com> [2015-12-10 16:49:44 +0000]:
> 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.
>
v4.4 is not yet tagged and i've seen new syscalls reverted
before release previously because of fundamental design flaws,
so i think we should wait until v4.4 is out.
on that note, some v4.0, v4.1, v4.2 and v4.3 patches are still
pending:
http://port70.net/~nsz/musl/linux41/
http://port70.net/~nsz/musl/linux42/
http://port70.net/~nsz/musl/linux43/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-10 17:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-10 16:49 [PATCH] [PATCH V1] Add mlock2 syscall wrapper Tottenham, Max
2015-12-10 17:02 ` Szabolcs Nagy
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).