Skip to content
Snippets Groups Projects
Commit 3804e289 authored by Avi Kivity's avatar Avi Kivity
Browse files

libc: real mmap()/munmap() implementation

parent c6f28d05
No related branches found
No related tags found
No related merge requests found
#include <sys/mman.h>
#include <memory>
#include "mmu.hh"
#include "debug.hh"
int mprotect(void *addr, size_t len, int prot)
......@@ -6,3 +8,26 @@ int mprotect(void *addr, size_t len, int prot)
debug("stub mprotect()");
return 0;
}
void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
if (fd != -1) {
abort();
}
std::unique_ptr<mmu::vma> v;
if (!(flags & MAP_FIXED)) {
v.reset(mmu::reserve(addr, length));
addr = v->addr();
}
mmu::map_anon(addr, length, 0);
v.release();
return addr;
}
int munmap(void *addr, size_t length)
{
mmu::unmap(addr, length);
return 0;
}
......@@ -258,22 +258,6 @@ namespace __cxxabiv1 {
}
void *mmap(void *addr, size_t length, int prot, int flags,
int fd, off_t offset)
{
if (fd != -1) {
abort();
}
return malloc(length);
}
int munmap(void *addr, size_t length)
{
return 0;
}
int getpagesize()
{
return 4096;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment