1 /* Support for sbrk() regions.
2 Copyright 1992, 2000 Free Software Foundation, Inc.
3 Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com */
5 /* Copyright (c) 2010. The SimGrid Team.
6 * All rights reserved. */
8 /* This program is free software; you can redistribute it and/or modify it
9 * under the terms of the license (GNU LGPL) which comes with this package. */
11 #include <unistd.h> /* Prototypes for sbrk (maybe) */
13 #include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
16 #include "mmprivate.h"
18 static void* sbrk_morecore (struct mdesc *mdp, int size);
19 #if NEED_DECLARATION_SBRK
20 extern void* sbrk (int size);
23 /* The mmalloc() package can use a single implicit malloc descriptor
24 for mmalloc/mrealloc/mfree operations which do not supply an explicit
25 descriptor. For these operations, sbrk() is used to obtain more core
26 from the system, or return core. This allows mmalloc() to provide
27 backwards compatibility with the non-mmap'd version. */
29 struct mdesc *__mmalloc_default_mdp;
31 /* Use sbrk() to get more core. */
34 sbrk_morecore (mdp, size)
40 if ((result = sbrk (size)) == (void*) -1)
46 mdp -> breakval = (char*)mdp -> breakval + size;
47 mdp -> top = (char*)mdp -> top + size;