xref: /csrg-svn/sys/sys/param.h (revision 38161)
123430Smckusick /*
229036Smckusick  * Copyright (c) 1982, 1986 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*38161Smckusick  *	@(#)param.h	7.10 (Berkeley) 05/29/89
723430Smckusick  */
863Sbill 
935813Smarc #define	BSD	198810		/* 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"
6012880Ssam #else
61176Sbill #include <signal.h>
62176Sbill #endif
6363Sbill 
6412880Ssam #define	ISSIG(p) \
6512880Ssam 	((p)->p_sig && ((p)->p_flag&STRC || \
6612965Sroot 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
678467Sroot 
6830406Skarels /*
6930406Skarels  * Machine type dependent parameters.
7030406Skarels  */
7130406Skarels #ifdef KERNEL
7237497Smckusick #include "machine/machparam.h"
7330406Skarels #else
7430406Skarels #include <machine/machparam.h>
7530406Skarels #endif
7630406Skarels 
7712880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
7863Sbill 
7963Sbill #define	NULL	0
8016796Skarels #define	CMASK	022		/* default mask for file creation */
8163Sbill #define	NODEV	(dev_t)(-1)
8263Sbill 
8363Sbill /*
8463Sbill  * Clustering of hardware pages on machines with ridiculously small
8563Sbill  * page sizes is done here.  The paging subsystem deals with units of
8630406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
8763Sbill  *
8863Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8963Sbill  */
905080Swnj #define	CLBYTES		(CLSIZE*NBPG)
912637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
925080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
935080Swnj #define	CLOFF		CLOFSET
948993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
9563Sbill 
968993Sroot #if CLSIZE==1
978993Sroot #define	clbase(i)	(i)
988993Sroot #define	clrnd(i)	(i)
998993Sroot #else
10063Sbill /* give the base virtual address (first of CLSIZE) */
10163Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
10263Sbill /* round a number of clicks up to a whole cluster */
10363Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1048993Sroot #endif
10563Sbill 
10624930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */
10724930Skarels #define	CBLOCK	64
10835813Smarc #define CBQSIZE	(CBLOCK/NBBY)	/* quote bytes/cblock - can do better */
10935813Smarc #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
11024930Skarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
11163Sbill 
11263Sbill /*
1136564Smckusic  * File system parameters and macros.
1146564Smckusic  *
1156564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1166564Smckusic  * with smaller units (fragments) only in the last direct block.
1176564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1186564Smckusic  * pool. It may be made larger without any effect on existing
1196564Smckusic  * file systems; however making it smaller make make some file
1206564Smckusic  * systems unmountable.
1216564Smckusic  *
1226564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1236564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1247147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1257147Smckusick  * be a power of two and in the range of
1267147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1277147Smckusick  * This size has no effect upon the file system, but is usually set
1287147Smckusick  * to the block size of the root file system, so as to maximize the
1297147Smckusick  * speed of ``fsck''.
1303069Swnj  */
1316564Smckusic #define	MAXBSIZE	8192
1326564Smckusic #define MAXFRAG 	8
1336564Smckusic 
1346564Smckusic /*
1356564Smckusic  * MAXPATHLEN defines the longest permissable path length
1366564Smckusic  * after expanding symbolic links. It is used to allocate
1376564Smckusic  * a temporary buffer from the buffer pool in which to do the
1386564Smckusic  * name expansion, hence should be a power of two, and must
1396564Smckusic  * be less than or equal to MAXBSIZE.
1406564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1416564Smckusic  * that may be expanded in a path name. It should be set high
1426564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1436564Smckusic  * reasonably quickly.
1446564Smckusic  */
14536805Sbostic #define	MAXPATHLEN	PATH_MAX
1466564Smckusic #define MAXSYMLINKS	8
1476564Smckusic 
1486564Smckusic /*
14931414Smckusick  * Constants for setting the parameters of the kernel memory allocator.
15031414Smckusick  *
15131414Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
15231414Smckusick  * allocated. It must be at least large enough to hold a pointer.
15331414Smckusick  *
15431414Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
15531414Smckusick  * allocate physical memory; requests for these size pieces of
15631414Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
15731414Smckusick  * always allocate and free physical memory; requests for these
15831414Smckusick  * size allocations should be done infrequently as they will be slow.
15931414Smckusick  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
16031414Smckusick  * and MAXALLOCSIZE must be a power of two.
16131414Smckusick  */
16231414Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
16331414Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
16431414Smckusick 
16531414Smckusick /*
1666564Smckusic  * bit map related macros
1676564Smckusic  */
1686564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1696564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1706564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1716564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1726564Smckusic 
1736564Smckusic /*
1746564Smckusic  * Macros for fast min/max.
1756564Smckusic  */
1766564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1776564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1786564Smckusic 
1796564Smckusic /*
1806564Smckusic  * Macros for counting and rounding.
1816564Smckusic  */
18223756Skarels #ifndef howmany
1836564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
18423756Skarels #endif
1856564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
18631414Smckusick #define powerof2(x)	((((x)-1)&(x))==0)
187*38161Smckusick 
188*38161Smckusick /*
189*38161Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
190*38161Smckusick  *
191*38161Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
192*38161Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
193*38161Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
194*38161Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
195*38161Smckusick  *
196*38161Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
197*38161Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
198*38161Smckusick  */
199*38161Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
200*38161Smckusick #define FSCALE	(1<<FSHIFT)
201