blob: 32eeb2a7c8c6b66c4d2c1474426f5f69ae3e1ff9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
/* mmap() emulation */
#include <camellia/syscalls.h>
#include <errno.h>
#include <sys/mman.h>
void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off) {
(void)fd; (void) off;
if ((flags & MMAP_UNSUPPORTED) == MMAP_UNSUPPORTED ||
(prot & MMAP_UNSUPPORTED) == MMAP_UNSUPPORTED ||
!(flags & MAP_ANONYMOUS))
{
errno = ENOSYS;
return NULL;
}
void *p = _sys_memflag(addr, len, MEMFLAG_FINDFREE | MEMFLAG_PRESENT);
if (!p) errno = ENOMEM;
return p;
}
int munmap(void *addr, size_t len) {
_sys_memflag(addr, len, 0);
return 0;
}
|