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