xref: /original-bsd/sys/sys/param.h (revision fbed46ce)
1 /* "@(#)param.h 2.1 3/25/82" */
2 
3 /*	param.h	4.17	82/04/19	*/
4 
5 /*
6  * Tunable variables which do not usually vary per system.
7  *
8  * The sizes of most system tables are configured
9  * into each system description.  The file system buffer
10  * cache size is assigned based on available memory.
11  * The tables whose sizes don't vary often are given here.
12  */
13 
14 #define	NMOUNT	15		/* number of mountable file systems */
15 #define	MSWAPX	15		/* pseudo mount table index for swapdev */
16 #define	MAXUPRC	25		/* max processes per user */
17 #define	SSIZE	4		/* initial stack size (*512 bytes) */
18 #define	SINCR	4		/* increment of stack (*512 bytes) */
19 #define	NOFILE	20		/* max open files per process */
20 /* NOFILE MUST NOT BE >= 31; SEE pte.h */
21 #define	CANBSIZ	256		/* max size of typewriter line */
22 #define	NCARGS	10240		/* # characters in exec arglist */
23 
24 /*
25  * priorities
26  * probably should not be
27  * altered too much
28  */
29 
30 #define	PSWP	0
31 #define	PINOD	10
32 #define	PRIBIO	20
33 #define	PRIUBA	24
34 #define	PZERO	25
35 #define	PPIPE	26
36 #define	PWAIT	30
37 #define	PSLEP	40
38 #define	PUSER	50
39 
40 #define	NZERO	20
41 
42 /*
43  * signals
44  * dont change
45  */
46 
47 #ifndef	NSIG
48 #include <signal.h>
49 #endif
50 
51 /*
52  * Return values from tsleep().
53  */
54 #define	TS_OK	0	/* normal wakeup */
55 #define	TS_TIME	1	/* timed-out wakeup */
56 #define	TS_SIG	2	/* asynchronous signal wakeup */
57 
58 /*
59  * fundamental constants of the implementation--
60  * cannot be changed easily.
61  */
62 
63 #define	NBBY		8		/* number of bits in a byte */
64 #define	NBPW		sizeof(int)	/* number of bytes in an integer */
65 #define	NBPG		512
66 #define	PGOFSET		(NBPG-1)	/* byte offset into page */
67 #define	PGSHIFT		9		/* LOG2(NBPG) */
68 
69 #define	UPAGES	8		/* pages of u-area */
70 #define	NULL	0
71 #define	CMASK	0		/* default mask for file creation */
72 #define	NODEV	(dev_t)(-1)
73 #define	NGRPS	256		/* max number groups */
74 
75 /*
76  * Clustering of hardware pages on machines with ridiculously small
77  * page sizes is done here.  The paging subsystem deals with units of
78  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
79  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
80  * deals with the same size blocks that the file system uses.
81  *
82  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
83  */
84 #define	CLSIZE		2
85 #define	CLBYTES		(CLSIZE*NBPG)
86 #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
87 #define	claligned(x)	((((int)(x))&CLOFSET)==0)
88 #define	CLOFF		CLOFSET
89 #define	CLSHIFT		(PGSHIFT+1)
90 
91 /* give the base virtual address (first of CLSIZE) */
92 #define	clbase(i)	((i) &~ (CLSIZE-1))
93 
94 /* round a number of clicks up to a whole cluster */
95 #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
96 
97 #ifndef INTRLVE
98 /* macros replacing interleaving functions */
99 #define	dkblock(bp)	((bp)->b_blkno)
100 #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
101 #endif
102 
103 #define	CBSIZE	28		/* number of chars in a clist block */
104 #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
105 
106 /*
107  * Some macros for units conversion
108  */
109 /* Core clicks (512 bytes) to segments and vice versa */
110 #define	ctos(x)	(x)
111 #define	stoc(x)	(x)
112 
113 /* Core clicks (512 bytes) to disk blocks */
114 #define	ctod(x)	(x)
115 
116 /* clicks to bytes */
117 #define	ctob(x)	((x)<<9)
118 
119 /* bytes to clicks */
120 #define	btoc(x)	((((unsigned)(x)+511)>>9))
121 
122 #ifndef KERNEL
123 #include	<sys/types.h>
124 #else
125 #include	"../h/types.h"
126 #endif
127 
128 /*
129  * Machine-dependent bits and macros
130  */
131 #define	UMODE	PSL_CURMOD		/* usermode bits */
132 #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
133 
134 #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
135 
136 /*
137  * File system parameters and macros.
138  *
139  * The file system is made out of blocks of at most MAXBSIZE units,
140  * with smaller units (fragments) only in the last direct block.
141  * MAXBSIZE primarily determines the size of buffers in the buffer
142  * pool. It may be made larger without any effect on existing
143  * file systems; however making it smaller make make some file
144  * systems unmountable.
145  *
146  * Note that the blocked devices are assumed to have DEV_BSIZE
147  * "sectors" and that fragments must be some multiple of this size.
148  */
149 #define	MAXBSIZE	8192
150 #define	DEV_BSIZE	512
151 #define MAXFRAG 	8
152 
153 /*
154  * MAXPATHLEN defines the longest permissable path length
155  * after expanding symbolic links. It is used to allocate
156  * a temporary buffer from the buffer pool in which to do the
157  * name expansion, hence should be a power of two, and must
158  * be less than or equal to MAXBSIZE.
159  * MAXSYMLINKS defines the maximum number of symbolic links
160  * that may be expanded in a path name. It should be set high
161  * enough to allow all legitimate uses, but halt infinite loops
162  * reasonably quickly.
163  */
164 #define MAXPATHLEN	1024
165 #define MAXSYMLINKS	8
166 
167 /*
168  * bit map related macros
169  */
170 #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
171 #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
172 #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
173 #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
174 
175 /*
176  * Macros for fast min/max.
177  */
178 #define	MIN(a,b) (((a)<(b))?(a):(b))
179 #define	MAX(a,b) (((a)>(b))?(a):(b))
180 
181 /*
182  * Macros for counting and rounding.
183  */
184 #define	howmany(x, y)	(((x)+((y)-1))/(y))
185 #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
186 
187 /*
188  * Provide about n microseconds of delay.
189  */
190 #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
191