From 4abab5ad6c8465a7528ccdd5f49367da05f78bbd Mon Sep 17 00:00:00 2001 From: Vladimir Azarov Date: Tue, 1 Oct 2024 15:47:05 +0200 Subject: Initial version --- src/mman/mprotect.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/mman/mprotect.c (limited to 'src/mman/mprotect.c') diff --git a/src/mman/mprotect.c b/src/mman/mprotect.c new file mode 100644 index 0000000..535787b --- /dev/null +++ b/src/mman/mprotect.c @@ -0,0 +1,13 @@ +#include +#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); -- cgit v1.2.3