Rev 4874 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4874 | Rev 4921 | ||
---|---|---|---|
1 | /* malloc.h -- header file for memory routines. */ |
1 | /* malloc.h -- header file for memory routines. */ |
2 | 2 | ||
3 | #ifndef _INCLUDE_MALLOC_H_ |
3 | #ifndef _INCLUDE_MALLOC_H_ |
4 | #define _INCLUDE_MALLOC_H_ |
4 | #define _INCLUDE_MALLOC_H_ |
5 | 5 | ||
6 | #include <_ansi.h> |
6 | #include <_ansi.h> |
7 | #include |
7 | #include |
8 | 8 | ||
9 | #define __need_size_t |
9 | #define __need_size_t |
10 | #include |
10 | #include |
11 | 11 | ||
12 | /* include any machine-specific extensions */ |
12 | /* include any machine-specific extensions */ |
13 | #include |
13 | #include |
14 | 14 | ||
15 | #ifdef __cplusplus |
15 | #ifdef __cplusplus |
16 | extern "C" { |
16 | extern "C" { |
17 | #endif |
17 | #endif |
18 | 18 | ||
19 | /* This version of struct mallinfo must match the one in |
19 | /* This version of struct mallinfo must match the one in |
20 | libc/stdlib/mallocr.c. */ |
20 | libc/stdlib/mallocr.c. */ |
21 | 21 | ||
22 | struct mallinfo { |
22 | struct mallinfo { |
23 | int arena; /* total space allocated from system */ |
23 | size_t arena; /* total space allocated from system */ |
24 | int ordblks; /* number of non-inuse chunks */ |
24 | size_t ordblks; /* number of non-inuse chunks */ |
25 | int smblks; /* unused -- always zero */ |
25 | size_t smblks; /* unused -- always zero */ |
26 | int hblks; /* number of mmapped regions */ |
26 | size_t hblks; /* number of mmapped regions */ |
27 | int hblkhd; /* total space in mmapped regions */ |
27 | size_t hblkhd; /* total space in mmapped regions */ |
28 | int usmblks; /* unused -- always zero */ |
28 | size_t usmblks; /* unused -- always zero */ |
29 | int fsmblks; /* unused -- always zero */ |
29 | size_t fsmblks; /* unused -- always zero */ |
30 | int uordblks; /* total allocated space */ |
30 | size_t uordblks; /* total allocated space */ |
31 | int fordblks; /* total non-inuse space */ |
31 | size_t fordblks; /* total non-inuse space */ |
32 | int keepcost; /* top-most, releasable (via malloc_trim) space */ |
32 | size_t keepcost; /* top-most, releasable (via malloc_trim) space */ |
33 | }; |
33 | }; |
34 | 34 | ||
35 | /* The routines. */ |
35 | /* The routines. */ |
36 | 36 | ||
37 | extern _PTR malloc _PARAMS ((size_t)); |
37 | extern _PTR malloc _PARAMS ((size_t)); |
38 | #ifdef __CYGWIN__ |
38 | #ifdef __CYGWIN__ |
39 | #undef _malloc_r |
39 | #undef _malloc_r |
40 | #define _malloc_r(r, s) malloc (s) |
40 | #define _malloc_r(r, s) malloc (s) |
41 | #else |
41 | #else |
42 | extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t)); |
42 | extern _PTR _malloc_r _PARAMS ((struct _reent *, size_t)); |
43 | #endif |
43 | #endif |
44 | 44 | ||
45 | extern _VOID free _PARAMS ((_PTR)); |
45 | extern _VOID free _PARAMS ((_PTR)); |
46 | #ifdef __CYGWIN__ |
46 | #ifdef __CYGWIN__ |
47 | #undef _free_r |
47 | #undef _free_r |
48 | #define _free_r(r, p) free (p) |
48 | #define _free_r(r, p) free (p) |
49 | #else |
49 | #else |
50 | extern _VOID _free_r _PARAMS ((struct _reent *, _PTR)); |
50 | extern _VOID _free_r _PARAMS ((struct _reent *, _PTR)); |
51 | #endif |
51 | #endif |
52 | 52 | ||
53 | extern _PTR realloc _PARAMS ((_PTR, size_t)); |
53 | extern _PTR realloc _PARAMS ((_PTR, size_t)); |
54 | #ifdef __CYGWIN__ |
54 | #ifdef __CYGWIN__ |
55 | #undef _realloc_r |
55 | #undef _realloc_r |
56 | #define _realloc_r(r, p, s) realloc (p, s) |
56 | #define _realloc_r(r, p, s) realloc (p, s) |
57 | #else |
57 | #else |
58 | extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t)); |
58 | extern _PTR _realloc_r _PARAMS ((struct _reent *, _PTR, size_t)); |
59 | #endif |
59 | #endif |
60 | 60 | ||
61 | extern _PTR calloc _PARAMS ((size_t, size_t)); |
61 | extern _PTR calloc _PARAMS ((size_t, size_t)); |
62 | #ifdef __CYGWIN__ |
62 | #ifdef __CYGWIN__ |
63 | #undef _calloc_r |
63 | #undef _calloc_r |
64 | #define _calloc_r(r, s1, s2) calloc (s1, s2); |
64 | #define _calloc_r(r, s1, s2) calloc (s1, s2); |
65 | #else |
65 | #else |
66 | extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t)); |
66 | extern _PTR _calloc_r _PARAMS ((struct _reent *, size_t, size_t)); |
67 | #endif |
67 | #endif |
68 | 68 | ||
69 | extern _PTR memalign _PARAMS ((size_t, size_t)); |
69 | extern _PTR memalign _PARAMS ((size_t, size_t)); |
70 | #ifdef __CYGWIN__ |
70 | #ifdef __CYGWIN__ |
71 | #undef _memalign_r |
71 | #undef _memalign_r |
72 | #define _memalign_r(r, s1, s2) memalign (s1, s2); |
72 | #define _memalign_r(r, s1, s2) memalign (s1, s2); |
73 | #else |
73 | #else |
74 | extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t)); |
74 | extern _PTR _memalign_r _PARAMS ((struct _reent *, size_t, size_t)); |
75 | #endif |
75 | #endif |
76 | 76 | ||
77 | extern struct mallinfo mallinfo _PARAMS ((void)); |
77 | extern struct mallinfo mallinfo _PARAMS ((void)); |
78 | #ifdef __CYGWIN__ |
78 | #ifdef __CYGWIN__ |
79 | #undef _mallinfo_r |
79 | #undef _mallinfo_r |
80 | #define _mallinfo_r(r) mallinfo () |
80 | #define _mallinfo_r(r) mallinfo () |
81 | #else |
81 | #else |
82 | extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *)); |
82 | extern struct mallinfo _mallinfo_r _PARAMS ((struct _reent *)); |
83 | #endif |
83 | #endif |
84 | 84 | ||
85 | extern void malloc_stats _PARAMS ((void)); |
85 | extern void malloc_stats _PARAMS ((void)); |
86 | #ifdef __CYGWIN__ |
86 | #ifdef __CYGWIN__ |
87 | #undef _malloc_stats_r |
87 | #undef _malloc_stats_r |
88 | #define _malloc_stats_r(r) malloc_stats () |
88 | #define _malloc_stats_r(r) malloc_stats () |
89 | #else |
89 | #else |
90 | extern void _malloc_stats_r _PARAMS ((struct _reent *)); |
90 | extern void _malloc_stats_r _PARAMS ((struct _reent *)); |
91 | #endif |
91 | #endif |
92 | 92 | ||
93 | extern int mallopt _PARAMS ((int, int)); |
93 | extern int mallopt _PARAMS ((int, int)); |
94 | #ifdef __CYGWIN__ |
94 | #ifdef __CYGWIN__ |
95 | #undef _mallopt_r |
95 | #undef _mallopt_r |
96 | #define _mallopt_r(i1, i2) mallopt (i1, i2) |
96 | #define _mallopt_r(i1, i2) mallopt (i1, i2) |
97 | #else |
97 | #else |
98 | extern int _mallopt_r _PARAMS ((struct _reent *, int, int)); |
98 | extern int _mallopt_r _PARAMS ((struct _reent *, int, int)); |
99 | #endif |
99 | #endif |
100 | 100 | ||
101 | extern size_t malloc_usable_size _PARAMS ((_PTR)); |
101 | extern size_t malloc_usable_size _PARAMS ((_PTR)); |
102 | #ifdef __CYGWIN__ |
102 | #ifdef __CYGWIN__ |
103 | #undef _malloc_usable_size_r |
103 | #undef _malloc_usable_size_r |
104 | #define _malloc_usable_size_r(r, p) malloc_usable_size (p) |
104 | #define _malloc_usable_size_r(r, p) malloc_usable_size (p) |
105 | #else |
105 | #else |
106 | extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR)); |
106 | extern size_t _malloc_usable_size_r _PARAMS ((struct _reent *, _PTR)); |
107 | #endif |
107 | #endif |
108 | 108 | ||
109 | /* These aren't too useful on an embedded system, but we define them |
109 | /* These aren't too useful on an embedded system, but we define them |
110 | anyhow. */ |
110 | anyhow. */ |
111 | 111 | ||
112 | extern _PTR valloc _PARAMS ((size_t)); |
112 | extern _PTR valloc _PARAMS ((size_t)); |
113 | #ifdef __CYGWIN__ |
113 | #ifdef __CYGWIN__ |
114 | #undef _valloc_r |
114 | #undef _valloc_r |
115 | #define _valloc_r(r, s) valloc (s) |
115 | #define _valloc_r(r, s) valloc (s) |
116 | #else |
116 | #else |
117 | extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t)); |
117 | extern _PTR _valloc_r _PARAMS ((struct _reent *, size_t)); |
118 | #endif |
118 | #endif |
119 | 119 | ||
120 | extern _PTR pvalloc _PARAMS ((size_t)); |
120 | extern _PTR pvalloc _PARAMS ((size_t)); |
121 | #ifdef __CYGWIN__ |
121 | #ifdef __CYGWIN__ |
122 | #undef _pvalloc_r |
122 | #undef _pvalloc_r |
123 | #define _pvalloc_r(r, s) pvalloc (s) |
123 | #define _pvalloc_r(r, s) pvalloc (s) |
124 | #else |
124 | #else |
125 | extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t)); |
125 | extern _PTR _pvalloc_r _PARAMS ((struct _reent *, size_t)); |
126 | #endif |
126 | #endif |
127 | 127 | ||
128 | extern int malloc_trim _PARAMS ((size_t)); |
128 | extern int malloc_trim _PARAMS ((size_t)); |
129 | #ifdef __CYGWIN__ |
129 | #ifdef __CYGWIN__ |
130 | #undef _malloc_trim_r |
130 | #undef _malloc_trim_r |
131 | #define _malloc_trim_r(r, s) malloc_trim (s) |
131 | #define _malloc_trim_r(r, s) malloc_trim (s) |
132 | #else |
132 | #else |
133 | extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t)); |
133 | extern int _malloc_trim_r _PARAMS ((struct _reent *, size_t)); |
134 | #endif |
134 | #endif |
135 | 135 | ||
136 | /* A compatibility routine for an earlier version of the allocator. */ |
136 | /* A compatibility routine for an earlier version of the allocator. */ |
137 | 137 | ||
138 | extern _VOID mstats _PARAMS ((char *)); |
138 | extern _VOID mstats _PARAMS ((char *)); |
139 | #ifdef __CYGWIN__ |
139 | #ifdef __CYGWIN__ |
140 | #undef _mstats_r |
140 | #undef _mstats_r |
141 | #define _mstats_r(r, p) mstats (p) |
141 | #define _mstats_r(r, p) mstats (p) |
142 | #else |
142 | #else |
143 | extern _VOID _mstats_r _PARAMS ((struct _reent *, char *)); |
143 | extern _VOID _mstats_r _PARAMS ((struct _reent *, char *)); |
144 | #endif |
144 | #endif |
145 | 145 | ||
146 | /* SVID2/XPG mallopt options */ |
146 | /* SVID2/XPG mallopt options */ |
147 | 147 | ||
148 | #define M_MXFAST 1 /* UNUSED in this malloc */ |
148 | #define M_MXFAST 1 /* UNUSED in this malloc */ |
149 | #define M_NLBLKS 2 /* UNUSED in this malloc */ |
149 | #define M_NLBLKS 2 /* UNUSED in this malloc */ |
150 | #define M_GRAIN 3 /* UNUSED in this malloc */ |
150 | #define M_GRAIN 3 /* UNUSED in this malloc */ |
151 | #define M_KEEP 4 /* UNUSED in this malloc */ |
151 | #define M_KEEP 4 /* UNUSED in this malloc */ |
152 | 152 | ||
153 | /* mallopt options that actually do something */ |
153 | /* mallopt options that actually do something */ |
154 | 154 | ||
155 | #define M_TRIM_THRESHOLD -1 |
155 | #define M_TRIM_THRESHOLD -1 |
156 | #define M_TOP_PAD -2 |
156 | #define M_TOP_PAD -2 |
157 | #define M_MMAP_THRESHOLD -3 |
157 | #define M_MMAP_THRESHOLD -3 |
158 | #define M_MMAP_MAX -4 |
158 | #define M_MMAP_MAX -4 |
159 | 159 | ||
160 | #ifndef __CYGWIN__ |
160 | #ifndef __CYGWIN__ |
161 | /* Some systems provide this, so do too for compatibility. */ |
161 | /* Some systems provide this, so do too for compatibility. */ |
162 | extern void cfree _PARAMS ((_PTR)); |
162 | extern void cfree _PARAMS ((_PTR)); |
163 | #endif /* __CYGWIN__ */ |
163 | #endif /* __CYGWIN__ */ |
164 | 164 | ||
165 | #ifdef __cplusplus |
165 | #ifdef __cplusplus |
166 | } |
166 | } |
167 | #endif |
167 | #endif |
168 | 168 | ||
169 | #endif /* _INCLUDE_MALLOC_H_ */ |
169 | #endif /* _INCLUDE_MALLOC_H_ */ |