OSDN Git Service

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