#include <sys/mman.h>
#include "mmprivate.h"
-#include "xbt/ex.h"
/* Cache the pagesize for the current host machine. Note that if the host
does not readily provide a getpagesize() function, we need to emulate it
MAP_PRIVATE_OR_SHARED(mdp) | MAP_IS_ANONYMOUS(mdp) |
MAP_FIXED, MAP_ANON_OR_FD(mdp), foffset);
- if (mapto != (void *) -1/* That's MAP_FAILED */) {
+ if (mapto == (void *) -1/* That's MAP_FAILED */)
+ THROWF(system_error,0,"mmap returned MAP_FAILED! error: %s",strerror(errno));
- if (mdp->top == 0)
- mdp->base = mdp->breakval = mapto;
+ if (mdp->top == 0)
+ mdp->base = mdp->breakval = mapto;
- mdp->top = PAGE_ALIGN((char *) mdp->breakval + size);
- result = (void *) mdp->breakval;
- mdp->breakval = (char *) mdp->breakval + size;
- } else {
- THROWF(system_error,0,"mmap returned MAP_FAILED! error: %s",strerror(errno));
- }
+ mdp->top = PAGE_ALIGN((char *) mdp->breakval + size);
+ result = (void *) mdp->breakval;
+ mdp->breakval = (char *) mdp->breakval + size;
} else {
result = (void *) mdp->breakval;
mdp->breakval = (char *) mdp->breakval + size;
return (result);
}
-void *__mmalloc_remap_core(struct mdesc *mdp)
+void *__mmalloc_remap_core(xbt_mheap_t mdp)
{
- void *base;
-
/* FIXME: Quick hack, needs error checking and other attention. */
- base = mmap(mdp->base, (char *) mdp->top - (char *) mdp->base,
+ return mmap(mdp->base, (char*) mdp->top - (char*) mdp->base,
PROT_READ | PROT_WRITE | PROT_EXEC,
MAP_PRIVATE_OR_SHARED(mdp) | MAP_FIXED, mdp->fd, 0);
- return ((void *) base);
}