Mercurial > hg > CbC > CbC_gcc
annotate libcpp/include/symtab.h @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | 04ced10e8804 |
children | 1830386684a0 |
rev | line source |
---|---|
0 | 1 /* Hash tables. |
131 | 2 Copyright (C) 2000-2018 Free Software Foundation, Inc. |
0 | 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 3, 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; see the file COPYING3. If not see | |
16 <http://www.gnu.org/licenses/>. */ | |
17 | |
18 #ifndef LIBCPP_SYMTAB_H | |
19 #define LIBCPP_SYMTAB_H | |
20 | |
21 #include "obstack.h" | |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
22 |
0 | 23 #ifndef GTY |
24 #define GTY(x) /* nothing */ | |
25 #endif | |
26 | |
27 /* This is what each hash table entry points to. It may be embedded | |
28 deeply within another object. */ | |
29 typedef struct ht_identifier ht_identifier; | |
67
f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
55
diff
changeset
|
30 typedef struct ht_identifier *ht_identifier_ptr; |
55
77e2b8dfacca
update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents:
0
diff
changeset
|
31 struct GTY(()) ht_identifier { |
0 | 32 const unsigned char *str; |
33 unsigned int len; | |
34 unsigned int hash_value; | |
35 }; | |
36 | |
37 #define HT_LEN(NODE) ((NODE)->len) | |
38 #define HT_STR(NODE) ((NODE)->str) | |
39 | |
111 | 40 typedef struct ht cpp_hash_table; |
0 | 41 typedef struct ht_identifier *hashnode; |
42 | |
43 enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC}; | |
44 | |
45 /* An identifier hash table for cpplib and the front ends. */ | |
46 struct ht | |
47 { | |
48 /* Identifiers are allocated from here. */ | |
49 struct obstack stack; | |
50 | |
51 hashnode *entries; | |
52 /* Call back, allocate a node. */ | |
111 | 53 hashnode (*alloc_node) (cpp_hash_table *); |
0 | 54 /* Call back, allocate something that hangs off a node like a cpp_macro. |
55 NULL means use the usual allocator. */ | |
56 void * (*alloc_subobject) (size_t); | |
57 | |
58 unsigned int nslots; /* Total slots in the entries array. */ | |
59 unsigned int nelements; /* Number of live elements. */ | |
60 | |
61 /* Link to reader, if any. For the benefit of cpplib. */ | |
62 struct cpp_reader *pfile; | |
63 | |
64 /* Table usage statistics. */ | |
65 unsigned int searches; | |
66 unsigned int collisions; | |
67 | |
68 /* Should 'entries' be freed when it is no longer needed? */ | |
69 bool entries_owned; | |
70 }; | |
71 | |
72 /* Initialize the hashtable with 2 ^ order entries. */ | |
111 | 73 extern cpp_hash_table *ht_create (unsigned int order); |
0 | 74 |
75 /* Frees all memory associated with a hash table. */ | |
111 | 76 extern void ht_destroy (cpp_hash_table *); |
0 | 77 |
111 | 78 extern hashnode ht_lookup (cpp_hash_table *, const unsigned char *, |
0 | 79 size_t, enum ht_lookup_option); |
111 | 80 extern hashnode ht_lookup_with_hash (cpp_hash_table *, const unsigned char *, |
0 | 81 size_t, unsigned int, |
82 enum ht_lookup_option); | |
83 #define HT_HASHSTEP(r, c) ((r) * 67 + ((c) - 113)); | |
84 #define HT_HASHFINISH(r, len) ((r) + (len)) | |
85 | |
86 /* For all nodes in TABLE, make a callback. The callback takes | |
87 TABLE->PFILE, the node, and a PTR, and the callback sequence stops | |
88 if the callback returns zero. */ | |
89 typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *); | |
111 | 90 extern void ht_forall (cpp_hash_table *, ht_cb, const void *); |
0 | 91 |
92 /* For all nodes in TABLE, call the callback. If the callback returns | |
93 a nonzero value, the node is removed from the table. */ | |
111 | 94 extern void ht_purge (cpp_hash_table *, ht_cb, const void *); |
0 | 95 |
96 /* Restore the hash table. */ | |
111 | 97 extern void ht_load (cpp_hash_table *ht, hashnode *entries, |
0 | 98 unsigned int nslots, unsigned int nelements, bool own); |
99 | |
100 /* Dump allocation statistics to stderr. */ | |
111 | 101 extern void ht_dump_statistics (cpp_hash_table *); |
0 | 102 |
103 #endif /* LIBCPP_SYMTAB_H */ |