xref: /csrg-svn/sys/sys/param.h (revision 45793)
123430Smckusick /*
238783Skarels  * 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*45793Sbostic  *	@(#)param.h	7.19 (Berkeley) 12/16/90
723430Smckusick  */
863Sbill 
944382Skarels #define	BSD	199006		/* June, 1990 system version (year & month) */
1025297Skarels #define BSD4_3	1
1140631Skarels #define BSD4_4	0.5
1224654Sbloom 
1336805Sbostic #include <sys/syslimits.h>
1436805Sbostic 
1563Sbill /*
168993Sroot  * Machine-independent constants
178993Sroot  */
1840631Skarels #define	MAXUPRC		CHILD_MAX	/* max processes per user */
1940631Skarels #define	NOFILE		OPEN_MAX	/* max open files per process */
2040631Skarels #define	NCARGS		ARG_MAX		/* # characters in exec arglist */
2140631Skarels #define	MAXINTERP	32		/* max interpreter file name length */
2240631Skarels #define	NGROUPS		NGROUPS_MAX	/* max number groups */
2343890Skarels #define MAXHOSTNAMELEN	256		/* maximum hostname size */
2443890Skarels #define	MAXCOMLEN	16		/* maximum command name remembered */
2543890Skarels 	/* MAXCOMLEN should be >= sizeof(ac_comm) (acct.h)  */
2643890Skarels #define	MAXLOGNAME	12		/* maximum login name length */
2743890Skarels 	/* MAXLOGNAME must be >= UT_NAMESIZE (<utmp.h>) */
282751Swnj 
2940631Skarels #define	NOGROUP		65535		/* marker for empty group set member */
3011808Ssam 
3163Sbill /*
328993Sroot  * Priorities
3363Sbill  */
3463Sbill #define	PSWP	0
3545708Smckusick #define	PVM	1
3663Sbill #define	PINOD	10
3763Sbill #define	PRIBIO	20
3837717Smckusick #define	PVFS	22
3963Sbill #define	PZERO	25
4040631Skarels #define	PSOCK	26
4163Sbill #define	PWAIT	30
427688Ssam #define	PLOCK	35
4340631Skarels #define	PPAUSE	40
4463Sbill #define	PUSER	50
4540631Skarels #define	PRIMASK	0x0ff
4640631Skarels #define	PCATCH	0x100		/* or'd with pri for tsleep to check signals */
4763Sbill 
4817556Skarels #define	NZERO	0
4963Sbill 
50*45793Sbostic #ifndef LOCORE
5130406Skarels #include	<sys/types.h>
5230406Skarels #endif
5330406Skarels 
5463Sbill /*
558993Sroot  * Signals
5663Sbill  */
5738783Skarels #include <sys/signal.h>
5863Sbill 
5930406Skarels /*
6030406Skarels  * Machine type dependent parameters.
6130406Skarels  */
62*45793Sbostic #include <machine/param.h>
63*45793Sbostic #include <machine/endian.h>
64*45793Sbostic #include <machine/limits.h>
6530406Skarels 
6612880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
6763Sbill 
6838783Skarels #ifndef NULL
6963Sbill #define	NULL	0
7038783Skarels #endif
7116796Skarels #define	CMASK	022		/* default mask for file creation */
7263Sbill #define	NODEV	(dev_t)(-1)
7363Sbill 
7463Sbill /*
7563Sbill  * Clustering of hardware pages on machines with ridiculously small
7663Sbill  * page sizes is done here.  The paging subsystem deals with units of
7730406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
7863Sbill  *
7963Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8063Sbill  */
815080Swnj #define	CLBYTES		(CLSIZE*NBPG)
822637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
835080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
845080Swnj #define	CLOFF		CLOFSET
858993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
8663Sbill 
878993Sroot #if CLSIZE==1
888993Sroot #define	clbase(i)	(i)
898993Sroot #define	clrnd(i)	(i)
908993Sroot #else
9163Sbill /* give the base virtual address (first of CLSIZE) */
9263Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
9363Sbill /* round a number of clicks up to a whole cluster */
9463Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
958993Sroot #endif
9663Sbill 
9724930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */
9824930Skarels #define	CBLOCK	64
9935813Smarc #define CBQSIZE	(CBLOCK/NBBY)	/* quote bytes/cblock - can do better */
10035813Smarc #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
10124930Skarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
10263Sbill 
10363Sbill /*
1046564Smckusic  * File system parameters and macros.
1056564Smckusic  *
1066564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1076564Smckusic  * with smaller units (fragments) only in the last direct block.
1086564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1096564Smckusic  * pool. It may be made larger without any effect on existing
1106564Smckusic  * file systems; however making it smaller make make some file
1116564Smckusic  * systems unmountable.
1123069Swnj  */
1136564Smckusic #define	MAXBSIZE	8192
1146564Smckusic #define MAXFRAG 	8
1156564Smckusic 
1166564Smckusic /*
1176564Smckusic  * MAXPATHLEN defines the longest permissable path length
1186564Smckusic  * after expanding symbolic links. It is used to allocate
1196564Smckusic  * a temporary buffer from the buffer pool in which to do the
1206564Smckusic  * name expansion, hence should be a power of two, and must
1216564Smckusic  * be less than or equal to MAXBSIZE.
1226564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1236564Smckusic  * that may be expanded in a path name. It should be set high
1246564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1256564Smckusic  * reasonably quickly.
1266564Smckusic  */
12736805Sbostic #define	MAXPATHLEN	PATH_MAX
1286564Smckusic #define MAXSYMLINKS	8
1296564Smckusic 
1306564Smckusic /*
13140209Skarels  * bit map related macros
13240209Skarels  */
13340209Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
13440209Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
13540209Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
13640209Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
13740209Skarels 
13840209Skarels /*
13940209Skarels  * Macros for counting and rounding.
14040209Skarels  */
14140209Skarels #ifndef howmany
14240209Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
14340209Skarels #endif
14440209Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
14540209Skarels #define powerof2(x)	((((x)-1)&(x))==0)
14640209Skarels 
14740209Skarels /*
14840209Skarels  * Macros for fast min/max:
14940209Skarels  * with inline expansion, the "function" is faster.
15040209Skarels  */
15140209Skarels #ifdef KERNEL
15240209Skarels #define	MIN(a,b) min((a), (b))
15340209Skarels #define	MAX(a,b) max((a), (b))
15440209Skarels #else
15540209Skarels #define	MIN(a,b) (((a)<(b))?(a):(b))
15640209Skarels #define	MAX(a,b) (((a)>(b))?(a):(b))
15740209Skarels #endif
15840209Skarels 
15940209Skarels /*
16031414Smckusick  * Constants for setting the parameters of the kernel memory allocator.
16131414Smckusick  *
16231414Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
16331414Smckusick  * allocated. It must be at least large enough to hold a pointer.
16431414Smckusick  *
16531414Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
16631414Smckusick  * allocate physical memory; requests for these size pieces of
16731414Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
16831414Smckusick  * always allocate and free physical memory; requests for these
16931414Smckusick  * size allocations should be done infrequently as they will be slow.
17031414Smckusick  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
17131414Smckusick  * and MAXALLOCSIZE must be a power of two.
17231414Smckusick  */
17331414Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
17431414Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
17531414Smckusick 
17631414Smckusick /*
17738161Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
17838161Smckusick  *
17938161Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
18038161Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
18138161Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
18238161Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
18338161Smckusick  *
18438161Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
18538161Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
18638161Smckusick  */
18738161Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
18838161Smckusick #define FSCALE	(1<<FSHIFT)
189