Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- 02111-1307 USA. */
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#ifndef _MALLOC_H
#define _MALLOC_H 1
/* GCC can always grok prototypes. For C++ programs we add throw()
to help it optimize the function calls. But this works only with
gcc 2.8.x and egcs. */
+#ifndef __THROW
# if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8)
# define __THROW throw ()
# else
# define __THROW
# endif
+#endif
# define __MALLOC_P(args) args __THROW
/* This macro will be used for functions which might take C++ callback
functions. */
extern "C" {
#endif
-/* Nonzero if the malloc is already initialized. */
-#ifdef _LIBC
-/* In the GNU libc we rename the global variable
- `__malloc_initialized' to `__libc_malloc_initialized'. */
-# define __malloc_initialized __libc_malloc_initialized
-#endif
-extern int __malloc_initialized;
-
-/* Initialize global configuration. Not needed with GNU libc. */
-#ifndef __GLIBC__
-extern void ptmalloc_init __MALLOC_P ((void));
-#endif
-
/* Allocate SIZE bytes of memory. */
extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
/* Free a block allocated by `malloc', `realloc' or `calloc'. */
extern void free __MALLOC_P ((__malloc_ptr_t __ptr));
-/* Free a block allocated by `calloc'. */
-extern void cfree __MALLOC_P ((__malloc_ptr_t __ptr));
-
/* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size));
+libc_hidden_proto(memalign)
+#ifdef __UCLIBC_SUSV2_LEGACY__
/* Allocate SIZE bytes on a page boundary. */
extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
+#endif
-/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
- __size to nearest pagesize. */
-extern __malloc_ptr_t pvalloc __MALLOC_P ((size_t __size))
- __attribute_malloc__;
-
-/* Underlying allocation function; successive calls should return
- contiguous pieces of memory. */
-extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
-
-/* Default value of `__morecore'. */
-extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size))
- __attribute_malloc__;
+#ifdef __MALLOC_STANDARD__
/* SVID2/XPG mallinfo structure */
struct mallinfo {
/* Returns a copy of the updated current mallinfo. */
extern struct mallinfo mallinfo __MALLOC_P ((void));
+libc_hidden_proto(mallinfo)
+
+/* Release all but __pad bytes of freed top-most memory back to the
+ system. Return 1 if successful, else 0. */
+extern int malloc_trim(size_t pad);
+
+#include <stdio.h>
+/* Prints brief summary statistics to the specified file.
+ * Writes to stderr if file is NULL. */
+extern void malloc_stats(FILE *file);
/* SVID2/XPG mallopt options */
#ifndef M_MXFAST
#define M_MMAP_THRESHOLD -3
#define M_MMAP_MAX -4
#define M_CHECK_ACTION -5
+#define M_PERTURB -6
/* General SVID/XPG interface to tunable parameters. */
extern int mallopt __MALLOC_P ((int __param, int __val));
-/* Release all but __pad bytes of freed top-most memory back to the
- system. Return 1 if successful, else 0. */
-extern int malloc_trim __MALLOC_P ((size_t __pad));
-
-/* Report the number of usable allocated bytes associated with allocated
- chunk __ptr. */
-extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr));
-
-/* Prints brief summary statistics on stderr. */
-extern void malloc_stats __MALLOC_P ((void));
-
-/* Record the state of all malloc variables in an opaque data structure. */
-extern __malloc_ptr_t malloc_get_state __MALLOC_P ((void));
-
-/* Restore the state of all malloc variables from data obtained with
- malloc_get_state(). */
-extern int malloc_set_state __MALLOC_P ((__malloc_ptr_t __ptr));
-
-#if defined __GLIBC__ || defined MALLOC_HOOKS
-/* Called once when malloc is initialized; redefining this variable in
- the application provides the preferred way to set up the hook
- pointers. */
-extern void (*__malloc_initialize_hook) __MALLOC_PMT ((void));
-/* Hooks for debugging and user-defined versions. */
-extern void (*__free_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr,
- __const __malloc_ptr_t));
-extern __malloc_ptr_t (*__malloc_hook) __MALLOC_PMT ((size_t __size,
- __const __malloc_ptr_t));
-extern __malloc_ptr_t (*__realloc_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr,
- size_t __size,
- __const __malloc_ptr_t));
-extern __malloc_ptr_t (*__memalign_hook) __MALLOC_PMT ((size_t __alignment,
- size_t __size,
- __const __malloc_ptr_t));
-extern void (*__after_morecore_hook) __MALLOC_PMT ((void));
-
-/* Activate a standard set of debugging hooks. */
-extern void __malloc_check_init __MALLOC_P ((void));
-#endif
+#endif /* __MALLOC_STANDARD__ */
+
+/* uClibc may use malloc internally in situations where user can not be
+ * notified about out-of-memory condition. In this situation uClibc will
+ * call __uc_malloc_failed if it is non-NULL, and retry allocation
+ * if it returns. If __uc_malloc_failed is NULL, uclibc will _exit(1).
+ * NB: do not use stdio in __uc_malloc_failed handler! */
+extern void *__uc_malloc(size_t size);
+libc_hidden_proto(__uc_malloc)
+extern void (*__uc_malloc_failed)(size_t size);
+libc_hidden_proto(__uc_malloc_failed)
#ifdef __cplusplus
-}; /* end of extern "C" */
+} /* end of extern "C" */
#endif
#endif /* malloc.h */