xref: /utopia/UTPA2-700.0.x/projects/tools/lint/mips-linux-gnu_include/malloc.h (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1*53ee8cc1Swenshuai.xi /* Prototypes and definition for malloc implementation.
2*53ee8cc1Swenshuai.xi    Copyright (C) 1996, 1997, 1999, 2000, 2002-2004, 2005, 2007
3*53ee8cc1Swenshuai.xi    Free Software Foundation, Inc.
4*53ee8cc1Swenshuai.xi    This file is part of the GNU C Library.
5*53ee8cc1Swenshuai.xi 
6*53ee8cc1Swenshuai.xi    The GNU C Library is free software; you can redistribute it and/or
7*53ee8cc1Swenshuai.xi    modify it under the terms of the GNU Lesser General Public
8*53ee8cc1Swenshuai.xi    License as published by the Free Software Foundation; either
9*53ee8cc1Swenshuai.xi    version 2.1 of the License, or (at your option) any later version.
10*53ee8cc1Swenshuai.xi 
11*53ee8cc1Swenshuai.xi    The GNU C Library is distributed in the hope that it will be useful,
12*53ee8cc1Swenshuai.xi    but WITHOUT ANY WARRANTY; without even the implied warranty of
13*53ee8cc1Swenshuai.xi    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*53ee8cc1Swenshuai.xi    Lesser General Public License for more details.
15*53ee8cc1Swenshuai.xi 
16*53ee8cc1Swenshuai.xi    You should have received a copy of the GNU Lesser General Public
17*53ee8cc1Swenshuai.xi    License along with the GNU C Library; if not, write to the Free
18*53ee8cc1Swenshuai.xi    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19*53ee8cc1Swenshuai.xi    02111-1307 USA.  */
20*53ee8cc1Swenshuai.xi 
21*53ee8cc1Swenshuai.xi #ifndef _MALLOC_H
22*53ee8cc1Swenshuai.xi #define _MALLOC_H 1
23*53ee8cc1Swenshuai.xi 
24*53ee8cc1Swenshuai.xi #include <features.h>
25*53ee8cc1Swenshuai.xi #include <stddef.h>
26*53ee8cc1Swenshuai.xi # define __malloc_ptr_t  void *
27*53ee8cc1Swenshuai.xi 
28*53ee8cc1Swenshuai.xi /* Used by GNU libc internals. */
29*53ee8cc1Swenshuai.xi #define __malloc_size_t size_t
30*53ee8cc1Swenshuai.xi #define __malloc_ptrdiff_t ptrdiff_t
31*53ee8cc1Swenshuai.xi 
32*53ee8cc1Swenshuai.xi #ifdef __GNUC__
33*53ee8cc1Swenshuai.xi 
34*53ee8cc1Swenshuai.xi # define __MALLOC_P(args)	args __THROW
35*53ee8cc1Swenshuai.xi /* This macro will be used for functions which might take C++ callback
36*53ee8cc1Swenshuai.xi    functions.  */
37*53ee8cc1Swenshuai.xi # define __MALLOC_PMT(args)	args
38*53ee8cc1Swenshuai.xi 
39*53ee8cc1Swenshuai.xi #else	/* Not GCC.  */
40*53ee8cc1Swenshuai.xi 
41*53ee8cc1Swenshuai.xi # define __MALLOC_P(args)	args
42*53ee8cc1Swenshuai.xi # define __MALLOC_PMT(args)	args
43*53ee8cc1Swenshuai.xi 
44*53ee8cc1Swenshuai.xi #endif	/* GCC.  */
45*53ee8cc1Swenshuai.xi 
46*53ee8cc1Swenshuai.xi 
47*53ee8cc1Swenshuai.xi __BEGIN_DECLS
48*53ee8cc1Swenshuai.xi 
49*53ee8cc1Swenshuai.xi /* Allocate SIZE bytes of memory.  */
50*53ee8cc1Swenshuai.xi extern void *malloc __MALLOC_P ((size_t __size)) __attribute_malloc__ __wur;
51*53ee8cc1Swenshuai.xi 
52*53ee8cc1Swenshuai.xi /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
53*53ee8cc1Swenshuai.xi extern void *calloc __MALLOC_P ((size_t __nmemb, size_t __size))
54*53ee8cc1Swenshuai.xi        __attribute_malloc__ __wur;
55*53ee8cc1Swenshuai.xi 
56*53ee8cc1Swenshuai.xi /* Re-allocate the previously allocated block in __ptr, making the new
57*53ee8cc1Swenshuai.xi    block SIZE bytes long.  */
58*53ee8cc1Swenshuai.xi /* __attribute_malloc__ is not used, because if realloc returns
59*53ee8cc1Swenshuai.xi    the same pointer that was passed to it, aliasing needs to be allowed
60*53ee8cc1Swenshuai.xi    between objects pointed by the old and new pointers.  */
61*53ee8cc1Swenshuai.xi extern void *realloc __MALLOC_P ((void *__ptr, size_t __size))
62*53ee8cc1Swenshuai.xi        __attribute_warn_unused_result__;
63*53ee8cc1Swenshuai.xi 
64*53ee8cc1Swenshuai.xi /* Free a block allocated by `malloc', `realloc' or `calloc'.  */
65*53ee8cc1Swenshuai.xi extern void free __MALLOC_P ((void *__ptr));
66*53ee8cc1Swenshuai.xi 
67*53ee8cc1Swenshuai.xi /* Free a block allocated by `calloc'. */
68*53ee8cc1Swenshuai.xi extern void cfree __MALLOC_P ((void *__ptr));
69*53ee8cc1Swenshuai.xi 
70*53ee8cc1Swenshuai.xi /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
71*53ee8cc1Swenshuai.xi extern void *memalign __MALLOC_P ((size_t __alignment, size_t __size))
72*53ee8cc1Swenshuai.xi        __attribute_malloc__ __wur;
73*53ee8cc1Swenshuai.xi 
74*53ee8cc1Swenshuai.xi /* Allocate SIZE bytes on a page boundary.  */
75*53ee8cc1Swenshuai.xi extern void *valloc __MALLOC_P ((size_t __size))
76*53ee8cc1Swenshuai.xi        __attribute_malloc__ __wur;
77*53ee8cc1Swenshuai.xi 
78*53ee8cc1Swenshuai.xi /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
79*53ee8cc1Swenshuai.xi    __size to nearest pagesize. */
80*53ee8cc1Swenshuai.xi extern void * pvalloc __MALLOC_P ((size_t __size))
81*53ee8cc1Swenshuai.xi        __attribute_malloc__ __wur;
82*53ee8cc1Swenshuai.xi 
83*53ee8cc1Swenshuai.xi /* Underlying allocation function; successive calls should return
84*53ee8cc1Swenshuai.xi    contiguous pieces of memory.  */
85*53ee8cc1Swenshuai.xi extern void *(*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
86*53ee8cc1Swenshuai.xi 
87*53ee8cc1Swenshuai.xi /* Default value of `__morecore'.  */
88*53ee8cc1Swenshuai.xi extern void *__default_morecore __MALLOC_P ((ptrdiff_t __size))
89*53ee8cc1Swenshuai.xi        __attribute_malloc__;
90*53ee8cc1Swenshuai.xi 
91*53ee8cc1Swenshuai.xi /* SVID2/XPG mallinfo structure */
92*53ee8cc1Swenshuai.xi 
93*53ee8cc1Swenshuai.xi struct mallinfo {
94*53ee8cc1Swenshuai.xi   int arena;    /* non-mmapped space allocated from system */
95*53ee8cc1Swenshuai.xi   int ordblks;  /* number of free chunks */
96*53ee8cc1Swenshuai.xi   int smblks;   /* number of fastbin blocks */
97*53ee8cc1Swenshuai.xi   int hblks;    /* number of mmapped regions */
98*53ee8cc1Swenshuai.xi   int hblkhd;   /* space in mmapped regions */
99*53ee8cc1Swenshuai.xi   int usmblks;  /* maximum total allocated space */
100*53ee8cc1Swenshuai.xi   int fsmblks;  /* space available in freed fastbin blocks */
101*53ee8cc1Swenshuai.xi   int uordblks; /* total allocated space */
102*53ee8cc1Swenshuai.xi   int fordblks; /* total free space */
103*53ee8cc1Swenshuai.xi   int keepcost; /* top-most, releasable (via malloc_trim) space */
104*53ee8cc1Swenshuai.xi };
105*53ee8cc1Swenshuai.xi 
106*53ee8cc1Swenshuai.xi /* Returns a copy of the updated current mallinfo. */
107*53ee8cc1Swenshuai.xi extern struct mallinfo mallinfo __MALLOC_P ((void));
108*53ee8cc1Swenshuai.xi 
109*53ee8cc1Swenshuai.xi /* SVID2/XPG mallopt options */
110*53ee8cc1Swenshuai.xi #ifndef M_MXFAST
111*53ee8cc1Swenshuai.xi # define M_MXFAST  1	/* maximum request size for "fastbins" */
112*53ee8cc1Swenshuai.xi #endif
113*53ee8cc1Swenshuai.xi #ifndef M_NLBLKS
114*53ee8cc1Swenshuai.xi # define M_NLBLKS  2	/* UNUSED in this malloc */
115*53ee8cc1Swenshuai.xi #endif
116*53ee8cc1Swenshuai.xi #ifndef M_GRAIN
117*53ee8cc1Swenshuai.xi # define M_GRAIN   3	/* UNUSED in this malloc */
118*53ee8cc1Swenshuai.xi #endif
119*53ee8cc1Swenshuai.xi #ifndef M_KEEP
120*53ee8cc1Swenshuai.xi # define M_KEEP    4	/* UNUSED in this malloc */
121*53ee8cc1Swenshuai.xi #endif
122*53ee8cc1Swenshuai.xi 
123*53ee8cc1Swenshuai.xi /* mallopt options that actually do something */
124*53ee8cc1Swenshuai.xi #define M_TRIM_THRESHOLD    -1
125*53ee8cc1Swenshuai.xi #define M_TOP_PAD           -2
126*53ee8cc1Swenshuai.xi #define M_MMAP_THRESHOLD    -3
127*53ee8cc1Swenshuai.xi #define M_MMAP_MAX          -4
128*53ee8cc1Swenshuai.xi #define M_CHECK_ACTION      -5
129*53ee8cc1Swenshuai.xi #define M_PERTURB	    -6
130*53ee8cc1Swenshuai.xi 
131*53ee8cc1Swenshuai.xi /* General SVID/XPG interface to tunable parameters. */
132*53ee8cc1Swenshuai.xi extern int mallopt __MALLOC_P ((int __param, int __val));
133*53ee8cc1Swenshuai.xi 
134*53ee8cc1Swenshuai.xi /* Release all but __pad bytes of freed top-most memory back to the
135*53ee8cc1Swenshuai.xi    system. Return 1 if successful, else 0. */
136*53ee8cc1Swenshuai.xi extern int malloc_trim __MALLOC_P ((size_t __pad));
137*53ee8cc1Swenshuai.xi 
138*53ee8cc1Swenshuai.xi /* Report the number of usable allocated bytes associated with allocated
139*53ee8cc1Swenshuai.xi    chunk __ptr. */
140*53ee8cc1Swenshuai.xi extern size_t malloc_usable_size __MALLOC_P ((void *__ptr));
141*53ee8cc1Swenshuai.xi 
142*53ee8cc1Swenshuai.xi /* Prints brief summary statistics on stderr. */
143*53ee8cc1Swenshuai.xi extern void malloc_stats __MALLOC_P ((void));
144*53ee8cc1Swenshuai.xi 
145*53ee8cc1Swenshuai.xi /* Record the state of all malloc variables in an opaque data structure. */
146*53ee8cc1Swenshuai.xi extern void *malloc_get_state __MALLOC_P ((void));
147*53ee8cc1Swenshuai.xi 
148*53ee8cc1Swenshuai.xi /* Restore the state of all malloc variables from data obtained with
149*53ee8cc1Swenshuai.xi    malloc_get_state(). */
150*53ee8cc1Swenshuai.xi extern int malloc_set_state __MALLOC_P ((void *__ptr));
151*53ee8cc1Swenshuai.xi 
152*53ee8cc1Swenshuai.xi /* Called once when malloc is initialized; redefining this variable in
153*53ee8cc1Swenshuai.xi    the application provides the preferred way to set up the hook
154*53ee8cc1Swenshuai.xi    pointers. */
155*53ee8cc1Swenshuai.xi extern void (*__malloc_initialize_hook) __MALLOC_PMT ((void));
156*53ee8cc1Swenshuai.xi /* Hooks for debugging and user-defined versions. */
157*53ee8cc1Swenshuai.xi extern void (*__free_hook) __MALLOC_PMT ((void *__ptr,
158*53ee8cc1Swenshuai.xi 					__const __malloc_ptr_t));
159*53ee8cc1Swenshuai.xi extern void *(*__malloc_hook) __MALLOC_PMT ((size_t __size,
160*53ee8cc1Swenshuai.xi 					     __const __malloc_ptr_t));
161*53ee8cc1Swenshuai.xi extern void *(*__realloc_hook) __MALLOC_PMT ((void *__ptr, size_t __size,
162*53ee8cc1Swenshuai.xi 					      __const __malloc_ptr_t));
163*53ee8cc1Swenshuai.xi extern void *(*__memalign_hook) __MALLOC_PMT ((size_t __alignment,
164*53ee8cc1Swenshuai.xi 					       size_t __size,
165*53ee8cc1Swenshuai.xi 					       __const __malloc_ptr_t));
166*53ee8cc1Swenshuai.xi extern void (*__after_morecore_hook) __MALLOC_PMT ((void));
167*53ee8cc1Swenshuai.xi 
168*53ee8cc1Swenshuai.xi /* Activate a standard set of debugging hooks. */
169*53ee8cc1Swenshuai.xi extern void __malloc_check_init __MALLOC_P ((void));
170*53ee8cc1Swenshuai.xi 
171*53ee8cc1Swenshuai.xi 
172*53ee8cc1Swenshuai.xi __END_DECLS
173*53ee8cc1Swenshuai.xi 
174*53ee8cc1Swenshuai.xi #endif /* malloc.h */
175