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