xref: /csrg-svn/sys/sys/param.h (revision 12508)
1*12508Ssam /*	param.h	4.32	83/05/18	*/
263Sbill 
363Sbill /*
4*12508Ssam  * Machine type dependent parameters.
563Sbill  */
69791Ssam #ifdef KERNEL
79791Ssam #include "../machine/param.h"
89791Ssam #else
99791Ssam #include <machine/param.h>
108993Sroot #endif
1163Sbill 
128993Sroot #define	NPTEPG		(NBPG/(sizeof (struct pte)))
138993Sroot 
148993Sroot /*
158993Sroot  * Machine-independent constants
168993Sroot  */
17356Sbill #define	NMOUNT	15		/* number of mountable file systems */
18356Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
1963Sbill #define	MAXUPRC	25		/* max processes per user */
2063Sbill #define	NOFILE	20		/* max open files per process */
212751Swnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
2263Sbill #define	CANBSIZ	256		/* max size of typewriter line */
23874Sbill #define	NCARGS	10240		/* # characters in exec arglist */
2410860Ssam #define	NGROUPS	8		/* max number groups */
252751Swnj 
2611808Ssam #define	NOGROUP	-1		/* marker for empty group set member */
2711808Ssam 
2863Sbill /*
298993Sroot  * Priorities
3063Sbill  */
3163Sbill #define	PSWP	0
3263Sbill #define	PINOD	10
3363Sbill #define	PRIBIO	20
3463Sbill #define	PRIUBA	24
3563Sbill #define	PZERO	25
3663Sbill #define	PPIPE	26
3763Sbill #define	PWAIT	30
387688Ssam #define	PLOCK	35
3963Sbill #define	PSLEP	40
4063Sbill #define	PUSER	50
4163Sbill 
4263Sbill #define	NZERO	20
4363Sbill 
4463Sbill /*
458993Sroot  * Signals
4663Sbill  */
47176Sbill #ifndef	NSIG
48176Sbill #include <signal.h>
49176Sbill #endif
5063Sbill 
518467Sroot #define	ISSIG(p)	((p)->p_sig && \
528467Sroot 	((p)->p_flag&STRC || ((p)->p_sig &~ (p)->p_ignsig)) && issig())
538467Sroot 
5463Sbill /*
558993Sroot  * Fundamental constants of the implementation.
5697Sbill  */
572637Swnj #define	NBBY		8		/* number of bits in a byte */
582637Swnj #define	NBPW		sizeof(int)	/* number of bytes in an integer */
5963Sbill 
6063Sbill #define	NULL	0
6163Sbill #define	CMASK	0		/* default mask for file creation */
6263Sbill #define	NODEV	(dev_t)(-1)
6363Sbill 
6463Sbill /*
6563Sbill  * Clustering of hardware pages on machines with ridiculously small
6663Sbill  * page sizes is done here.  The paging subsystem deals with units of
6763Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
6863Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
6963Sbill  * deals with the same size blocks that the file system uses.
7063Sbill  *
7163Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
7263Sbill  */
735080Swnj #define	CLBYTES		(CLSIZE*NBPG)
742637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
755080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
765080Swnj #define	CLOFF		CLOFSET
778993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
7863Sbill 
798993Sroot #if CLSIZE==1
808993Sroot #define	clbase(i)	(i)
818993Sroot #define	clrnd(i)	(i)
828993Sroot #else
8363Sbill /* give the base virtual address (first of CLSIZE) */
8463Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
8563Sbill /* round a number of clicks up to a whole cluster */
8663Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
878993Sroot #endif
8863Sbill 
8963Sbill #ifndef INTRLVE
9063Sbill /* macros replacing interleaving functions */
9163Sbill #define	dkblock(bp)	((bp)->b_blkno)
9263Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
9363Sbill #endif
9463Sbill 
9563Sbill #define	CBSIZE	28		/* number of chars in a clist block */
9663Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
9763Sbill 
983069Swnj #ifndef KERNEL
993069Swnj #include	<sys/types.h>
1003069Swnj #else
10110384Ssam #ifndef LOCORE
1023069Swnj #include	"../h/types.h"
1033069Swnj #endif
10410384Ssam #endif
10563Sbill 
10663Sbill /*
1076564Smckusic  * File system parameters and macros.
1086564Smckusic  *
1096564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1106564Smckusic  * with smaller units (fragments) only in the last direct block.
1116564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1126564Smckusic  * pool. It may be made larger without any effect on existing
1136564Smckusic  * file systems; however making it smaller make make some file
1146564Smckusic  * systems unmountable.
1156564Smckusic  *
1166564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1176564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1187147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1197147Smckusick  * be a power of two and in the range of
1207147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1217147Smckusick  * This size has no effect upon the file system, but is usually set
1227147Smckusick  * to the block size of the root file system, so as to maximize the
1237147Smckusick  * speed of ``fsck''.
1243069Swnj  */
1256564Smckusic #define	MAXBSIZE	8192
1266564Smckusic #define	DEV_BSIZE	512
12711225Ssam #define BLKDEV_IOSIZE	2048
1286564Smckusic #define MAXFRAG 	8
1296564Smckusic 
1306564Smckusic /*
1317442Skre  * Map a ``block device block'' to a file system block.
1327442Skre  * This should be device dependent, and will be after we
1337442Skre  * add an entry to cdevsw for that purpose.  For now though
1347442Skre  * just use DEV_BSIZE.
1357442Skre  */
1368993Sroot #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
1377442Skre 
1387442Skre /*
1396564Smckusic  * MAXPATHLEN defines the longest permissable path length
1406564Smckusic  * after expanding symbolic links. It is used to allocate
1416564Smckusic  * a temporary buffer from the buffer pool in which to do the
1426564Smckusic  * name expansion, hence should be a power of two, and must
1436564Smckusic  * be less than or equal to MAXBSIZE.
1446564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1456564Smckusic  * that may be expanded in a path name. It should be set high
1466564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1476564Smckusic  * reasonably quickly.
1486564Smckusic  */
1496564Smckusic #define MAXPATHLEN	1024
1506564Smckusic #define MAXSYMLINKS	8
1516564Smckusic 
1526564Smckusic /*
1536564Smckusic  * bit map related macros
1546564Smckusic  */
1556564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1566564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1576564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1586564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1596564Smckusic 
1606564Smckusic /*
1616564Smckusic  * Macros for fast min/max.
1626564Smckusic  */
1636564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1646564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1656564Smckusic 
1666564Smckusic /*
1676564Smckusic  * Macros for counting and rounding.
1686564Smckusic  */
1696564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
1706564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
171