RT-AC56 3.0.0.4.374.37 core
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / sysroot / usr / include / malloc.h
blob49c4dbba45d99fb1b2bd8f38311a2d0ee62fbb9f
1 /* Prototypes and definition for malloc implementation.
2 Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _MALLOC_H
21 #define _MALLOC_H 1
23 #include <features.h>
26 `ptmalloc', a malloc implementation for multiple threads without
27 lock contention, by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>.
28 See the files `ptmalloc.c' or `COPYRIGHT' for copying conditions.
30 VERSION 2.6.4-pt Wed Dec 4 00:35:54 MET 1996
32 This work is mainly derived from malloc-2.6.4 by Doug Lea
33 <dl@cs.oswego.edu>, which is available from:
35 ftp://g.oswego.edu/pub/misc/malloc.c
37 This trimmed-down header file only provides function prototypes and
38 the exported data structures. For more detailed function
39 descriptions and compile-time options, see the source file
40 `ptmalloc.c'.
43 #if defined(__STDC__) || defined (__cplusplus)
44 # include <stddef.h>
45 # define __malloc_ptr_t void *
46 #else
47 # undef size_t
48 # define size_t unsigned int
49 # undef ptrdiff_t
50 # define ptrdiff_t int
51 # define __malloc_ptr_t char *
52 #endif
54 #if !defined __attribute_malloc__
55 # define __attribute_malloc__
56 #endif
58 #ifdef __GNUC__
60 /* GCC can always grok prototypes. For C++ programs we add throw()
61 to help it optimize the function calls. But this works only with
62 gcc 2.8.x and egcs. */
63 #ifndef __THROW
64 # if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8)
65 # define __THROW throw ()
66 # else
67 # define __THROW
68 # endif
69 #endif
70 # define __MALLOC_P(args) args __THROW
71 /* This macro will be used for functions which might take C++ callback
72 functions. */
73 # define __MALLOC_PMT(args) args
75 #else /* Not GCC. */
77 # define __THROW
79 # if (defined __STDC__ && __STDC__) || defined __cplusplus
81 # define __MALLOC_P(args) args
82 # define __MALLOC_PMT(args) args
84 # else /* Not ANSI C or C++. */
86 # define __MALLOC_P(args) () /* No prototypes. */
87 # define __MALLOC_PMT(args) ()
89 # endif /* ANSI C or C++. */
91 #endif /* GCC. */
93 #ifndef NULL
94 # ifdef __cplusplus
95 # define NULL 0
96 # else
97 # define NULL ((__malloc_ptr_t) 0)
98 # endif
99 #endif
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
105 /* Allocate SIZE bytes of memory. */
106 extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
108 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
109 extern __malloc_ptr_t calloc __MALLOC_P ((size_t __nmemb, size_t __size))
110 __attribute_malloc__;
112 /* Re-allocate the previously allocated block in __ptr, making the new
113 block SIZE bytes long. */
114 extern __malloc_ptr_t realloc __MALLOC_P ((__malloc_ptr_t __ptr,
115 size_t __size))
116 __attribute_malloc__;
118 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
119 extern void free __MALLOC_P ((__malloc_ptr_t __ptr));
121 /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
122 extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size));
124 /* Allocate SIZE bytes on a page boundary. */
125 extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
127 #ifdef __MALLOC_STANDARD__
129 /* SVID2/XPG mallinfo structure */
130 struct mallinfo {
131 int arena; /* total space allocated from system */
132 int ordblks; /* number of non-inuse chunks */
133 int smblks; /* unused -- always zero */
134 int hblks; /* number of mmapped regions */
135 int hblkhd; /* total space in mmapped regions */
136 int usmblks; /* unused -- always zero */
137 int fsmblks; /* unused -- always zero */
138 int uordblks; /* total allocated space */
139 int fordblks; /* total non-inuse space */
140 int keepcost; /* top-most, releasable (via malloc_trim) space */
143 /* Returns a copy of the updated current mallinfo. */
144 extern struct mallinfo mallinfo __MALLOC_P ((void));
146 /* Release all but __pad bytes of freed top-most memory back to the
147 system. Return 1 if successful, else 0. */
148 extern int malloc_trim(size_t pad);
150 #include <stdio.h>
151 /* Prints brief summary statistics to the specified file.
152 * Writes to stderr if file is NULL. */
153 extern void malloc_stats(FILE *file);
155 /* SVID2/XPG mallopt options */
156 #ifndef M_MXFAST
157 # define M_MXFAST 1 /* UNUSED in this malloc */
158 #endif
159 #ifndef M_NLBLKS
160 # define M_NLBLKS 2 /* UNUSED in this malloc */
161 #endif
162 #ifndef M_GRAIN
163 # define M_GRAIN 3 /* UNUSED in this malloc */
164 #endif
165 #ifndef M_KEEP
166 # define M_KEEP 4 /* UNUSED in this malloc */
167 #endif
169 /* mallopt options that actually do something */
170 #define M_TRIM_THRESHOLD -1
171 #define M_TOP_PAD -2
172 #define M_MMAP_THRESHOLD -3
173 #define M_MMAP_MAX -4
174 #define M_CHECK_ACTION -5
175 #define M_PERTURB -6
177 /* General SVID/XPG interface to tunable parameters. */
178 extern int mallopt __MALLOC_P ((int __param, int __val));
180 #endif /* __MALLOC_STANDARD__ */
182 /* uClibc may use malloc internally in situations where user can not be
183 * notified about out-of-memory condition. In this situation uClibc will
184 * call __uc_malloc_failed if it is non-NULL, and retry allocation
185 * if it returns. If __uc_malloc_failed is NULL, uclibc will _exit(1).
186 * NB: do not use stdio in __uc_malloc_failed handler! */
187 extern void *__uc_malloc(size_t size);
188 extern void (*__uc_malloc_failed)(size_t size);
190 #ifdef __cplusplus
191 } /* end of extern "C" */
192 #endif
194 #endif /* malloc.h */