aboutsummaryrefslogtreecommitdiff
path: root/sys/src/mprotect.c
diff options
context:
space:
mode:
authorNicholas Noll <nbnoll@eml.cc>2021-11-18 13:18:38 -0800
committerNicholas Noll <nbnoll@eml.cc>2021-11-18 13:18:38 -0800
commit4bf477d5ed372fd44697d2f0df245b61b4f3f7b3 (patch)
treee52d8aa00de40b33c4f26cacba6841f299f97bb2 /sys/src/mprotect.c
parent8306b655f9d9a291126ed4947c481ea540c9b835 (diff)
filling out system layer
Diffstat (limited to 'sys/src/mprotect.c')
-rw-r--r--sys/src/mprotect.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/src/mprotect.c b/sys/src/mprotect.c
new file mode 100644
index 0000000..6d20dc1
--- /dev/null
+++ b/sys/src/mprotect.c
@@ -0,0 +1,14 @@
+#include "internal.h"
+
+int
+sys·mprotect(void *addr, uintptr len, int prot)
+{
+ long ret;
+ uintptr beg, end;
+
+ beg = (uintptr)addr & -PAGESIZE;
+ end = (uintptr)(addr + len + PAGESIZE-1) & -PAGESIZE;
+
+ ret = syscall(·MProtect, beg, end-beg, prot);
+ return error(ret);
+}