Wrappers for mman operations

This commit is contained in:
Ali Mashtizadeh 2014-10-15 15:19:17 -07:00
parent c39c558da0
commit 1b82af5c11
2 changed files with 37 additions and 0 deletions

View File

@ -1,4 +1,5 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
@ -9,6 +10,8 @@
#error "Unsupported Architecture!"
#endif
#include <syscall.h>
int
getpagesizes(size_t *pagesize, int nelem)
{
@ -31,10 +34,42 @@ getpagesizes(size_t *pagesize, int nelem)
void*
mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
void *realAddr;
if (!(flags & MAP_FIXED)) {
// Find an address
}
if (flags & MAP_ANON) {
realAddr = SystemMemMap(addr, len, prot | flags);
} else {
abort();
}
// XXX: Update mapping
return realAddr;
}
int
munmap(void *addr, size_t len)
{
// XXX: Update mappings
return SystemMemUnmap(addr, len);
}
int
mprotect(void *addr, size_t len, int prot)
{
// XXX: Update mappings
return SystemMemProtect(addr, len, prot);
}
int
madvise(void *addr, size_t len, int behav)
{
return 0;
}

View File

@ -17,6 +17,8 @@
int getpagesizes(size_t *pagesize, int nlem);
void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset);
int munmap(void *addr, size_t len);
int mprotect(void *addr, size_t len, int prot);
int madvise(void *addr, size_t len, int behav);
#endif /* _KERNEL */
#endif /* __SYS_MMAN_H__ */