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