OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc2/] [newlib/] [libc/] [stdlib/] [mstats.c] - Blame information for rev 520

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* VxWorks provides its own version of malloc, and we can't use this
2
   one because VxWorks does not provide sbrk.  So we have a hook to
3
   not compile this code.  */
4
 
5
#ifdef MALLOC_PROVIDED
6
 
7
int _dummy_mstats = 1;
8
 
9
#else
10
 
11
/*
12
FUNCTION
13
<<mallinfo>>, <<malloc_stats>>, <<mallopt>>---malloc support
14
 
15
INDEX
16
        mallinfo
17
INDEX
18
        malloc_stats
19
INDEX
20
        mallopt
21
INDEX
22
        _mallinfo_r
23
INDEX
24
        _malloc_stats_r
25
INDEX
26
        _mallopt_r
27
 
28
ANSI_SYNOPSIS
29
        #include <malloc.h>
30
        struct mallinfo mallinfo(void);
31
        void malloc_stats(void);
32
        int mallopt(int <[parameter]>, <[value]>);
33
 
34
        struct mallinfo _mallinfo_r(void *<[reent]>);
35
        void _malloc_stats_r(void *<[reent]>);
36
        int _mallopt_r(void *<[reent]>, int <[parameter]>, <[value]>);
37
 
38
TRAD_SYNOPSIS
39
        #include <malloc.h>
40
        struct mallinfo mallinfo();
41
 
42
        void malloc_stats();
43
 
44
        int mallopt(<[parameter]>, <[value]>)
45
        int <[parameter]>;
46
        int <[value]>;
47
 
48
        struct mallinfo _mallinfo_r(<[reent]>);
49
        char *<[reent]>;
50
 
51
        void _malloc_stats_r(<[reent]>);
52
        char *<[reent]>;
53
 
54
        int _mallopt_r(<[reent]>, <[parameter]>, <[value]>)
55
        char *<[reent]>;
56
        int <[parameter]>;
57
        int <[value]>;
58
 
59
DESCRIPTION
60
<<mallinfo>> returns a structure describing the current state of
61
memory allocation.  The structure is defined in malloc.h.  The
62
following fields are defined: <<arena>> is the total amount of space
63
in the heap; <<ordblks>> is the number of chunks which are not in use;
64
<<uordblks>> is the total amount of space allocated by <<malloc>>;
65
<<fordblks>> is the total amount of space not in use; <<keepcost>> is
66
the size of the top most memory block.
67
 
68
<<malloc_stats>> print some statistics about memory allocation on
69
standard error.
70
 
71
<<mallopt>> takes a parameter and a value.  The parameters are defined
72
in malloc.h, and may be one of the following: <<M_TRIM_THRESHOLD>>
73
sets the maximum amount of unused space in the top most block before
74
releasing it back to the system in <<free>> (the space is released by
75
calling <<_sbrk_r>> with a negative argument); <<M_TOP_PAD>> is the
76
amount of padding to allocate whenever <<_sbrk_r>> is called to
77
allocate more space.
78
 
79
The alternate functions <<_mallinfo_r>>, <<_malloc_stats_r>>, and
80
<<_mallopt_r>> are reentrant versions.  The extra argument <[reent]>
81
is a pointer to a reentrancy structure.
82
 
83
RETURNS
84
<<mallinfo>> returns a mallinfo structure.  The structure is defined
85
in malloc.h.
86
 
87
<<malloc_stats>> does not return a result.
88
 
89
<<mallopt>> returns zero if the parameter could not be set, or
90
non-zero if it could be set.
91
 
92
PORTABILITY
93
<<mallinfo>> and <<mallopt>> are provided by SVR4, but <<mallopt>>
94
takes different parameters on different systems.  <<malloc_stats>> is
95
not portable.
96
 
97
*/
98
 
99
#include <_ansi.h>
100
#include <reent.h>
101
#include <stdlib.h>
102
#include <malloc.h>
103
#include <stdio.h>
104
 
105
#ifndef _REENT_ONLY
106
 
107
struct mallinfo
108
_DEFUN_VOID (mallinfo)
109
{
110
  return _mallinfo_r (_REENT);
111
}
112
 
113
#if !defined (_ELIX_LEVEL) || _ELIX_LEVEL >= 2
114
void
115
_DEFUN_VOID (malloc_stats)
116
{
117
  _malloc_stats_r (_REENT);
118
}
119
 
120
int
121
_DEFUN (mallopt, (p, v),
122
        int p _AND
123
        int v)
124
{
125
  return _mallopt_r (_REENT, p, v);
126
}
127
 
128
#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 2 */
129
 
130
#endif
131
 
132
#if !defined (_ELIX_LEVEL) || _ELIX_LEVEL >= 2
133
 
134
/* mstats is now compatibility code.  It used to be real, for a
135
   previous version of the malloc routines.  It now just calls
136
   malloc_stats.  */
137
 
138
void
139
_DEFUN (_mstats_r, (ptr, s),
140
        struct _reent *ptr _AND
141
        char *s)
142
{
143
  _REENT_SMALL_CHECK_INIT(ptr);
144
  fiprintf (_stderr_r (ptr), "Memory allocation statistics %s\n", s);
145
  _malloc_stats_r (ptr);
146
}
147
 
148
#ifndef _REENT_ONLY
149
void
150
_DEFUN (mstats, (s),
151
        char *s)
152
{
153
  _mstats_r (_REENT, s);
154
}
155
 
156
#endif
157
 
158
#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 2 */
159
 
160
#endif /* ! defined (MALLOC_PROVIDED) */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.