* ltconfig, ltmain.sh: New files, from libtool 1.0.
[deliverable/binutils-gdb.git] / mmalloc / sbrk-sup.c
1 /* Support for sbrk() regions.
2 Copyright 1992 Free Software Foundation, Inc.
3 Contributed by Fred Fish at Cygnus Support. fnf@cygnus.com
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18
19
20 #include <string.h> /* Prototypes for memcpy, memmove, memset, etc */
21
22 #include "mmalloc.h"
23
24 extern PTR sbrk ();
25
26 /* The mmalloc() package can use a single implicit malloc descriptor
27 for mmalloc/mrealloc/mfree operations which do not supply an explicit
28 descriptor. For these operations, sbrk() is used to obtain more core
29 from the system, or return core. This allows mmalloc() to provide
30 backwards compatibility with the non-mmap'd version. */
31
32 struct mdesc *__mmalloc_default_mdp;
33
34 /* Use sbrk() to get more core. */
35
36 static PTR
37 sbrk_morecore (mdp, size)
38 struct mdesc *mdp;
39 int size;
40 {
41 PTR result;
42
43 if ((result = sbrk (size)) != NULL)
44 {
45 mdp -> breakval += size;
46 mdp -> top += size;
47 }
48 return (result);
49 }
50
51 /* Initialize the default malloc descriptor if this is the first time
52 a request has been made to use the default sbrk'd region. */
53
54 struct mdesc *
55 __mmalloc_sbrk_init ()
56 {
57 PTR base;
58
59 base = sbrk (0);
60 __mmalloc_default_mdp = (struct mdesc *) sbrk (sizeof (struct mdesc));
61 (void) memset ((char *) __mmalloc_default_mdp, 0, sizeof (struct mdesc));
62 __mmalloc_default_mdp -> morecore = sbrk_morecore;
63 __mmalloc_default_mdp -> base = base;
64 __mmalloc_default_mdp -> breakval = __mmalloc_default_mdp -> top = sbrk (0);
65 __mmalloc_default_mdp -> fd = -1;
66 return (__mmalloc_default_mdp);
67 }
68
69
This page took 0.03258 seconds and 4 git commands to generate.