xref: /dflybsd-src/contrib/gcc-4.7/gcc/alloc-pool.h (revision 04febcfb30580676d3e95f58a16c5137ee478b32)
1*e4b17023SJohn Marino /* Functions to support a pool of allocatable objects
2*e4b17023SJohn Marino    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2007
3*e4b17023SJohn Marino    Free Software Foundation, Inc.
4*e4b17023SJohn Marino    Contributed by Daniel Berlin <dan@cgsoftware.com>
5*e4b17023SJohn Marino 
6*e4b17023SJohn Marino This file is part of GCC.
7*e4b17023SJohn Marino 
8*e4b17023SJohn Marino GCC is free software; you can redistribute it and/or modify
9*e4b17023SJohn Marino it under the terms of the GNU General Public License as published by
10*e4b17023SJohn Marino the Free Software Foundation; either version 3, or (at your option)
11*e4b17023SJohn Marino any later version.
12*e4b17023SJohn Marino 
13*e4b17023SJohn Marino GCC is distributed in the hope that it will be useful,
14*e4b17023SJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
15*e4b17023SJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*e4b17023SJohn Marino GNU General Public License for more details.
17*e4b17023SJohn Marino 
18*e4b17023SJohn Marino You should have received a copy of the GNU General Public License
19*e4b17023SJohn Marino along with GCC; see the file COPYING3.  If not see
20*e4b17023SJohn Marino <http://www.gnu.org/licenses/>.  */
21*e4b17023SJohn Marino #ifndef ALLOC_POOL_H
22*e4b17023SJohn Marino #define ALLOC_POOL_H
23*e4b17023SJohn Marino 
24*e4b17023SJohn Marino typedef unsigned long ALLOC_POOL_ID_TYPE;
25*e4b17023SJohn Marino 
26*e4b17023SJohn Marino typedef struct alloc_pool_list_def
27*e4b17023SJohn Marino {
28*e4b17023SJohn Marino   struct alloc_pool_list_def *next;
29*e4b17023SJohn Marino }
30*e4b17023SJohn Marino  *alloc_pool_list;
31*e4b17023SJohn Marino 
32*e4b17023SJohn Marino typedef struct alloc_pool_def
33*e4b17023SJohn Marino {
34*e4b17023SJohn Marino   const char *name;
35*e4b17023SJohn Marino #ifdef ENABLE_CHECKING
36*e4b17023SJohn Marino   ALLOC_POOL_ID_TYPE id;
37*e4b17023SJohn Marino #endif
38*e4b17023SJohn Marino   size_t elts_per_block;
39*e4b17023SJohn Marino 
40*e4b17023SJohn Marino   /* These are the elements that have been allocated at least once and freed.  */
41*e4b17023SJohn Marino   alloc_pool_list returned_free_list;
42*e4b17023SJohn Marino 
43*e4b17023SJohn Marino   /* These are the elements that have not yet been allocated out of
44*e4b17023SJohn Marino      the last block obtained from XNEWVEC.  */
45*e4b17023SJohn Marino   char* virgin_free_list;
46*e4b17023SJohn Marino 
47*e4b17023SJohn Marino   /* The number of elements in the virgin_free_list that can be
48*e4b17023SJohn Marino      allocated before needing another block.  */
49*e4b17023SJohn Marino   size_t virgin_elts_remaining;
50*e4b17023SJohn Marino 
51*e4b17023SJohn Marino   size_t elts_allocated;
52*e4b17023SJohn Marino   size_t elts_free;
53*e4b17023SJohn Marino   size_t blocks_allocated;
54*e4b17023SJohn Marino   alloc_pool_list block_list;
55*e4b17023SJohn Marino   size_t block_size;
56*e4b17023SJohn Marino   size_t elt_size;
57*e4b17023SJohn Marino }
58*e4b17023SJohn Marino  *alloc_pool;
59*e4b17023SJohn Marino 
60*e4b17023SJohn Marino extern alloc_pool create_alloc_pool (const char *, size_t, size_t);
61*e4b17023SJohn Marino extern void free_alloc_pool (alloc_pool);
62*e4b17023SJohn Marino extern void empty_alloc_pool (alloc_pool);
63*e4b17023SJohn Marino extern void free_alloc_pool_if_empty (alloc_pool *);
64*e4b17023SJohn Marino extern void *pool_alloc (alloc_pool);
65*e4b17023SJohn Marino extern void pool_free (alloc_pool, void *);
66*e4b17023SJohn Marino extern void dump_alloc_pool_statistics (void);
67*e4b17023SJohn Marino #endif
68