Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill little useless things in mmalloc. Still searching how to do the Big Cleanup...
[simgrid.git] / src / xbt / mmalloc / mmap-sup.c
index ad2692c..964e484 100644 (file)
 #include <fcntl.h>
 #include <sys/mman.h>
 
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
 #include "mmprivate.h"
 #include "xbt/ex.h"
 
    it out. */
 
 static size_t pagesize;
-#if NEED_DECLARATION_GETPAGESIZE
-extern int getpagesize(void);
-#endif
 
 #define PAGE_ALIGN(addr) (void*) (((long)(addr) + pagesize - 1) & \
                                    ~(pagesize - 1))
 
 /* Return MAP_PRIVATE if MDP represents /dev/zero.  Otherwise, return
    MAP_SHARED.  */
-
 #define MAP_PRIVATE_OR_SHARED(MDP) (( MDP -> flags & MMALLOC_ANONYMOUS) \
                                     ? MAP_PRIVATE \
                                     : MAP_SHARED)
 
 /* Return MAP_ANONYMOUS if MDP uses anonymous mapping. Otherwise, return 0 */
-
 #define MAP_IS_ANONYMOUS(MDP) (((MDP) -> flags & MMALLOC_ANONYMOUS) \
                               ? MAP_ANONYMOUS \
                               : 0)
@@ -109,9 +100,11 @@ void *__mmalloc_mmap_morecore(struct mdesc *mdp, int size)
       foffset = (char *) mdp->top - (char *) mdp->base;
 
       if (mdp->fd > 0) {
-        /* FIXME:  Test results of lseek() and write() */
+        /* FIXME:  Test results of lseek() */
         lseek(mdp->fd, foffset + mapbytes - 1, SEEK_SET);
         test = write(mdp->fd, &buf, 1);
+        if (test == -1)
+          THROWF(system_error, 0, "write to mmap'ed fd failed! error: %s", strerror(errno));
       }
 
       /* Let's call mmap. Note that it is possible that mdp->top