2023-09-22 15:41:05 +03:00
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <sys/syscall.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
void* mmap(void* addr, size_t len, int prot, int flags, int fildes, off_t off)
|
|
|
|
{
|
|
|
|
sys_mmap_t args {
|
|
|
|
.addr = addr,
|
|
|
|
.len = len,
|
|
|
|
.prot = prot,
|
|
|
|
.flags = flags,
|
|
|
|
.off = off
|
|
|
|
};
|
|
|
|
long ret = syscall(SYS_MMAP, &args);
|
|
|
|
if (ret == -1)
|
2023-09-29 10:38:08 +03:00
|
|
|
return MAP_FAILED;
|
2023-09-22 15:41:05 +03:00
|
|
|
return (void*)ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
int munmap(void* addr, size_t len)
|
|
|
|
{
|
|
|
|
return syscall(SYS_MUNMAP, addr, len);
|
|
|
|
}
|