Commit | Line | Data |
---|---|---|
629188b5 JR |
1 | /* Copyright (c) 1979 Regents of the University of California */ |
2 | /* | |
3 | * To speed up walks through symbols defined in a particular | |
4 | * segment, we buil up a table of pointers into the symbol table | |
5 | * and a table of delimiters for each segment. The delimiter for | |
6 | * the particular segment points to the first word in that segment. | |
7 | */ | |
8 | ||
9 | struct symtab **symptrs; /*dynamically allocated*/ | |
10 | struct symtab **symdelim[NLOC + NLOC + 1]; | |
11 | struct symtab *hshtab[NHASH]; | |
12 | struct symtab **symptrub; | |
13 | int nsyms; /*number in the symbol table*/ | |
14 | int njxxx; /*the number of jxxx entries in the table*/ | |
15 | int nforgotten; /*how many entries erroneously entered*/ | |
16 | int nlabels; /*how many labels in the symbol table*/ | |
17 | int hshused; /*how many hash slots used*/ | |
18 | ||
19 | #define SEGITERATE(segno, start, end, copointer, walkpointer, ubpointer, direction) \ | |
20 | for(copointer = start == 0? symdelim[segno]:start,\ | |
21 | ubpointer = end == 0 ? *symdelim[segno+1] : *(symdelim[segno]-1),\ | |
22 | walkpointer = *copointer;\ | |
23 | walkpointer != ubpointer;\ | |
24 | walkpointer = * direction copointer) | |
25 | ||
26 | #define SYMITERATE(copointer, walkpointer) \ | |
27 | for(copointer = symptrs, \ | |
28 | walkpointer = *copointer; \ | |
29 | copointer < symptrub; \ | |
30 | walkpointer = * ++ copointer) | |
31 | /* | |
32 | * Symbols are allocated in non contiguous chunks by extending | |
33 | * the data area. This way, it is extremely easy to | |
34 | * allow virtual memory temporary files, change the length | |
35 | * of NCPS, and allows for a much more flexible storage | |
36 | * allocation | |
37 | */ | |
38 | ||
39 | #define SYMDALLOP 200 | |
40 | struct allocbox{ | |
41 | struct allocbox *nextalloc; | |
42 | struct symtab symslots[SYMDALLOP]; | |
43 | char symnames[SYMDALLOP * NCPS]; | |
44 | }; | |
45 | ||
46 | extern struct allocbox *allochead; | |
47 | extern struct allocbox *alloctail; | |
48 | extern struct symtab *nextsym; | |
49 | extern struct allocbox *newbox; | |
50 | extern char *namebuffer; | |
51 | extern int symsleft; | |
52 | ||
53 | #define ALLOCQTY sizeof (struct allocbox) | |
54 | /* | |
55 | * Iterate through all symbols in the symbol table in declaration | |
56 | * order | |
57 | */ | |
58 | #define DECLITERATE(allocwalk, walkpointer, ubpointer) \ | |
59 | for(allocwalk = allochead; \ | |
60 | allocwalk != 0; \ | |
61 | allocwalk = allocwalk->nextalloc) \ | |
62 | for (walkpointer = &allocwalk->symslots[0],\ | |
63 | ubpointer = &allocwalk->symslots[SYMDALLOP], \ | |
64 | ubpointer = ubpointer > ( (struct symtab *)alloctail) \ | |
65 | ? nextsym : ubpointer ;\ | |
66 | walkpointer < ubpointer; \ | |
67 | walkpointer++ ) |