1 /* Prototypes and definition for malloc implementation.
2 Copyright (C) 1996 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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
24 `ptmalloc', a malloc implementation for multiple threads without
25 lock contention, by Wolfram Gloger <wmglo@dent.med.uni-muenchen.de>.
26 See the files `ptmalloc.c' or `COPYRIGHT' for copying conditions.
28 VERSION 2.6.4-pt Wed Dec 4 00:35:54 MET 1996
30 This work is mainly derived from malloc-2.6.4 by Doug Lea
31 <dl@cs.oswego.edu>, which is available from:
33 ftp://g.oswego.edu/pub/misc/malloc.c
35 This trimmed-down header file only provides function prototypes and
36 the exported data structures. For more detailed function
37 descriptions and compile-time options, see the source file
41 #if defined(__STDC__) || defined (__cplusplus)
43 #define __malloc_ptr_t void *
46 #define size_t unsigned int
49 #define __malloc_ptr_t char *
53 /* Used by GNU libc internals. */
54 #define __malloc_size_t size_t
55 #define __malloc_ptrdiff_t ptrdiff_t
58 #if defined (__STDC__) || defined (__cplusplus) || defined (__GNUC__)
59 #define __MALLOC_P(args) args
61 #define __MALLOC_P(args) ()
68 #define NULL ((__malloc_ptr_t) 0)
76 /* Initialize global configuration. Not needed with GNU libc. */
78 extern void ptmalloc_init
__MALLOC_P ((void));
81 /* Allocate SIZE bytes of memory. */
82 extern __malloc_ptr_t malloc
__MALLOC_P ((size_t __size
));
84 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
85 extern __malloc_ptr_t calloc
__MALLOC_P ((size_t __nmemb
, size_t __size
));
87 /* Re-allocate the previously allocated block in __ptr, making the new
88 block SIZE bytes long. */
89 extern __malloc_ptr_t realloc
__MALLOC_P ((__malloc_ptr_t __ptr
, size_t __size
));
91 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
92 extern void free
__MALLOC_P ((__malloc_ptr_t __ptr
));
94 /* Free a block allocated by `calloc'. */
95 extern void cfree
__MALLOC_P ((__malloc_ptr_t __ptr
));
97 /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
98 extern __malloc_ptr_t memalign
__MALLOC_P ((size_t __alignment
, size_t __size
));
100 /* Allocate SIZE bytes on a page boundary. */
101 extern __malloc_ptr_t valloc
__MALLOC_P ((size_t __size
));
103 /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
104 __size to nearest pagesize. */
105 extern __malloc_ptr_t pvalloc
__MALLOC_P ((size_t __size
));
107 /* Underlying allocation function; successive calls should return
108 contiguous pieces of memory. */
109 extern __malloc_ptr_t (*__morecore
) __MALLOC_P ((ptrdiff_t __size
));
111 /* Default value of `__morecore'. */
112 extern __malloc_ptr_t __default_morecore
__MALLOC_P ((ptrdiff_t __size
));
114 /* SVID2/XPG mallinfo structure */
116 int arena
; /* total space allocated from system */
117 int ordblks
; /* number of non-inuse chunks */
118 int smblks
; /* unused -- always zero */
119 int hblks
; /* number of mmapped regions */
120 int hblkhd
; /* total space in mmapped regions */
121 int usmblks
; /* unused -- always zero */
122 int fsmblks
; /* unused -- always zero */
123 int uordblks
; /* total allocated space */
124 int fordblks
; /* total non-inuse space */
125 int keepcost
; /* top-most, releasable (via malloc_trim) space */
128 /* Returns a copy of the updated current mallinfo. */
129 extern struct mallinfo mallinfo
__MALLOC_P ((void));
131 /* SVID2/XPG mallopt options */
133 #define M_MXFAST 1 /* UNUSED in this malloc */
136 #define M_NLBLKS 2 /* UNUSED in this malloc */
139 #define M_GRAIN 3 /* UNUSED in this malloc */
142 #define M_KEEP 4 /* UNUSED in this malloc */
145 /* mallopt options that actually do something */
146 #define M_TRIM_THRESHOLD -1
148 #define M_MMAP_THRESHOLD -3
149 #define M_MMAP_MAX -4
150 #define M_CHECK_ACTION -5
152 /* General SVID/XPG interface to tunable parameters. */
153 extern int mallopt
__MALLOC_P ((int __param
, int __val
));
155 /* Release all but __pad bytes of freed top-most memory back to the
156 system. Return 1 if successful, else 0. */
157 extern int malloc_trim
__MALLOC_P ((size_t __pad
));
159 /* Report the number of usable allocated bytes associated with allocated
161 extern size_t malloc_usable_size
__MALLOC_P ((__malloc_ptr_t __ptr
));
163 /* Prints brief summary statistics on stderr. */
164 extern void malloc_stats
__MALLOC_P ((void));
166 #if defined(__GLIBC__) || defined(MALLOC_HOOKS)
168 /* Hooks for debugging versions. */
169 extern void (*__malloc_initialize_hook
) __MALLOC_P ((void));
170 extern void (*__free_hook
) __MALLOC_P ((__malloc_ptr_t __ptr
));
171 extern __malloc_ptr_t (*__malloc_hook
) __MALLOC_P ((size_t __size
));
172 extern __malloc_ptr_t (*__realloc_hook
) __MALLOC_P ((__malloc_ptr_t __ptr
,
174 extern __malloc_ptr_t (*__memalign_hook
) __MALLOC_P ((size_t __size
,
175 size_t __alignment
));
177 /* Activate a standard set of debugging hooks. */
178 extern void malloc_check_init
__MALLOC_P ((void));
183 }; /* end of extern "C" */
186 #endif /* !defined(_MALLOC_H) */