summaryrefslogtreecommitdiff
path: root/src/mman/mprotect.c
blob: f488486db6e2d8fe4f7f3b200a0af81a6396451b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
#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);
}