2 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify it
5 under the terms of the GNU General Public License as published by the
6 Free Software Foundation; either version 2, or (at your option) any
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 #ifndef GCC_HASHTABLE_H
19 #define GCC_HASHTABLE_H
23 /* This is what each hash table entry points to. It may be embedded
24 deeply within another object. */
25 typedef struct ht_identifier ht_identifier
;
29 const unsigned char *str
;
32 #define HT_LEN(NODE) ((NODE)->len)
33 #define HT_STR(NODE) ((NODE)->str)
35 /* We want code outside cpplib, such as the compiler front-ends, to be
36 able to include this header, and to be able to link with
37 cpphashtbl.o without pulling in any other parts of cpplib. */
40 typedef struct ht hash_table
;
41 typedef struct ht_identifier
*hashnode
;
43 enum ht_lookup_option
{HT_NO_INSERT
= 0, HT_ALLOC
, HT_ALLOCED
};
45 /* An identifier hash table for cpplib and the front ends. */
48 /* Identifiers are allocated from here. */
53 hashnode (*alloc_node
) PARAMS ((hash_table
*));
55 unsigned int nslots
; /* Total slots in the entries array. */
56 unsigned int nelements
; /* Number of live elements. */
58 /* Link to reader, if any. For the benefit of cpplib. */
59 struct cpp_reader
*pfile
;
61 /* Table usage statistics. */
62 unsigned int searches
;
63 unsigned int collisions
;
66 extern void gcc_obstack_init
PARAMS ((struct obstack
*));
67 /* Initialise the hashtable with 2 ^ order entries. */
68 extern hash_table
*ht_create
PARAMS ((unsigned int order
));
69 extern hashnode ht_lookup
PARAMS ((hash_table
*, const unsigned char *,
70 unsigned int, enum ht_lookup_option
));
72 /* For all nodes in TABLE, make a callback. The callback takes
73 TABLE->PFILE, the node, and a PTR, and the callback sequence stops
74 if the callback returns zero. */
75 typedef int (*ht_cb
) PARAMS ((struct cpp_reader
*, hashnode
, const void *));
76 extern void ht_forall
PARAMS ((hash_table
*, ht_cb
, const void *));
78 /* Dump allocation statistics to stderr. */
79 extern void ht_dump_statistics
PARAMS ((hash_table
*));
81 /* Approximate positive square root of a host double. This is for
82 statistical reports, not code generation. */
83 extern double approx_sqrt
PARAMS ((double));
85 #endif /* GCC_HASHTABLE_H */