Debian Codegraph @

include/shstr.h

raw symbols SCIP
1 /**
2 * @file
3 * Shared-strings defines.
4 */
5
6 #ifndef SHSTR_H
7 #define SHSTR_H
8
9 /**
10 * The size of the shared strings hashtable. This must be smaller than
11 * 32767, but 947 ought to be plenty enough.
12 */
13 #define TABLESIZE 4133
14
15 /**
16 * This specifies how many characters the hashing routine should look at.
17 * You may actually save CPU by increasing this number if the typical string
18 * is large.
19 */
20 #ifndef MAXSTRING
21 #define MAXSTRING 20
22 #endif
23
24 /**
25 * In the unlikely occurence that 16383 references to a string are too
26 * few, you can modify the below type to something bigger.
27 * (The top bit of "refcount" is used to signify that "u.array" points
28 * at the array entry.)
29 */
30 #define REFCOUNT_TYPE int
31
32 /**
33 * The offsetof macro is part of ANSI C, but many compilers lack it, for
34 * example "gcc -ansi"
35 */
36 #if !defined(offsetof)
37 #define offsetof(type, member) (int)&(((type *)0)->member)
38 #endif
39
40 /**
41 * SS(string) will return the address of the shared_string struct which
42 * contains "string".
43 */
44 #define SS(x) ((shared_string *) ((x)-offsetof(shared_string, string)))
45
46 #define SS_DUMP_TABLE 1
47 #define SS_DUMP_TOTALS 2
48
49 #ifdef SS_STATISTICS
50 /** Used to collect statistics on string manipulation. */
51 static struct statistics {
52 int calls;
53 int hashed;
54 int strcmps;
55 int search;
56 int linked;
57 } add_stats, add_ref_stats, free_stats, find_stats, hash_stats;
58 #define GATHER(n) (++n)
59 #else /* !SS_STATISTICS */
60 #define GATHER(n)
61 #endif /* SS_STATISTICS */
62
63 #define TOPBIT ((unsigned REFCOUNT_TYPE)1<<(sizeof(REFCOUNT_TYPE)*CHAR_BIT-1))
64
65 #define PADDING ((2*sizeof(long)-sizeof(REFCOUNT_TYPE))%sizeof(long))+1
66
67 /**
68 * One actual shared string.
69 */
70 typedef struct _shared_string {
71 union {
72 struct _shared_string **array;
73 struct _shared_string *previous;
74 } u;
75 struct _shared_string *next;
76 /* The top bit of "refcount" is used to signify that "u.array" points
77 * at the array entry.
78 */
79 unsigned REFCOUNT_TYPE refcount;
80 /* Padding will be unused memory, since we can't know how large
81 * the padding when allocating memory. We assume here that
82 * sizeof(long) is a good boundary.
83 */
84 char string[PADDING];
85 } shared_string;
86
87 #endif /* SHSTR_H */