1*604Sbill /* Copyright (c) 1980 Regents of the University of California */ 2*604Sbill /* "@(#)assyms.h 4.1 08/13/80" */ 3*604Sbill /* 4*604Sbill * To speed up walks through symbols defined in a particular 5*604Sbill * segment, we buil up a table of pointers into the symbol table 6*604Sbill * and a table of delimiters for each segment. The delimiter for 7*604Sbill * the particular segment points to the first word in that segment. 8*604Sbill */ 9*604Sbill 10*604Sbill extern struct symtab **symptrs; /*dynamically allocated*/ 11*604Sbill extern struct symtab **symdelim[NLOC + NLOC + 1]; 12*604Sbill extern struct symtab **symptrub; 13*604Sbill extern int nsyms; /*number in the symbol table*/ 14*604Sbill extern int njxxx; /*the number of jxxx entries in the table*/ 15*604Sbill extern int nforgotten; /*how many entries erroneously entered*/ 16*604Sbill extern int nlabels; /*how many labels in the symbol table*/ 17*604Sbill extern int hshused; /*how many hash slots used*/ 18*604Sbill 19*604Sbill #define SEGITERATE(segno, start, end, copointer, walkpointer, ubpointer, direction) \ 20*604Sbill for(copointer = start == 0? symdelim[segno]:start,\ 21*604Sbill ubpointer = end == 0 ? *symdelim[segno+1] : *(symdelim[segno]-1),\ 22*604Sbill walkpointer = *copointer;\ 23*604Sbill walkpointer != ubpointer;\ 24*604Sbill walkpointer = * direction copointer) 25*604Sbill 26*604Sbill #define SYMITERATE(copointer, walkpointer) \ 27*604Sbill for(copointer = symptrs, \ 28*604Sbill walkpointer = *copointer; \ 29*604Sbill copointer < symptrub; \ 30*604Sbill walkpointer = * ++ copointer) 31*604Sbill /* 32*604Sbill * Symbols are allocated in non contiguous chunks by extending 33*604Sbill * the data area. This way, it is extremely easy to 34*604Sbill * allow virtual memory temporary files, change the length 35*604Sbill * of NCPS, and allows for a much more flexible storage 36*604Sbill * allocation 37*604Sbill */ 38*604Sbill 39*604Sbill #define SYMDALLOP 200 40*604Sbill struct allocbox{ 41*604Sbill struct allocbox *nextalloc; 42*604Sbill struct symtab symslots[SYMDALLOP]; 43*604Sbill #ifndef FLEXNAMES 44*604Sbill char symnames[SYMDALLOP * NCPS]; 45*604Sbill #endif 46*604Sbill }; 47*604Sbill 48*604Sbill #ifdef FLEXNAMES 49*604Sbill /* 50*604Sbill * Names are allocated in a string pool. String pools are linked 51*604Sbill * together and are allocated dynamically by Calloc. 52*604Sbill */ 53*604Sbill #define STRPOOLDALLOP NCPS 54*604Sbill struct strpool{ 55*604Sbill struct strpool *str_next; 56*604Sbill int str_nalloc; 57*604Sbill char str_names[STRPOOLDALLOP]; 58*604Sbill }; 59*604Sbill 60*604Sbill extern struct strpool *strplhead; 61*604Sbill #endif 62*604Sbill 63*604Sbill extern struct allocbox *allochead; 64*604Sbill extern struct allocbox *alloctail; 65*604Sbill extern struct symtab *nextsym; 66*604Sbill extern struct allocbox *newbox; 67*604Sbill extern char *namebuffer; 68*604Sbill extern int symsleft; 69*604Sbill 70*604Sbill #define ALLOCQTY sizeof (struct allocbox) 71*604Sbill /* 72*604Sbill * Iterate through all symbols in the symbol table in declaration 73*604Sbill * order 74*604Sbill */ 75*604Sbill #define DECLITERATE(allocwalk, walkpointer, ubpointer) \ 76*604Sbill for(allocwalk = allochead; \ 77*604Sbill allocwalk != 0; \ 78*604Sbill allocwalk = allocwalk->nextalloc) \ 79*604Sbill for (walkpointer = &allocwalk->symslots[0],\ 80*604Sbill ubpointer = &allocwalk->symslots[SYMDALLOP], \ 81*604Sbill ubpointer = ubpointer > ( (struct symtab *)alloctail) \ 82*604Sbill ? nextsym : ubpointer ;\ 83*604Sbill walkpointer < ubpointer; \ 84*604Sbill walkpointer++ ) 85*604Sbill /* 86*604Sbill * The hash table is segmented, and dynamically extendable. 87*604Sbill * We have a linked list of hash table segments; within each 88*604Sbill * segment we use a quadratic rehash that touches no more than 1/2 89*604Sbill * of the buckets in the hash table when probing. 90*604Sbill * If the probe does not find the desired symbol, it moves to the 91*604Sbill * next segment, or allocates a new segment. 92*604Sbill * 93*604Sbill * Hash table segments are kept on the linked list with the first 94*604Sbill * segment always first (that contains the reserved words) and 95*604Sbill * the last added segment immediately after the first segment 96*604Sbill * to hopefully gain something by locality of reference. 97*604Sbill */ 98*604Sbill struct hashdallop { 99*604Sbill int h_nused; 100*604Sbill struct hashdallop *h_next; 101*604Sbill struct symtab *h_htab[NHASH]; 102*604Sbill }; 103