xref: /original-bsd/sys/sys/param.h (revision 389af1df)
1*389af1dfSmckusic /* "@(#)param.h 2.1 3/25/82" */
2*389af1dfSmckusic 
3*389af1dfSmckusic /*	param.h	4.17	82/04/19	*/
45db792e4Sbill 
55db792e4Sbill /*
645ac661dSwnj  * Tunable variables which do not usually vary per system.
75db792e4Sbill  *
845ac661dSwnj  * The sizes of most system tables are configured
945ac661dSwnj  * into each system description.  The file system buffer
1045ac661dSwnj  * cache size is assigned based on available memory.
1145ac661dSwnj  * The tables whose sizes don't vary often are given here.
125db792e4Sbill  */
135db792e4Sbill 
1416850871Sbill #define	NMOUNT	15		/* number of mountable file systems */
1516850871Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
165db792e4Sbill #define	MAXUPRC	25		/* max processes per user */
175db792e4Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
185db792e4Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
195db792e4Sbill #define	NOFILE	20		/* max open files per process */
2045ac661dSwnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
215db792e4Sbill #define	CANBSIZ	256		/* max size of typewriter line */
225eb5d423Sbill #define	NCARGS	10240		/* # characters in exec arglist */
2345ac661dSwnj 
245db792e4Sbill /*
255db792e4Sbill  * priorities
265db792e4Sbill  * probably should not be
275db792e4Sbill  * altered too much
285db792e4Sbill  */
295db792e4Sbill 
305db792e4Sbill #define	PSWP	0
315db792e4Sbill #define	PINOD	10
325db792e4Sbill #define	PRIBIO	20
335db792e4Sbill #define	PRIUBA	24
345db792e4Sbill #define	PZERO	25
355db792e4Sbill #define	PPIPE	26
365db792e4Sbill #define	PWAIT	30
375db792e4Sbill #define	PSLEP	40
385db792e4Sbill #define	PUSER	50
395db792e4Sbill 
405db792e4Sbill #define	NZERO	20
415db792e4Sbill 
425db792e4Sbill /*
435db792e4Sbill  * signals
445db792e4Sbill  * dont change
455db792e4Sbill  */
465db792e4Sbill 
4746cc71adSbill #ifndef	NSIG
4846cc71adSbill #include <signal.h>
4946cc71adSbill #endif
50c6983186Sbill 
51c6983186Sbill /*
52c6983186Sbill  * Return values from tsleep().
53c6983186Sbill  */
54c6983186Sbill #define	TS_OK	0	/* normal wakeup */
55c6983186Sbill #define	TS_TIME	1	/* timed-out wakeup */
56c6983186Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
575db792e4Sbill 
585db792e4Sbill /*
595db792e4Sbill  * fundamental constants of the implementation--
605db792e4Sbill  * cannot be changed easily.
615db792e4Sbill  */
625db792e4Sbill 
63e163c03cSwnj #define	NBBY		8		/* number of bits in a byte */
645db792e4Sbill #define	NBPW		sizeof(int)	/* number of bytes in an integer */
65e163c03cSwnj #define	NBPG		512
66e163c03cSwnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
67e163c03cSwnj #define	PGSHIFT		9		/* LOG2(NBPG) */
685db792e4Sbill 
69e163c03cSwnj #define	UPAGES	8		/* pages of u-area */
705db792e4Sbill #define	NULL	0
715db792e4Sbill #define	CMASK	0		/* default mask for file creation */
725db792e4Sbill #define	NODEV	(dev_t)(-1)
7341fc41bdSwnj #define	NGRPS	256		/* max number groups */
745db792e4Sbill 
755db792e4Sbill /*
765db792e4Sbill  * Clustering of hardware pages on machines with ridiculously small
775db792e4Sbill  * page sizes is done here.  The paging subsystem deals with units of
785db792e4Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
795db792e4Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
805db792e4Sbill  * deals with the same size blocks that the file system uses.
815db792e4Sbill  *
825db792e4Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
835db792e4Sbill  */
845db792e4Sbill #define	CLSIZE		2
85248881f8Swnj #define	CLBYTES		(CLSIZE*NBPG)
86e163c03cSwnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
87248881f8Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
88248881f8Swnj #define	CLOFF		CLOFSET
89248881f8Swnj #define	CLSHIFT		(PGSHIFT+1)
905db792e4Sbill 
915db792e4Sbill /* give the base virtual address (first of CLSIZE) */
925db792e4Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
935db792e4Sbill 
945db792e4Sbill /* round a number of clicks up to a whole cluster */
955db792e4Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
965db792e4Sbill 
975db792e4Sbill #ifndef INTRLVE
985db792e4Sbill /* macros replacing interleaving functions */
995db792e4Sbill #define	dkblock(bp)	((bp)->b_blkno)
1005db792e4Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
1015db792e4Sbill #endif
1025db792e4Sbill 
1035db792e4Sbill #define	CBSIZE	28		/* number of chars in a clist block */
1045db792e4Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
1055db792e4Sbill 
1065db792e4Sbill /*
1075db792e4Sbill  * Some macros for units conversion
1085db792e4Sbill  */
1095db792e4Sbill /* Core clicks (512 bytes) to segments and vice versa */
1105db792e4Sbill #define	ctos(x)	(x)
1115db792e4Sbill #define	stoc(x)	(x)
1125db792e4Sbill 
1135db792e4Sbill /* Core clicks (512 bytes) to disk blocks */
1145db792e4Sbill #define	ctod(x)	(x)
1155db792e4Sbill 
1165db792e4Sbill /* clicks to bytes */
1175db792e4Sbill #define	ctob(x)	((x)<<9)
1185db792e4Sbill 
1195db792e4Sbill /* bytes to clicks */
1205db792e4Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
1215db792e4Sbill 
122e0ff83f9Swnj #ifndef KERNEL
123e0ff83f9Swnj #include	<sys/types.h>
124e0ff83f9Swnj #else
125e0ff83f9Swnj #include	"../h/types.h"
126e0ff83f9Swnj #endif
12776379a38Sbill 
1285db792e4Sbill /*
1295db792e4Sbill  * Machine-dependent bits and macros
1305db792e4Sbill  */
1315db792e4Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
1325db792e4Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
1335db792e4Sbill 
1345db792e4Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
135e0ff83f9Swnj 
136e0ff83f9Swnj /*
137*389af1dfSmckusic  * File system parameters and macros.
138*389af1dfSmckusic  *
139*389af1dfSmckusic  * The file system is made out of blocks of at most MAXBSIZE units,
140*389af1dfSmckusic  * with smaller units (fragments) only in the last direct block.
141*389af1dfSmckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
142*389af1dfSmckusic  * pool. It may be made larger without any effect on existing
143*389af1dfSmckusic  * file systems; however making it smaller make make some file
144*389af1dfSmckusic  * systems unmountable.
145*389af1dfSmckusic  *
146*389af1dfSmckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
147*389af1dfSmckusic  * "sectors" and that fragments must be some multiple of this size.
148*389af1dfSmckusic  */
149*389af1dfSmckusic #define	MAXBSIZE	8192
150*389af1dfSmckusic #define	DEV_BSIZE	512
151*389af1dfSmckusic #define MAXFRAG 	8
152*389af1dfSmckusic 
153*389af1dfSmckusic /*
154*389af1dfSmckusic  * MAXPATHLEN defines the longest permissable path length
155*389af1dfSmckusic  * after expanding symbolic links. It is used to allocate
156*389af1dfSmckusic  * a temporary buffer from the buffer pool in which to do the
157*389af1dfSmckusic  * name expansion, hence should be a power of two, and must
158*389af1dfSmckusic  * be less than or equal to MAXBSIZE.
159*389af1dfSmckusic  * MAXSYMLINKS defines the maximum number of symbolic links
160*389af1dfSmckusic  * that may be expanded in a path name. It should be set high
161*389af1dfSmckusic  * enough to allow all legitimate uses, but halt infinite loops
162*389af1dfSmckusic  * reasonably quickly.
163*389af1dfSmckusic  */
164*389af1dfSmckusic #define MAXPATHLEN	1024
165*389af1dfSmckusic #define MAXSYMLINKS	8
166*389af1dfSmckusic 
167*389af1dfSmckusic /*
168*389af1dfSmckusic  * bit map related macros
169*389af1dfSmckusic  */
170*389af1dfSmckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
171*389af1dfSmckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
172*389af1dfSmckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
173*389af1dfSmckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
174*389af1dfSmckusic 
175*389af1dfSmckusic /*
176*389af1dfSmckusic  * Macros for fast min/max.
177*389af1dfSmckusic  */
178*389af1dfSmckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
179*389af1dfSmckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
180*389af1dfSmckusic 
181*389af1dfSmckusic /*
182*389af1dfSmckusic  * Macros for counting and rounding.
183*389af1dfSmckusic  */
184*389af1dfSmckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
185*389af1dfSmckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
186*389af1dfSmckusic 
187*389af1dfSmckusic /*
188*389af1dfSmckusic  * Provide about n microseconds of delay.
189e0ff83f9Swnj  */
190e0ff83f9Swnj #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
191