Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Now supernovae mode works out of project directory.
[simgrid.git] / src / xbt / mmalloc / mmap-sup.c
index 81af351..4388ff9 100644 (file)
@@ -9,7 +9,9 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#if defined(HAVE_MMAP)
+#ifndef MAP_ANONYMOUS
+       #define MAP_ANONYMOUS MAP_ANON
+#endif
 
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>    /* Prototypes for lseek */
@@ -40,7 +42,7 @@ extern int getpagesize (void);
 /* Return MAP_PRIVATE if MDP represents /dev/zero.  Otherwise, return
    MAP_SHARED.  */
 
-#define MAP_PRIVATE_OR_SHARED(MDP) ((MDP -> flags & MMALLOC_DEVZERO) \
+#define MAP_PRIVATE_OR_SHARED(MDP) (( MDP -> flags & MMALLOC_ANONYMOUS) \
                                     ? MAP_PRIVATE \
                                     : MAP_SHARED)
 
@@ -62,6 +64,7 @@ extern int getpagesize (void);
 void*
 __mmalloc_mmap_morecore (struct mdesc *mdp, int size)
 {
+  ssize_t test = 0;
   void* result = NULL;
   off_t foffset;       /* File offset at which new mapping will start */
   size_t mapbytes;     /* Number of bytes to map */
@@ -114,7 +117,7 @@ __mmalloc_mmap_morecore (struct mdesc *mdp, int size)
       if( mdp -> fd > 0){
          /* FIXME:  Test results of lseek() and write() */
         lseek (mdp -> fd, foffset + mapbytes - 1, SEEK_SET);
-             write (mdp -> fd, &buf, 1);
+        test = write (mdp -> fd, &buf, 1);
       }
            
            /* Let's call mmap. Note that it is possible that mdp->top
@@ -192,7 +195,7 @@ mmalloc_findbase (int size)
         to signal an error return, and besides, it is useful to
         catch NULL pointers if it is unmapped.  Instead start
         at the next page boundary. */
-      base = (void*) getpagesize ();
+      base = (void*)(long) getpagesize ();
     }
   else if (base == (void*) -1)
     {
@@ -200,4 +203,3 @@ mmalloc_findbase (int size)
     }
   return ((void*) base);
 }
-#endif /* defined(HAVE_MMAP) */