* except.c (expand_start_catch_block): We only need the rethrow
[official-gcc.git] / gcc / hash.h
blob388532abd655435673a43639a97eb0f976b0adc5
1 /* CYGNUS LOCAL: whole file jason */
2 /* Header file for generic hash table support.
3 Copyright (C) 1993, 94 Free Software Foundation, Inc.
4 Written by Steve Chamberlain <sac@cygnus.com>
6 This file was lifted from BFD, the Binary File Descriptor library.
8 This program 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 of the License, or
11 (at your option) any later version.
13 This program 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.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
22 #ifdef IN_GCC
24 /* Add prototype support. */
25 #ifndef PROTO
26 #if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)
27 #define PROTO(ARGS) ARGS
28 #else
29 #define PROTO(ARGS) ()
30 #endif
31 #endif
33 #define PARAMS(ARGS) PROTO(ARGS)
35 #ifdef __STDC__
36 #define PTR void *
37 #else
38 #ifndef const
39 #define const
40 #endif
41 #define PTR char *
42 #endif
44 #else /* ! IN_GCC */
45 #include <ansidecl.h>
46 #endif /* IN_GCC */
48 #include "obstack.h"
50 typedef enum {false, true} boolean;
52 /* Hash table routines. There is no way to free up a hash table. */
54 /* An element in the hash table. Most uses will actually use a larger
55 structure, and an instance of this will be the first field. */
57 struct hash_entry
59 /* Next entry for this hash code. */
60 struct hash_entry *next;
61 /* String being hashed. */
62 const char *string;
63 /* Hash code. This is the full hash code, not the index into the
64 table. */
65 unsigned long hash;
68 /* A hash table. */
70 struct hash_table
72 /* The hash array. */
73 struct hash_entry **table;
74 /* The number of slots in the hash table. */
75 unsigned int size;
76 /* A function used to create new elements in the hash table. The
77 first entry is itself a pointer to an element. When this
78 function is first invoked, this pointer will be NULL. However,
79 having the pointer permits a hierarchy of method functions to be
80 built each of which calls the function in the superclass. Thus
81 each function should be written to allocate a new block of memory
82 only if the argument is NULL. */
83 struct hash_entry *(*newfunc) PARAMS ((struct hash_entry *,
84 struct hash_table *,
85 const char *));
86 /* An obstack for this hash table. */
87 struct obstack memory;
90 /* Initialize a hash table. */
91 extern boolean hash_table_init
92 PARAMS ((struct hash_table *,
93 struct hash_entry *(*) (struct hash_entry *,
94 struct hash_table *,
95 const char *)));
97 /* Initialize a hash table specifying a size. */
98 extern boolean hash_table_init_n
99 PARAMS ((struct hash_table *,
100 struct hash_entry *(*) (struct hash_entry *,
101 struct hash_table *,
102 const char *),
103 unsigned int size));
105 /* Free up a hash table. */
106 extern void hash_table_free PARAMS ((struct hash_table *));
108 /* Look up a string in a hash table. If CREATE is true, a new entry
109 will be created for this string if one does not already exist. The
110 COPY argument must be true if this routine should copy the string
111 into newly allocated memory when adding an entry. */
112 extern struct hash_entry *hash_lookup
113 PARAMS ((struct hash_table *, const char *, boolean create,
114 boolean copy));
116 /* Base method for creating a hash table entry. */
117 extern struct hash_entry *hash_newfunc
118 PARAMS ((struct hash_entry *, struct hash_table *,
119 const char *));
121 /* Grab some space for a hash table entry. */
122 extern PTR hash_allocate PARAMS ((struct hash_table *,
123 unsigned int));
125 /* Traverse a hash table in a random order, calling a function on each
126 element. If the function returns false, the traversal stops. The
127 INFO argument is passed to the function. */
128 extern void hash_traverse PARAMS ((struct hash_table *,
129 boolean (*) (struct hash_entry *,
130 PTR),
131 PTR info));