]> git.ipfire.org Git - thirdparty/gcc.git/blame - libcpp/include/symtab.h
v850.c (v850_use_dfa_pipeline_interface): New.
[thirdparty/gcc.git] / libcpp / include / symtab.h
CommitLineData
2a967f3d 1/* Hash tables.
b453c95f 2 Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
2a967f3d
NB
3
4This program is free software; you can redistribute it and/or modify it
5under the terms of the GNU General Public License as published by the
6Free Software Foundation; either version 2, or (at your option) any
7later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
16Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
17
4f4e53dd
PB
18#ifndef LIBCPP_SYMTAB_H
19#define LIBCPP_SYMTAB_H
2a967f3d
NB
20
21#include "obstack.h"
43839642 22#define GTY(x) /* nothing */
2a967f3d
NB
23
24/* This is what each hash table entry points to. It may be embedded
25 deeply within another object. */
26typedef struct ht_identifier ht_identifier;
e2500fed 27struct ht_identifier GTY(())
2a967f3d 28{
2a967f3d 29 const unsigned char *str;
4977bab6 30 unsigned int len;
5e0c54e5 31 unsigned int hash_value;
2a967f3d
NB
32};
33
34#define HT_LEN(NODE) ((NODE)->len)
35#define HT_STR(NODE) ((NODE)->str)
36
2a967f3d
NB
37typedef struct ht hash_table;
38typedef struct ht_identifier *hashnode;
39
40enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC, HT_ALLOCED};
41
42/* An identifier hash table for cpplib and the front ends. */
43struct ht
44{
45 /* Identifiers are allocated from here. */
46 struct obstack stack;
47
48 hashnode *entries;
49 /* Call back. */
1d088dee 50 hashnode (*alloc_node) (hash_table *);
2a967f3d
NB
51
52 unsigned int nslots; /* Total slots in the entries array. */
53 unsigned int nelements; /* Number of live elements. */
54
55 /* Link to reader, if any. For the benefit of cpplib. */
56 struct cpp_reader *pfile;
57
58 /* Table usage statistics. */
59 unsigned int searches;
60 unsigned int collisions;
b453c95f
GK
61
62 /* Should 'entries' be freed when it is no longer needed? */
63 bool entries_owned;
2a967f3d
NB
64};
65
4912a07c 66/* Initialize the hashtable with 2 ^ order entries. */
1d088dee 67extern hash_table *ht_create (unsigned int order);
bef985f3
NB
68
69/* Frees all memory associated with a hash table. */
1d088dee 70extern void ht_destroy (hash_table *);
bef985f3 71
1d088dee 72extern hashnode ht_lookup (hash_table *, const unsigned char *,
7bb3fbbb 73 size_t, enum ht_lookup_option);
2a967f3d
NB
74
75/* For all nodes in TABLE, make a callback. The callback takes
76 TABLE->PFILE, the node, and a PTR, and the callback sequence stops
77 if the callback returns zero. */
1d088dee
AJ
78typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
79extern void ht_forall (hash_table *, ht_cb, const void *);
2a967f3d 80
b453c95f
GK
81/* Restore the hash table. */
82extern void ht_load (hash_table *ht, hashnode *entries,
83 unsigned int nslots, unsigned int nelements, bool own);
84
2a967f3d 85/* Dump allocation statistics to stderr. */
1d088dee 86extern void ht_dump_statistics (hash_table *);
2a967f3d 87
4f4e53dd 88#endif /* LIBCPP_SYMTAB_H */