xref: /csrg-svn/sys/sys/param.h (revision 38783)
123430Smckusick /*
2*38783Skarels  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
323430Smckusick  * All rights reserved.  The Berkeley software License Agreement
423430Smckusick  * specifies the terms and conditions for redistribution.
523430Smckusick  *
6*38783Skarels  *	@(#)param.h	7.11 (Berkeley) 08/26/89
723430Smckusick  */
863Sbill 
9*38783Skarels #define	BSD	198908		/* system version  (year & month) */
1025297Skarels #define BSD4_3	1
1124654Sbloom 
1236805Sbostic #include <sys/syslimits.h>
1336805Sbostic 
1463Sbill /*
158993Sroot  * Machine-independent constants
168993Sroot  */
1717556Skarels #define	NMOUNT	20		/* number of mountable file systems */
1816796Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
1915070Skarels #define	MSWAPX	NMOUNT		/* pseudo mount table index for swapdev */
2036805Sbostic #define	MAXUPRC	CHILD_MAX	/* max processes per user */
2136805Sbostic #define	NOFILE	OPEN_MAX	/* max open files per process */
2263Sbill #define	CANBSIZ	256		/* max size of typewriter line */
2336805Sbostic #define	NCARGS	ARG_MAX		/* # characters in exec arglist */
2430576Sbostic #define	MAXINTERP	32	/* maximum interpreter file name length */
2536805Sbostic #define	NGROUPS	NGROUPS_MAX	/* max number groups */
2630406Skarels #define MAXHOSTNAMELEN	64	/* maximum hostname size */
272751Swnj 
2826257Skarels #define	NOGROUP	65535		/* marker for empty group set member */
2911808Ssam 
3063Sbill /*
318993Sroot  * Priorities
3263Sbill  */
3363Sbill #define	PSWP	0
3463Sbill #define	PINOD	10
3563Sbill #define	PRIBIO	20
3637717Smckusick #define	PVFS	22
3763Sbill #define	PRIUBA	24
3863Sbill #define	PZERO	25
3963Sbill #define	PPIPE	26
4063Sbill #define	PWAIT	30
417688Ssam #define	PLOCK	35
4263Sbill #define	PSLEP	40
4363Sbill #define	PUSER	50
4463Sbill 
4517556Skarels #define	NZERO	0
4663Sbill 
4730406Skarels #ifndef KERNEL
4830406Skarels #include	<sys/types.h>
4930406Skarels #else
5030406Skarels #ifndef LOCORE
5130406Skarels #include	"types.h"
5230406Skarels #endif
5330406Skarels #endif
5430406Skarels 
5563Sbill /*
568993Sroot  * Signals
5763Sbill  */
5812880Ssam #ifdef KERNEL
5917033Sbloom #include "signal.h"
60*38783Skarels 
61*38783Skarels #define	ISSIG(p) \
62*38783Skarels 	((p)->p_sig && \
63*38783Skarels 	    ((p)->p_flag&STRC || ((p)->p_sig &~ (p)->p_sigmask)) && issig())
64*38783Skarels 
6512880Ssam #else
66*38783Skarels #include <sys/signal.h>
67176Sbill #endif
6863Sbill 
6930406Skarels /*
7030406Skarels  * Machine type dependent parameters.
7130406Skarels  */
7230406Skarels #ifdef KERNEL
7337497Smckusick #include "machine/machparam.h"
7430406Skarels #else
7530406Skarels #include <machine/machparam.h>
7630406Skarels #endif
7730406Skarels 
7812880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
7963Sbill 
80*38783Skarels #ifndef NULL
8163Sbill #define	NULL	0
82*38783Skarels #endif
8316796Skarels #define	CMASK	022		/* default mask for file creation */
8463Sbill #define	NODEV	(dev_t)(-1)
8563Sbill 
8663Sbill /*
8763Sbill  * Clustering of hardware pages on machines with ridiculously small
8863Sbill  * page sizes is done here.  The paging subsystem deals with units of
8930406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
9063Sbill  *
9163Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
9263Sbill  */
935080Swnj #define	CLBYTES		(CLSIZE*NBPG)
942637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
955080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
965080Swnj #define	CLOFF		CLOFSET
978993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
9863Sbill 
998993Sroot #if CLSIZE==1
1008993Sroot #define	clbase(i)	(i)
1018993Sroot #define	clrnd(i)	(i)
1028993Sroot #else
10363Sbill /* give the base virtual address (first of CLSIZE) */
10463Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
10563Sbill /* round a number of clicks up to a whole cluster */
10663Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1078993Sroot #endif
10863Sbill 
10924930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */
11024930Skarels #define	CBLOCK	64
11135813Smarc #define CBQSIZE	(CBLOCK/NBBY)	/* quote bytes/cblock - can do better */
11235813Smarc #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
11324930Skarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
11463Sbill 
11563Sbill /*
1166564Smckusic  * File system parameters and macros.
1176564Smckusic  *
1186564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1196564Smckusic  * with smaller units (fragments) only in the last direct block.
1206564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1216564Smckusic  * pool. It may be made larger without any effect on existing
1226564Smckusic  * file systems; however making it smaller make make some file
1236564Smckusic  * systems unmountable.
1246564Smckusic  *
1256564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1266564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1277147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1287147Smckusick  * be a power of two and in the range of
1297147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1307147Smckusick  * This size has no effect upon the file system, but is usually set
1317147Smckusick  * to the block size of the root file system, so as to maximize the
1327147Smckusick  * speed of ``fsck''.
1333069Swnj  */
1346564Smckusic #define	MAXBSIZE	8192
1356564Smckusic #define MAXFRAG 	8
1366564Smckusic 
1376564Smckusic /*
1386564Smckusic  * MAXPATHLEN defines the longest permissable path length
1396564Smckusic  * after expanding symbolic links. It is used to allocate
1406564Smckusic  * a temporary buffer from the buffer pool in which to do the
1416564Smckusic  * name expansion, hence should be a power of two, and must
1426564Smckusic  * be less than or equal to MAXBSIZE.
1436564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1446564Smckusic  * that may be expanded in a path name. It should be set high
1456564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1466564Smckusic  * reasonably quickly.
1476564Smckusic  */
14836805Sbostic #define	MAXPATHLEN	PATH_MAX
1496564Smckusic #define MAXSYMLINKS	8
1506564Smckusic 
1516564Smckusic /*
15231414Smckusick  * Constants for setting the parameters of the kernel memory allocator.
15331414Smckusick  *
15431414Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
15531414Smckusick  * allocated. It must be at least large enough to hold a pointer.
15631414Smckusick  *
15731414Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
15831414Smckusick  * allocate physical memory; requests for these size pieces of
15931414Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
16031414Smckusick  * always allocate and free physical memory; requests for these
16131414Smckusick  * size allocations should be done infrequently as they will be slow.
16231414Smckusick  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
16331414Smckusick  * and MAXALLOCSIZE must be a power of two.
16431414Smckusick  */
16531414Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
16631414Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
16731414Smckusick 
16831414Smckusick /*
1696564Smckusic  * bit map related macros
1706564Smckusic  */
1716564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1726564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1736564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1746564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1756564Smckusic 
1766564Smckusic /*
1776564Smckusic  * Macros for fast min/max.
1786564Smckusic  */
1796564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1806564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1816564Smckusic 
1826564Smckusic /*
1836564Smckusic  * Macros for counting and rounding.
1846564Smckusic  */
18523756Skarels #ifndef howmany
1866564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
18723756Skarels #endif
1886564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
18931414Smckusick #define powerof2(x)	((((x)-1)&(x))==0)
19038161Smckusick 
19138161Smckusick /*
19238161Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
19338161Smckusick  *
19438161Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
19538161Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
19638161Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
19738161Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
19838161Smckusick  *
19938161Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
20038161Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
20138161Smckusick  */
20238161Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
20338161Smckusick #define FSCALE	(1<<FSHIFT)
204