OSDN Git Service

* real.h (ieee_extended_intel_96_round_53_format): New.
[pf3gnuchains/gcc-fork.git] / gcc / hashtable.h
1 /* Hash tables.
2    Copyright (C) 2000, 2001 Free Software Foundation, Inc.
3
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
7 later version.
8
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.
13
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.  */
17
18 #ifndef GCC_HASHTABLE_H
19 #define GCC_HASHTABLE_H
20
21 #include "obstack.h"
22
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;
26 struct ht_identifier GTY(())
27 {
28   const unsigned char *str;
29   unsigned int len;
30   unsigned int hash_value;
31 };
32
33 #define HT_LEN(NODE) ((NODE)->len)
34 #define HT_STR(NODE) ((NODE)->str)
35
36 typedef struct ht hash_table;
37 typedef struct ht_identifier *hashnode;
38
39 enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC, HT_ALLOCED};
40
41 /* An identifier hash table for cpplib and the front ends.  */
42 struct ht
43 {
44   /* Identifiers are allocated from here.  */
45   struct obstack stack;
46
47   hashnode *entries;
48   /* Call back.  */
49   hashnode (*alloc_node) PARAMS ((hash_table *));
50
51   unsigned int nslots;          /* Total slots in the entries array.  */
52   unsigned int nelements;       /* Number of live elements.  */
53
54   /* Link to reader, if any.  For the benefit of cpplib.  */
55   struct cpp_reader *pfile;
56
57   /* Table usage statistics.  */
58   unsigned int searches;
59   unsigned int collisions;
60 };
61
62 /* Initialize the hashtable with 2 ^ order entries.  */
63 extern hash_table *ht_create PARAMS ((unsigned int order));
64
65 /* Frees all memory associated with a hash table.  */
66 extern void ht_destroy PARAMS ((hash_table *));
67
68 extern hashnode ht_lookup PARAMS ((hash_table *, const unsigned char *,
69                                    unsigned int, enum ht_lookup_option));
70
71 /* For all nodes in TABLE, make a callback.  The callback takes
72    TABLE->PFILE, the node, and a PTR, and the callback sequence stops
73    if the callback returns zero.  */
74 typedef int (*ht_cb) PARAMS ((struct cpp_reader *, hashnode, const void *));
75 extern void ht_forall PARAMS ((hash_table *, ht_cb, const void *));
76
77 /* Dump allocation statistics to stderr.  */
78 extern void ht_dump_statistics PARAMS ((hash_table *));
79
80 /* Approximate positive square root of a host double.  This is for
81    statistical reports, not code generation.  */
82 extern double approx_sqrt PARAMS ((double));
83
84 #endif /* GCC_HASHTABLE_H */