diff options
author | Fred Fish <fnf@specifix.com> | 1992-04-17 03:01:54 +0000 |
---|---|---|
committer | Fred Fish <fnf@specifix.com> | 1992-04-17 03:01:54 +0000 |
commit | 13b33d2b0a53a588bbec6e9ab9946d40947a84b1 (patch) | |
tree | a9bba09ddaf1f4132b14bbe46fb42865aad1cdc5 /mmalloc | |
parent | 2d6d969c616d286076df1778db0d06a64f11251a (diff) | |
download | binutils-13b33d2b0a53a588bbec6e9ab9946d40947a84b1.tar.gz binutils-13b33d2b0a53a588bbec6e9ab9946d40947a84b1.tar.bz2 binutils-13b33d2b0a53a588bbec6e9ab9946d40947a84b1.zip |
* TODO: New file.
* attach.c, mcalloc.c, mfree.c, mmalloc.c, mmalloc.h, mmap-sup.c,
mmcheck.c, mtrace.c, mrealloc.c, mvalloc.c, sbrk-sup.c: Lint.
Diffstat (limited to 'mmalloc')
-rw-r--r-- | mmalloc/TODO | 15 | ||||
-rw-r--r-- | mmalloc/sbrk-sup.c | 69 |
2 files changed, 84 insertions, 0 deletions
diff --git a/mmalloc/TODO b/mmalloc/TODO new file mode 100644 index 00000000000..46bccc26b43 --- /dev/null +++ b/mmalloc/TODO @@ -0,0 +1,15 @@ +(1) Make implementation changes necessary to allow multiple processes + to use the mmalloc managed region simultaneously. This requires, + at the minimum, some sort of cooperative locking that ensures that + only one process at a time is changing any of the mmalloc managed + data structures (its ok for the mmalloc managed data regions to be + changed at any time since we don't care about their contents). + +(2) In order to support multiple processes using the mmalloc managed + region, the malloc descriptor needs to be broken into two parts, + one part which is specific to the given process and is maintained + separately on a per process basis, and another part which is common + to all processes. As an example, the file descriptor is specific + to a given process, as are the morecore and abortfunc pointers. + However magic[], the version number, the flags field, etc are + common to all processes. diff --git a/mmalloc/sbrk-sup.c b/mmalloc/sbrk-sup.c new file mode 100644 index 00000000000..f6efa1746e0 --- /dev/null +++ b/mmalloc/sbrk-sup.c @@ -0,0 +1,69 @@ +/* Support for sbrk() regions. + Copyright 1992 Free Software Foundation, Inc. + Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU 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 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +#include <string.h> /* Prototypes for memcpy, memmove, memset, etc */ + +#include "mmalloc.h" + +extern PTR sbrk (); + +/* The mmalloc() package can use a single implicit malloc descriptor + for mmalloc/mrealloc/mfree operations which do not supply an explicit + descriptor. For these operations, sbrk() is used to obtain more core + from the system, or return core. This allows mmalloc() to provide + backwards compatibility with the non-mmap'd version. */ + +struct mdesc *__mmalloc_default_mdp; + +/* Use sbrk() to get more core. */ + +static PTR +sbrk_morecore (mdp, size) + struct mdesc *mdp; + int size; +{ + PTR result; + + if ((result = sbrk (size)) != NULL) + { + mdp -> breakval += size; + mdp -> top += size; + } + return (result); +} + +/* Initialize the default malloc descriptor if this is the first time + a request has been made to use the default sbrk'd region. */ + +struct mdesc * +__mmalloc_sbrk_init () +{ + PTR base; + + base = sbrk (0); + __mmalloc_default_mdp = (struct mdesc *) sbrk (sizeof (struct mdesc)); + (void) memset ((char *) __mmalloc_default_mdp, 0, sizeof (struct mdesc)); + __mmalloc_default_mdp -> morecore = sbrk_morecore; + __mmalloc_default_mdp -> base = base; + __mmalloc_default_mdp -> breakval = __mmalloc_default_mdp -> top = sbrk (0); + __mmalloc_default_mdp -> fd = -1; + return (__mmalloc_default_mdp); +} + + |