summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/mman/mprotect.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/mman/mprotect.c')
-rw-r--r--libc-top-half/musl/src/mman/mprotect.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/mman/mprotect.c b/libc-top-half/musl/src/mman/mprotect.c
new file mode 100644
index 0000000..535787b
--- /dev/null
+++ b/libc-top-half/musl/src/mman/mprotect.c
@@ -0,0 +1,13 @@
+#include <sys/mman.h>
+#include "libc.h"
+#include "syscall.h"
+
+int __mprotect(void *addr, size_t len, int prot)
+{
+ size_t start, end;
+ start = (size_t)addr & -PAGE_SIZE;
+ end = (size_t)((char *)addr + len + PAGE_SIZE-1) & -PAGE_SIZE;
+ return syscall(SYS_mprotect, start, end-start, prot);
+}
+
+weak_alias(__mprotect, mprotect);