git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@7695
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
+#include <unistd.h> /* close */
#include <sys/types.h>
#include "mmprivate.h"
#include <sys/types.h>
#include "mmprivate.h"
/* Now unmap all the pages associated with this region by asking for a
negative increment equal to the current size of the region. */
/* Now unmap all the pages associated with this region by asking for a
negative increment equal to the current size of the region. */
- if ((mtemp.morecore (&mtemp, mtemp.base - mtemp.breakval)) == NULL)
+ if ((mtemp.morecore (&mtemp, (char*)mtemp.base - (char*)mtemp.breakval)) == NULL)
{
/* Deallocating failed. Update the original malloc descriptor
with any changes */
{
/* Deallocating failed. Update the original malloc descriptor
with any changes */
+ size_t block;//, blocks; unused variable?
register size_t i;
struct list *prev, *next;
register size_t i;
struct list *prev, *next;
/* Get the address of the first free fragment in this block. */
prev = (struct list *)
/* Get the address of the first free fragment in this block. */
prev = (struct list *)
- ((PTR) ADDRESS(block) +
- (mdp -> heapinfo[block].busy.info.frag.first << type));
+ ((char*) ADDRESS(block) +
+ ( mdp -> heapinfo[block].busy.info.frag.first << type));
if (mdp -> heapinfo[block].busy.info.frag.nfree ==
(BLOCKSIZE >> type) - 1)
if (mdp -> heapinfo[block].busy.info.frag.nfree ==
(BLOCKSIZE >> type) - 1)
+
+/* Useless prototype to make gcc happy */
+void free(void* ptr);
+
+
/* When using this package, provide a version of malloc/realloc/free built
on top of it, so that if we use the default sbrk() region we will not
collide with another malloc package trying to do the same thing, if
/* When using this package, provide a version of malloc/realloc/free built
on top of it, so that if we use the default sbrk() region we will not
collide with another malloc package trying to do the same thing, if
as inside a system library). */
void
as inside a system library). */
void
{
mfree ((PTR) NULL, ptr);
}
{
mfree ((PTR) NULL, ptr);
}
{
adj = BLOCKSIZE - adj;
mdp -> morecore (mdp, adj);
{
adj = BLOCKSIZE - adj;
mdp -> morecore (mdp, adj);
- result = (PTR) result + adj;
+ result = (char*) result + adj;
}
/* Check if we need to grow the info table. */
}
/* Check if we need to grow the info table. */
- if ((size_t) BLOCK ((PTR) result + size) > mdp -> heapsize)
+ if ((size_t) BLOCK ((char*) result + size) > mdp -> heapsize)
{
newsize = mdp -> heapsize;
{
newsize = mdp -> heapsize;
- while ((size_t) BLOCK ((PTR) result + size) > newsize)
+ while ((size_t) BLOCK ((char*) result + size) > newsize)
mdp -> heapsize = newsize;
}
mdp -> heapsize = newsize;
}
- mdp -> heaplimit = BLOCK ((PTR) result + size);
+ mdp -> heaplimit = BLOCK ((char*) result + size);
/* Link all fragments but the first into the free list. */
for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i)
{
/* Link all fragments but the first into the free list. */
for (i = 1; i < (size_t) (BLOCKSIZE >> log); ++i)
{
- next = (struct list *) ((PTR) result + (i << log));
+ next = (struct list *) ((char*) result + (i << log));
next -> next = mdp -> fraghead[log].next;
next -> prev = &mdp -> fraghead[log];
next -> prev -> next = next;
next -> next = mdp -> fraghead[log].next;
next -> prev = &mdp -> fraghead[log];
next -> prev -> next = next;
#else /* defined(HAVE_MMAP) */
/* Prevent "empty translation unit" warnings from the idiots at X3J11. */
#else /* defined(HAVE_MMAP) */
/* Prevent "empty translation unit" warnings from the idiots at X3J11. */
-static char ansi_c_idiots = 69;
+//static char ansi_c_idiots = 69;
#endif /* defined(HAVE_MMAP) */
#endif /* defined(HAVE_MMAP) */
mdp -> aligned_blocks = l;
}
l -> exact = result;
mdp -> aligned_blocks = l;
}
l -> exact = result;
- result = l -> aligned = (PTR) result + alignment - adj;
+ result = l -> aligned = (char*) result + alignment - adj;
sign of the result is machine dependent for negative values, so force
it to be treated as an unsigned int. */
sign of the result is machine dependent for negative values, so force
it to be treated as an unsigned int. */
-#define ADDR2UINT(addr) ((unsigned int) ((PTR) (addr) - (PTR) NULL))
+#define ADDR2UINT(addr) ((unsigned int) ((char*) (addr) - (char*) NULL))
#define RESIDUAL(addr,bsize) ((unsigned int) (ADDR2UINT (addr) % (bsize)))
/* Determine the amount of memory spanned by the initial heap table
#define RESIDUAL(addr,bsize) ((unsigned int) (ADDR2UINT (addr) % (bsize)))
/* Determine the amount of memory spanned by the initial heap table
/* Address to block number and vice versa. */
/* Address to block number and vice versa. */
-#define BLOCK(A) (((PTR) (A) - mdp -> heapbase) / BLOCKSIZE + 1)
+#define BLOCK(A) (((char*) (A) - (char*) mdp -> heapbase) / BLOCKSIZE + 1)
-#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + mdp -> heapbase))
+#define ADDRESS(B) ((PTR) (((ADDR2UINT(B)) - 1) * BLOCKSIZE + (char*) mdp -> heapbase))
/* Data structure giving per-block information. */
/* Data structure giving per-block information. */
mdp = MD_TO_MDP (md);
result.bytes_total =
mdp = MD_TO_MDP (md);
result.bytes_total =
- (PTR) mdp -> top - (void *)mdp;
+ (char*) mdp -> top - (char*)mdp;
result.chunks_used = mdp -> heapstats.chunks_used;
result.bytes_used = mdp -> heapstats.bytes_used;
result.chunks_free = mdp -> heapstats.chunks_free;
result.chunks_used = mdp -> heapstats.chunks_used;
result.bytes_used = mdp -> heapstats.bytes_used;
result.chunks_free = mdp -> heapstats.chunks_free;
+/* Useless prototype to make gcc happy */
+void *realloc (void *ptr, size_t size);
+
/* When using this package, provide a version of malloc/realloc/free built
on top of it, so that if we use the default sbrk() region we will not
collide with another malloc package trying to do the same thing, if
/* When using this package, provide a version of malloc/realloc/free built
on top of it, so that if we use the default sbrk() region we will not
collide with another malloc package trying to do the same thing, if
Boston, MA 02111-1307, USA. */
#include "mmprivate.h"
Boston, MA 02111-1307, USA. */
#include "mmprivate.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
/* 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
return (mmemalign (md, cache_pagesize, size));
}
return (mmemalign (md, cache_pagesize, size));
}
+/* Useless prototype to make gcc happy */
+PTR valloc (size_t size);
-valloc (size)
- size_t size;
{
return mvalloc ((PTR) NULL, size);
}
{
return mvalloc ((PTR) NULL, size);
}
- mdp -> breakval += size;
- mdp -> top += size;
+ mdp -> breakval = (char*)mdp -> breakval + size;
+ mdp -> top = (char*)mdp -> top + size;