xref: /csrg-svn/old/as.vax/assyms.h (revision 5830)
1604Sbill /*
2*5830Srrh  *	Copyright (c) 1982 Regents of the University of California
3*5830Srrh  *	@(#)assyms.h 4.3 02/14/82
4*5830Srrh  */
5*5830Srrh /*
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
35604Sbill  *	the data area.  This way, it is extremely easy to
36604Sbill  *	allow virtual memory temporary files, change the length
37604Sbill  *	of NCPS, and allows for a much more flexible storage
38604Sbill  *	allocation
39604Sbill  */
40604Sbill 
41604Sbill #define SYMDALLOP	200
42604Sbill struct 	allocbox{
43604Sbill 	struct		allocbox	*nextalloc;
44604Sbill 	struct		symtab		symslots[SYMDALLOP];
45604Sbill };
46604Sbill 
47604Sbill #ifdef FLEXNAMES
48604Sbill /*
49604Sbill  *	Names are allocated in a string pool.  String pools are linked
50604Sbill  *	together and are allocated dynamically by Calloc.
51604Sbill  */
52604Sbill #define	STRPOOLDALLOP	NCPS
53604Sbill struct	strpool{
54604Sbill 	struct	strpool	*str_next;
55604Sbill 	int		str_nalloc;
56604Sbill 	char		str_names[STRPOOLDALLOP];
57604Sbill };
58604Sbill 
59604Sbill extern	struct	strpool *strplhead;
60604Sbill #endif
61604Sbill 
62604Sbill extern	struct	allocbox	*allochead;
63604Sbill extern	struct	allocbox	*alloctail;
64604Sbill extern	struct	symtab		*nextsym;
65604Sbill extern	struct	allocbox	*newbox;
66604Sbill extern	char			*namebuffer;
67604Sbill extern	int			symsleft;
68604Sbill 
69604Sbill #define ALLOCQTY 	sizeof (struct allocbox)
70604Sbill /*
71604Sbill  *	Iterate through all symbols in the symbol table in declaration
72604Sbill  *	order
73604Sbill  */
74604Sbill #define DECLITERATE(allocwalk, walkpointer, ubpointer) \
75604Sbill 	for(allocwalk = allochead; \
76604Sbill 	    allocwalk != 0; \
77604Sbill 	    allocwalk = allocwalk->nextalloc) \
78604Sbill 		for (walkpointer = &allocwalk->symslots[0],\
79604Sbill 		        ubpointer = &allocwalk->symslots[SYMDALLOP], \
80604Sbill 		        ubpointer = ubpointer > ( (struct symtab *)alloctail) \
81604Sbill 				 ? nextsym : ubpointer ;\
82604Sbill 		     walkpointer < ubpointer; \
83604Sbill 		     walkpointer++ )
84604Sbill /*
85604Sbill  *	The hash table is segmented, and dynamically extendable.
86604Sbill  *	We have a linked list of hash table segments; within each
87604Sbill  *	segment we use a quadratic rehash that touches no more than 1/2
88604Sbill  *	of the buckets in the hash table when probing.
89604Sbill  *	If the probe does not find the desired symbol, it moves to the
90604Sbill  *	next segment, or allocates a new segment.
91604Sbill  *
92604Sbill  *	Hash table segments are kept on the linked list with the first
93604Sbill  *	segment always first (that contains the reserved words) and
94604Sbill  *	the last added segment immediately after the first segment
95604Sbill  *	to hopefully gain something by locality of reference.
96604Sbill  */
97604Sbill struct hashdallop {
98604Sbill 	int	h_nused;
99604Sbill 	struct	hashdallop	*h_next;
100604Sbill 	struct	symtab		*h_htab[NHASH];
101604Sbill };
102