/* Support for an sbrk-like function that uses mmap.
Copyright 1992, 2000 Free Software Foundation, Inc.
- Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com
+ Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com */
-This file is part of the GNU C Library.
+/* Copyright (c) 2010. The SimGrid Team.
+ * All rights reserved. */
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+/* 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. */
-The GNU C Library is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA. */
-
-#if defined(HAVE_MMAP)
+#ifndef MAP_ANONYMOUS
+ #define MAP_ANONYMOUS MAP_ANON
+#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h> /* Prototypes for lseek */
/* 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)
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 */
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
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)
{
}
return ((void*) base);
}
-#endif /* defined(HAVE_MMAP) */