00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef LIBCPP_SYMTAB_H
00019 #define LIBCPP_SYMTAB_H
00020
00021 #include "obstack.h"
00022 #define GTY(x)
00023
00024
00025
00026 typedef struct ht_identifier ht_identifier;
00027 struct ht_identifier GTY(())
00028 {
00029 const unsigned char *str;
00030 unsigned int len;
00031 unsigned int hash_value;
00032 };
00033
00034 #define HT_LEN(NODE) ((NODE)->len)
00035 #define HT_STR(NODE) ((NODE)->str)
00036
00037 typedef struct ht hash_table;
00038 typedef struct ht_identifier *hashnode;
00039
00040 enum ht_lookup_option {HT_NO_INSERT = 0, HT_ALLOC, HT_ALLOCED};
00041
00042
00043 struct ht
00044 {
00045
00046 struct obstack stack;
00047
00048 hashnode *entries;
00049
00050 hashnode (*alloc_node) (hash_table *);
00051
00052
00053 void * (*alloc_subobject) (size_t);
00054
00055 unsigned int nslots;
00056 unsigned int nelements;
00057
00058
00059 struct cpp_reader *pfile;
00060
00061
00062 unsigned int searches;
00063 unsigned int collisions;
00064
00065
00066 bool entries_owned;
00067 };
00068
00069
00070 extern hash_table *ht_create (unsigned int order);
00071
00072
00073 extern void ht_destroy (hash_table *);
00074
00075 extern hashnode ht_lookup (hash_table *, const unsigned char *,
00076 size_t, enum ht_lookup_option);
00077 extern hashnode ht_lookup_with_hash (hash_table *, const unsigned char *,
00078 size_t, unsigned int,
00079 enum ht_lookup_option);
00080 #define HT_HASHSTEP(r, c) ((r) * 67 + ((c) - 113));
00081 #define HT_HASHFINISH(r, len) ((r) + (len))
00082
00083
00084
00085
00086 typedef int (*ht_cb) (struct cpp_reader *, hashnode, const void *);
00087 extern void ht_forall (hash_table *, ht_cb, const void *);
00088
00089
00090 extern void ht_load (hash_table *ht, hashnode *entries,
00091 unsigned int nslots, unsigned int nelements, bool own);
00092
00093
00094 extern void ht_dump_statistics (hash_table *);
00095
00096 #endif