PowerPC: Define AT_HWCAP2 bits and AT_HWCAP2 handling for POWER8.
[glibc.git] / malloc / malloc.h
blob02b28c78e852d7f6541d657fe58ade3ec8300257
1 /* Prototypes and definition for malloc implementation.
2 Copyright (C) 1996,1997,1999,2000,2002-2004,2005,2007,2009,2011,2012
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef _MALLOC_H
21 #define _MALLOC_H 1
23 #include <features.h>
24 #include <stddef.h>
25 #include <stdio.h>
26 # define __malloc_ptr_t void *
28 /* Used by GNU libc internals. */
29 #define __malloc_size_t size_t
30 #define __malloc_ptrdiff_t ptrdiff_t
32 #ifdef __GNUC__
34 # define __MALLOC_P(args) args __THROW
35 /* This macro will be used for functions which might take C++ callback
36 functions. */
37 # define __MALLOC_PMT(args) args
39 # ifdef _LIBC
40 # define __MALLOC_HOOK_VOLATILE
41 # define __MALLOC_DEPRECATED
42 # else
43 # define __MALLOC_HOOK_VOLATILE volatile
44 # define __MALLOC_DEPRECATED __attribute_deprecated__
45 # endif
47 #else /* Not GCC. */
49 # define __MALLOC_P(args) args
50 # define __MALLOC_PMT(args) args
51 # define __MALLOC_HOOK_VOLATILE
52 # define __MALLOC_DEPRECATED __attribute_deprecated__
54 #endif /* GCC. */
57 __BEGIN_DECLS
59 /* Allocate SIZE bytes of memory. */
60 extern void *malloc (size_t __size) __THROW __attribute_malloc__ __wur;
62 /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0. */
63 extern void *calloc (size_t __nmemb, size_t __size)
64 __THROW __attribute_malloc__ __wur;
66 /* Re-allocate the previously allocated block in __ptr, making the new
67 block SIZE bytes long. */
68 /* __attribute_malloc__ is not used, because if realloc returns
69 the same pointer that was passed to it, aliasing needs to be allowed
70 between objects pointed by the old and new pointers. */
71 extern void *realloc (void *__ptr, size_t __size)
72 __THROW __attribute_warn_unused_result__;
74 /* Free a block allocated by `malloc', `realloc' or `calloc'. */
75 extern void free (void *__ptr) __THROW;
77 /* Free a block allocated by `calloc'. */
78 extern void cfree (void *__ptr) __THROW;
80 /* Allocate SIZE bytes allocated to ALIGNMENT bytes. */
81 extern void *memalign (size_t __alignment, size_t __size)
82 __THROW __attribute_malloc__ __wur;
84 /* Allocate SIZE bytes on a page boundary. */
85 extern void *valloc (size_t __size) __THROW __attribute_malloc__ __wur;
87 /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
88 __size to nearest pagesize. */
89 extern void * pvalloc (size_t __size) __THROW __attribute_malloc__ __wur;
91 /* Underlying allocation function; successive calls should return
92 contiguous pieces of memory. */
93 extern void *(*__morecore) (ptrdiff_t __size);
95 /* Default value of `__morecore'. */
96 extern void *__default_morecore (ptrdiff_t __size)
97 __THROW __attribute_malloc__;
99 /* SVID2/XPG mallinfo structure */
101 struct mallinfo
103 int arena; /* non-mmapped space allocated from system */
104 int ordblks; /* number of free chunks */
105 int smblks; /* number of fastbin blocks */
106 int hblks; /* number of mmapped regions */
107 int hblkhd; /* space in mmapped regions */
108 int usmblks; /* maximum total allocated space */
109 int fsmblks; /* space available in freed fastbin blocks */
110 int uordblks; /* total allocated space */
111 int fordblks; /* total free space */
112 int keepcost; /* top-most, releasable (via malloc_trim) space */
115 /* Returns a copy of the updated current mallinfo. */
116 extern struct mallinfo mallinfo (void) __THROW;
118 /* SVID2/XPG mallopt options */
119 #ifndef M_MXFAST
120 # define M_MXFAST 1 /* maximum request size for "fastbins" */
121 #endif
122 #ifndef M_NLBLKS
123 # define M_NLBLKS 2 /* UNUSED in this malloc */
124 #endif
125 #ifndef M_GRAIN
126 # define M_GRAIN 3 /* UNUSED in this malloc */
127 #endif
128 #ifndef M_KEEP
129 # define M_KEEP 4 /* UNUSED in this malloc */
130 #endif
132 /* mallopt options that actually do something */
133 #define M_TRIM_THRESHOLD -1
134 #define M_TOP_PAD -2
135 #define M_MMAP_THRESHOLD -3
136 #define M_MMAP_MAX -4
137 #define M_CHECK_ACTION -5
138 #define M_PERTURB -6
139 #define M_ARENA_TEST -7
140 #define M_ARENA_MAX -8
142 /* General SVID/XPG interface to tunable parameters. */
143 extern int mallopt (int __param, int __val) __THROW;
145 /* Release all but __pad bytes of freed top-most memory back to the
146 system. Return 1 if successful, else 0. */
147 extern int malloc_trim (size_t __pad) __THROW;
149 /* Report the number of usable allocated bytes associated with allocated
150 chunk __ptr. */
151 extern size_t malloc_usable_size (void *__ptr) __THROW;
153 /* Prints brief summary statistics on stderr. */
154 extern void malloc_stats (void) __THROW;
156 /* Output information about state of allocator to stream FP. */
157 extern int malloc_info (int __options, FILE *__fp) __THROW;
159 /* Record the state of all malloc variables in an opaque data structure. */
160 extern void *malloc_get_state (void) __THROW;
162 /* Restore the state of all malloc variables from data obtained with
163 malloc_get_state(). */
164 extern int malloc_set_state (void *__ptr) __THROW;
166 /* Called once when malloc is initialized; redefining this variable in
167 the application provides the preferred way to set up the hook
168 pointers. */
169 extern void (*__MALLOC_HOOK_VOLATILE __malloc_initialize_hook) (void)
170 __MALLOC_DEPRECATED;
171 /* Hooks for debugging and user-defined versions. */
172 extern void (*__MALLOC_HOOK_VOLATILE __free_hook) (void *__ptr,
173 const __malloc_ptr_t)
174 __MALLOC_DEPRECATED;
175 extern void *(*__MALLOC_HOOK_VOLATILE __malloc_hook) (size_t __size,
176 const __malloc_ptr_t)
177 __MALLOC_DEPRECATED;
178 extern void *(*__MALLOC_HOOK_VOLATILE __realloc_hook) (void *__ptr,
179 size_t __size,
180 const __malloc_ptr_t)
181 __MALLOC_DEPRECATED;
182 extern void *(*__MALLOC_HOOK_VOLATILE __memalign_hook) (size_t __alignment,
183 size_t __size,
184 const __malloc_ptr_t)
185 __MALLOC_DEPRECATED;
186 extern void (*__MALLOC_HOOK_VOLATILE __after_morecore_hook) (void);
188 /* Activate a standard set of debugging hooks. */
189 extern void __malloc_check_init (void) __THROW __MALLOC_DEPRECATED;
192 __END_DECLS
194 #endif /* malloc.h */