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