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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib-1.10.0/] [newlib/] [libc/] [stdlib/] [mstats.c] - Blame information for rev 1773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1010 ivang
/* 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
void
114
_DEFUN_VOID (malloc_stats)
115
{
116
  _malloc_stats_r (_REENT);
117
}
118
 
119
int
120
_DEFUN (mallopt, (p, v),
121
        int p _AND
122
        int v)
123
{
124
  return _mallopt_r (_REENT, p, v);
125
}
126
 
127
#endif
128
 
129
/* mstats is now compatibility code.  It used to be real, for a
130
   previous version of the malloc routines.  It now just calls
131
   malloc_stats.  */
132
 
133
void
134
_DEFUN (_mstats_r, (ptr, s),
135
        struct _reent *ptr _AND
136
        char *s)
137
{
138
  fiprintf (_stderr_r (ptr), "Memory allocation statistics %s\n", s);
139
  _malloc_stats_r (ptr);
140
}
141
 
142
#ifndef _REENT_ONLY
143
void
144
_DEFUN (mstats, (s),
145
        char *s)
146
{
147
  _mstats_r (_REENT, s);
148
}
149
 
150
#endif
151
#endif /* ! defined (MALLOC_PROVIDED) */

powered by: WebSVN 2.1.0

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