Wrappers for mman operations
This commit is contained in:
parent
c39c558da0
commit
1b82af5c11
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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__ */
|
||||
|
Loading…
Reference in New Issue
Block a user