1604Sbill /* 25830Srrh * Copyright (c) 1982 Regents of the University of California 3*13461Srrh * @(#)assyms.h 4.5 06/30/83 45830Srrh */ 55830Srrh /* 6604Sbill * To speed up walks through symbols defined in a particular 7604Sbill * segment, we buil up a table of pointers into the symbol table 8604Sbill * and a table of delimiters for each segment. The delimiter for 9604Sbill * the particular segment points to the first word in that segment. 10604Sbill */ 11604Sbill 12604Sbill extern struct symtab **symptrs; /*dynamically allocated*/ 13604Sbill extern struct symtab **symdelim[NLOC + NLOC + 1]; 14604Sbill extern struct symtab **symptrub; 15604Sbill extern int nsyms; /*number in the symbol table*/ 16604Sbill extern int njxxx; /*the number of jxxx entries in the table*/ 17604Sbill extern int nforgotten; /*how many entries erroneously entered*/ 18604Sbill extern int nlabels; /*how many labels in the symbol table*/ 19604Sbill extern int hshused; /*how many hash slots used*/ 20604Sbill 21604Sbill #define SEGITERATE(segno, start, end, copointer, walkpointer, ubpointer, direction) \ 22604Sbill for(copointer = start == 0? symdelim[segno]:start,\ 23604Sbill ubpointer = end == 0 ? *symdelim[segno+1] : *(symdelim[segno]-1),\ 24604Sbill walkpointer = *copointer;\ 25604Sbill walkpointer != ubpointer;\ 26604Sbill walkpointer = * direction copointer) 27604Sbill 28604Sbill #define SYMITERATE(copointer, walkpointer) \ 29604Sbill for(copointer = symptrs, \ 30604Sbill walkpointer = *copointer; \ 31604Sbill copointer < symptrub; \ 32604Sbill walkpointer = * ++ copointer) 33604Sbill /* 34604Sbill * Symbols are allocated in non contiguous chunks by extending 35*13461Srrh * the data area. 36604Sbill */ 37604Sbill 38604Sbill #define SYMDALLOP 200 39604Sbill struct allocbox{ 40604Sbill struct allocbox *nextalloc; 41604Sbill struct symtab symslots[SYMDALLOP]; 42604Sbill }; 43604Sbill 44604Sbill /* 45*13461Srrh * Names are allocated in a dynamically extensible string pool. 46604Sbill */ 47604Sbill struct strpool{ 48604Sbill struct strpool *str_next; 49604Sbill int str_nalloc; 50604Sbill char str_names[STRPOOLDALLOP]; 51604Sbill }; 52604Sbill 53604Sbill extern struct strpool *strplhead; 54604Sbill 55604Sbill extern struct allocbox *allochead; 56604Sbill extern struct allocbox *alloctail; 57604Sbill extern struct symtab *nextsym; 58604Sbill extern struct allocbox *newbox; 59604Sbill extern char *namebuffer; 60604Sbill extern int symsleft; 61604Sbill 62604Sbill #define ALLOCQTY sizeof (struct allocbox) 63604Sbill /* 64604Sbill * Iterate through all symbols in the symbol table in declaration 65604Sbill * order 66604Sbill */ 67604Sbill #define DECLITERATE(allocwalk, walkpointer, ubpointer) \ 68604Sbill for(allocwalk = allochead; \ 69604Sbill allocwalk != 0; \ 70604Sbill allocwalk = allocwalk->nextalloc) \ 71604Sbill for (walkpointer = &allocwalk->symslots[0],\ 72604Sbill ubpointer = &allocwalk->symslots[SYMDALLOP], \ 73604Sbill ubpointer = ubpointer > ( (struct symtab *)alloctail) \ 74604Sbill ? nextsym : ubpointer ;\ 75604Sbill walkpointer < ubpointer; \ 76604Sbill walkpointer++ ) 77604Sbill /* 78604Sbill * The hash table is segmented, and dynamically extendable. 79604Sbill * We have a linked list of hash table segments; within each 80604Sbill * segment we use a quadratic rehash that touches no more than 1/2 81604Sbill * of the buckets in the hash table when probing. 82604Sbill * If the probe does not find the desired symbol, it moves to the 83604Sbill * next segment, or allocates a new segment. 84604Sbill * 85604Sbill * Hash table segments are kept on the linked list with the first 86604Sbill * segment always first (that contains the reserved words) and 87604Sbill * the last added segment immediately after the first segment 88604Sbill * to hopefully gain something by locality of reference. 89604Sbill */ 90604Sbill struct hashdallop { 91604Sbill int h_nused; 92604Sbill struct hashdallop *h_next; 93604Sbill struct symtab *h_htab[NHASH]; 94604Sbill }; 95