OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [sys/] [linux/] [include/] [malloc.h] - Blame information for rev 207

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 207 jeremybenn
/* 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.
4
 
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.
9
 
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.
14
 
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.  */
19
 
20
#ifndef _MALLOC_H
21
#define _MALLOC_H 1
22
 
23
#include <features.h>
24
 
25
/*
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.
29
 
30
  VERSION 2.6.4-pt Wed Dec  4 00:35:54 MET 1996
31
 
32
  This work is mainly derived from malloc-2.6.4 by Doug Lea
33
  <dl@cs.oswego.edu>, which is available from:
34
 
35
                 ftp://g.oswego.edu/pub/misc/malloc.c
36
 
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'.
41
*/
42
 
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
53
 
54
#ifdef _LIBC
55
/* Used by GNU libc internals. */
56
# define __malloc_size_t size_t
57
# define __malloc_ptrdiff_t ptrdiff_t
58
#elif !defined __attribute_malloc__
59
# define __attribute_malloc__
60
#endif
61
 
62
#ifdef __GNUC__
63
 
64
/* GCC can always grok prototypes.  For C++ programs we add throw()
65
   to help it optimize the function calls.  But this works only with
66
   gcc 2.8.x and egcs.  */
67
# if defined __cplusplus && (__GNUC__ >= 3 || __GNUC_MINOR__ >= 8)
68
#  define __THROW       throw ()
69
# else
70
#  define __THROW
71
# endif
72
# define __MALLOC_P(args)       args __THROW
73
/* This macro will be used for functions which might take C++ callback
74
   functions.  */
75
# define __MALLOC_PMT(args)     args
76
 
77
#else   /* Not GCC.  */
78
 
79
# define __THROW
80
 
81
# if (defined __STDC__ && __STDC__) || defined __cplusplus
82
 
83
#  define __MALLOC_P(args)      args
84
#  define __MALLOC_PMT(args)    args
85
 
86
# else  /* Not ANSI C or C++.  */
87
 
88
#  define __MALLOC_P(args)      ()      /* No prototypes.  */
89
#  define __MALLOC_PMT(args)    ()
90
 
91
# endif /* ANSI C or C++.  */
92
 
93
#endif  /* GCC.  */
94
 
95
#ifndef NULL
96
# ifdef __cplusplus
97
#  define NULL  0
98
# else
99
#  define NULL  ((__malloc_ptr_t) 0)
100
# endif
101
#endif
102
 
103
#ifdef __cplusplus
104
extern "C" {
105
#endif
106
 
107
struct _reent;
108
 
109
/* Nonzero if the malloc is already initialized.  */
110
#ifdef _LIBC
111
/* In the GNU libc we rename the global variable
112
   `__malloc_initialized' to `__libc_malloc_initialized'.  */
113
# define __malloc_initialized __libc_malloc_initialized
114
#endif
115
extern int __malloc_initialized;
116
 
117
/* Initialize global configuration.  Not needed with GNU libc. */
118
#ifndef __GLIBC__
119
extern void ptmalloc_init __MALLOC_P ((void));
120
#endif
121
 
122
/* Allocate SIZE bytes of memory.  */
123
extern __malloc_ptr_t malloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
124
extern __malloc_ptr_t _malloc_r __MALLOC_P ((struct _reent * __r, size_t __size)) __attribute_malloc__;
125
 
126
/* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
127
extern __malloc_ptr_t calloc __MALLOC_P ((size_t __nmemb, size_t __size))
128
       __attribute_malloc__;
129
extern __malloc_ptr_t _calloc_r __MALLOC_P ((struct _reent * __r,
130
                                             size_t __nmemb, size_t __size))
131
       __attribute_malloc__;
132
 
133
/* Re-allocate the previously allocated block in __ptr, making the new
134
   block SIZE bytes long.  */
135
extern __malloc_ptr_t realloc __MALLOC_P ((__malloc_ptr_t __ptr,
136
                                           size_t __size))
137
       __attribute_malloc__;
138
extern __malloc_ptr_t _realloc_r __MALLOC_P ((struct _reent * __r,
139
                                              __malloc_ptr_t __ptr,
140
                                              size_t __size))
141
       __attribute_malloc__;
142
 
143
/* Free a block allocated by `malloc', `realloc' or `calloc'.  */
144
extern void free __MALLOC_P ((__malloc_ptr_t __ptr));
145
extern void _free_r __MALLOC_P ((struct _reent * __r, __malloc_ptr_t __ptr));
146
 
147
/* Free a block allocated by `calloc'. */
148
extern void cfree __MALLOC_P ((__malloc_ptr_t __ptr));
149
 
150
/* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
151
extern __malloc_ptr_t memalign __MALLOC_P ((size_t __alignment, size_t __size));
152
extern __malloc_ptr_t _memalign_r __MALLOC_P ((struct _reent *__r,
153
                                               size_t __alignment,
154
                                               size_t __size));
155
 
156
/* Allocate SIZE bytes on a page boundary.  */
157
extern __malloc_ptr_t valloc __MALLOC_P ((size_t __size)) __attribute_malloc__;
158
extern __malloc_ptr_t _valloc_r __MALLOC_P ((struct _reent *__r,
159
                                             size_t __size))
160
       __attribute_malloc__;
161
 
162
/* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
163
   __size to nearest pagesize. */
164
extern __malloc_ptr_t  pvalloc __MALLOC_P ((size_t __size))
165
       __attribute_malloc__;
166
extern __malloc_ptr_t  _pvalloc_r __MALLOC_P ((struct _reent *__r,
167
                                               size_t __size))
168
       __attribute_malloc__;
169
 
170
/* Underlying allocation function; successive calls should return
171
   contiguous pieces of memory.  */
172
extern __malloc_ptr_t (*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
173
 
174
/* Default value of `__morecore'.  */
175
extern __malloc_ptr_t __default_morecore __MALLOC_P ((ptrdiff_t __size))
176
       __attribute_malloc__;
177
 
178
/* SVID2/XPG mallinfo structure */
179
struct mallinfo {
180
  int arena;    /* total space allocated from system */
181
  int ordblks;  /* number of non-inuse chunks */
182
  int smblks;   /* unused -- always zero */
183
  int hblks;    /* number of mmapped regions */
184
  int hblkhd;   /* total space in mmapped regions */
185
  int usmblks;  /* unused -- always zero */
186
  int fsmblks;  /* unused -- always zero */
187
  int uordblks; /* total allocated space */
188
  int fordblks; /* total non-inuse space */
189
  int keepcost; /* top-most, releasable (via malloc_trim) space */
190
};
191
 
192
/* Returns a copy of the updated current mallinfo. */
193
extern struct mallinfo mallinfo __MALLOC_P ((void));
194
extern struct mallinfo _mallinfo_r __MALLOC_P ((struct _reent *__r));
195
 
196
/* SVID2/XPG mallopt options */
197
#ifndef M_MXFAST
198
# define M_MXFAST  1    /* UNUSED in this malloc */
199
#endif
200
#ifndef M_NLBLKS
201
# define M_NLBLKS  2    /* UNUSED in this malloc */
202
#endif
203
#ifndef M_GRAIN
204
# define M_GRAIN   3    /* UNUSED in this malloc */
205
#endif
206
#ifndef M_KEEP
207
# define M_KEEP    4    /* UNUSED in this malloc */
208
#endif
209
 
210
/* mallopt options that actually do something */
211
#define M_TRIM_THRESHOLD    -1
212
#define M_TOP_PAD           -2
213
#define M_MMAP_THRESHOLD    -3
214
#define M_MMAP_MAX          -4
215
#define M_CHECK_ACTION      -5
216
 
217
/* General SVID/XPG interface to tunable parameters. */
218
extern int mallopt __MALLOC_P ((int __param, int __val));
219
extern int _mallopt_r __MALLOC_P ((struct _reent *__r, int __param, int __val));
220
 
221
/* Release all but __pad bytes of freed top-most memory back to the
222
   system. Return 1 if successful, else 0. */
223
extern int malloc_trim __MALLOC_P ((size_t __pad));
224
 
225
/* Report the number of usable allocated bytes associated with allocated
226
   chunk __ptr. */
227
extern size_t malloc_usable_size __MALLOC_P ((__malloc_ptr_t __ptr));
228
 
229
/* Prints brief summary statistics on stderr. */
230
extern void malloc_stats __MALLOC_P ((void));
231
extern void _malloc_stats_r __MALLOC_P ((struct _reent *__r));
232
 
233
/* Record the state of all malloc variables in an opaque data structure. */
234
extern __malloc_ptr_t malloc_get_state __MALLOC_P ((void));
235
 
236
/* Restore the state of all malloc variables from data obtained with
237
   malloc_get_state(). */
238
extern int malloc_set_state __MALLOC_P ((__malloc_ptr_t __ptr));
239
 
240
#if defined __GLIBC__ || defined MALLOC_HOOKS
241
/* Called once when malloc is initialized; redefining this variable in
242
   the application provides the preferred way to set up the hook
243
   pointers. */
244
extern void (*__malloc_initialize_hook) __MALLOC_PMT ((void));
245
/* Hooks for debugging and user-defined versions. */
246
extern void (*__free_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr,
247
                                        __const __malloc_ptr_t));
248
extern __malloc_ptr_t (*__malloc_hook) __MALLOC_PMT ((size_t __size,
249
                                                    __const __malloc_ptr_t));
250
extern __malloc_ptr_t (*__realloc_hook) __MALLOC_PMT ((__malloc_ptr_t __ptr,
251
                                                     size_t __size,
252
                                                     __const __malloc_ptr_t));
253
extern __malloc_ptr_t (*__memalign_hook) __MALLOC_PMT ((size_t __alignment,
254
                                                      size_t __size,
255
                                                      __const __malloc_ptr_t));
256
extern void (*__after_morecore_hook) __MALLOC_PMT ((void));
257
 
258
/* Activate a standard set of debugging hooks. */
259
extern void __malloc_check_init __MALLOC_P ((void));
260
#endif
261
 
262
#ifdef __cplusplus
263
}; /* end of extern "C" */
264
#endif
265
 
266
#endif /* malloc.h */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.