xref: /csrg-svn/sys/sys/param.h (revision 8467)
1*8467Sroot /*	param.h	4.22	82/10/10	*/
263Sbill 
363Sbill /*
42751Swnj  * Tunable variables which do not usually vary per system.
563Sbill  *
62751Swnj  * The sizes of most system tables are configured
72751Swnj  * into each system description.  The file system buffer
82751Swnj  * cache size is assigned based on available memory.
92751Swnj  * The tables whose sizes don't vary often are given here.
1063Sbill  */
1163Sbill 
12356Sbill #define	NMOUNT	15		/* number of mountable file systems */
13356Sbill #define	MSWAPX	15		/* pseudo mount table index for swapdev */
1463Sbill #define	MAXUPRC	25		/* max processes per user */
1563Sbill #define	SSIZE	4		/* initial stack size (*512 bytes) */
1663Sbill #define	SINCR	4		/* increment of stack (*512 bytes) */
1763Sbill #define	NOFILE	20		/* max open files per process */
182751Swnj /* NOFILE MUST NOT BE >= 31; SEE pte.h */
1963Sbill #define	CANBSIZ	256		/* max size of typewriter line */
20874Sbill #define	NCARGS	10240		/* # characters in exec arglist */
212751Swnj 
2263Sbill /*
2363Sbill  * priorities
2463Sbill  * probably should not be
2563Sbill  * altered too much
2663Sbill  */
2763Sbill 
2863Sbill #define	PSWP	0
2963Sbill #define	PINOD	10
3063Sbill #define	PRIBIO	20
3163Sbill #define	PRIUBA	24
3263Sbill #define	PZERO	25
3363Sbill #define	PPIPE	26
3463Sbill #define	PWAIT	30
357688Ssam #define	PLOCK	35
3663Sbill #define	PSLEP	40
3763Sbill #define	PUSER	50
3863Sbill 
3963Sbill #define	NZERO	20
4063Sbill 
4163Sbill /*
4263Sbill  * signals
4363Sbill  * dont change
4463Sbill  */
4563Sbill 
46176Sbill #ifndef	NSIG
47176Sbill #include <signal.h>
48176Sbill #endif
4963Sbill 
50*8467Sroot #define	ISSIG(p)	((p)->p_sig && \
51*8467Sroot 	((p)->p_flag&STRC || ((p)->p_sig &~ (p)->p_ignsig)) && issig())
52*8467Sroot 
5363Sbill /*
5497Sbill  * Return values from tsleep().
5597Sbill  */
5697Sbill #define	TS_OK	0	/* normal wakeup */
5797Sbill #define	TS_TIME	1	/* timed-out wakeup */
5897Sbill #define	TS_SIG	2	/* asynchronous signal wakeup */
5997Sbill 
6097Sbill /*
6163Sbill  * fundamental constants of the implementation--
6263Sbill  * cannot be changed easily.
6363Sbill  */
6463Sbill 
652637Swnj #define	NBBY		8		/* number of bits in a byte */
662637Swnj #define	NBPW		sizeof(int)	/* number of bytes in an integer */
672637Swnj #define	NBPG		512
682637Swnj #define	PGOFSET		(NBPG-1)	/* byte offset into page */
692637Swnj #define	PGSHIFT		9		/* LOG2(NBPG) */
7063Sbill 
712637Swnj #define	UPAGES	8		/* pages of u-area */
7263Sbill #define	NULL	0
7363Sbill #define	CMASK	0		/* default mask for file creation */
7463Sbill #define	NODEV	(dev_t)(-1)
757869Sroot #define	NGROUPS	8		/* max number groups */
7663Sbill 
7763Sbill /*
7863Sbill  * Clustering of hardware pages on machines with ridiculously small
7963Sbill  * page sizes is done here.  The paging subsystem deals with units of
8063Sbill  * CLSIZE pte's describing NBPG (from vm.h) pages each... BSIZE must
8163Sbill  * be CLSIZE*NBPG in the current implementation, that is the paging subsystem
8263Sbill  * deals with the same size blocks that the file system uses.
8363Sbill  *
8463Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8563Sbill  */
865080Swnj #define	CLSIZE		2
875080Swnj #define	CLBYTES		(CLSIZE*NBPG)
882637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
895080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
905080Swnj #define	CLOFF		CLOFSET
915080Swnj #define	CLSHIFT		(PGSHIFT+1)
9263Sbill 
9363Sbill /* give the base virtual address (first of CLSIZE) */
9463Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
9563Sbill 
9663Sbill /* round a number of clicks up to a whole cluster */
9763Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
9863Sbill 
9963Sbill #ifndef INTRLVE
10063Sbill /* macros replacing interleaving functions */
10163Sbill #define	dkblock(bp)	((bp)->b_blkno)
10263Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
10363Sbill #endif
10463Sbill 
10563Sbill #define	CBSIZE	28		/* number of chars in a clist block */
10663Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
10763Sbill 
10863Sbill /*
10963Sbill  * Some macros for units conversion
11063Sbill  */
11163Sbill /* Core clicks (512 bytes) to segments and vice versa */
11263Sbill #define	ctos(x)	(x)
11363Sbill #define	stoc(x)	(x)
11463Sbill 
11563Sbill /* Core clicks (512 bytes) to disk blocks */
11663Sbill #define	ctod(x)	(x)
11763Sbill 
11863Sbill /* clicks to bytes */
11963Sbill #define	ctob(x)	((x)<<9)
12063Sbill 
12163Sbill /* bytes to clicks */
12263Sbill #define	btoc(x)	((((unsigned)(x)+511)>>9))
12363Sbill 
1243069Swnj #ifndef KERNEL
1253069Swnj #include	<sys/types.h>
1263069Swnj #else
1273069Swnj #include	"../h/types.h"
1283069Swnj #endif
12963Sbill 
13063Sbill /*
13163Sbill  * Machine-dependent bits and macros
13263Sbill  */
13363Sbill #define	UMODE	PSL_CURMOD		/* usermode bits */
13463Sbill #define	USERMODE(ps)	(((ps) & UMODE) == UMODE)
13563Sbill 
13663Sbill #define	BASEPRI(ps)	(((ps) & PSL_IPL) != 0)
1373069Swnj 
1383069Swnj /*
1396564Smckusic  * File system parameters and macros.
1406564Smckusic  *
1416564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1426564Smckusic  * with smaller units (fragments) only in the last direct block.
1436564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1446564Smckusic  * pool. It may be made larger without any effect on existing
1456564Smckusic  * file systems; however making it smaller make make some file
1466564Smckusic  * systems unmountable.
1476564Smckusic  *
1486564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1496564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1507147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1517147Smckusick  * be a power of two and in the range of
1527147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1537147Smckusick  * This size has no effect upon the file system, but is usually set
1547147Smckusick  * to the block size of the root file system, so as to maximize the
1557147Smckusick  * speed of ``fsck''.
1563069Swnj  */
1576564Smckusic #define	MAXBSIZE	8192
1586564Smckusic #define	DEV_BSIZE	512
1597147Smckusick #define BLKDEV_IOSIZE	4096
1606564Smckusic #define MAXFRAG 	8
1616564Smckusic 
1626564Smckusic /*
1637442Skre  * Map a ``block device block'' to a file system block.
1647442Skre  * This should be device dependent, and will be after we
1657442Skre  * add an entry to cdevsw for that purpose.  For now though
1667442Skre  * just use DEV_BSIZE.
1677442Skre  */
1687442Skre #define	bdbtofsb(bn)	((bn) / CLSIZE)
1697442Skre 
1707442Skre /*
1716564Smckusic  * MAXPATHLEN defines the longest permissable path length
1726564Smckusic  * after expanding symbolic links. It is used to allocate
1736564Smckusic  * a temporary buffer from the buffer pool in which to do the
1746564Smckusic  * name expansion, hence should be a power of two, and must
1756564Smckusic  * be less than or equal to MAXBSIZE.
1766564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1776564Smckusic  * that may be expanded in a path name. It should be set high
1786564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1796564Smckusic  * reasonably quickly.
1806564Smckusic  */
1816564Smckusic #define MAXPATHLEN	1024
1826564Smckusic #define MAXSYMLINKS	8
1836564Smckusic 
1846564Smckusic /*
1856564Smckusic  * bit map related macros
1866564Smckusic  */
1876564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1886564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1896564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1906564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1916564Smckusic 
1926564Smckusic /*
1936564Smckusic  * Macros for fast min/max.
1946564Smckusic  */
1956564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1966564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1976564Smckusic 
1986564Smckusic /*
1996564Smckusic  * Macros for counting and rounding.
2006564Smckusic  */
2016564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
2026564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
2036564Smckusic 
2046564Smckusic /*
2056564Smckusic  * Provide about n microseconds of delay.
2066564Smckusic  */
2073069Swnj #define	DELAY(n)	{ register int N = (n); while (--N > 0); }
208