xref: /csrg-svn/sys/sys/param.h (revision 49237)
148799Sbostic /*-
248799Sbostic  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
348799Sbostic  * All rights reserved.
423430Smckusick  *
548799Sbostic  * %sccs.include.redist.c%
648799Sbostic  *
7*49237Skarels  *	@(#)param.h	7.23 (Berkeley) 05/06/91
823430Smckusick  */
963Sbill 
1048389Skarels #define	BSD	199103		/* March, 1991 system version (year & month) */
1125297Skarels #define BSD4_3	1
1240631Skarels #define BSD4_4	0.5
1324654Sbloom 
1448799Sbostic #ifndef NULL
1548799Sbostic #define	NULL	0
1648799Sbostic #endif
1736805Sbostic 
1848389Skarels #ifndef LOCORE
1948389Skarels #include <sys/types.h>
2048389Skarels #endif
2148389Skarels 
2263Sbill /*
2348799Sbostic  * Machine-independent constants (some used in following include files).
2448799Sbostic  * Redefined constants are from POSIX 1003.1 limits file.
2548799Sbostic  *
2648799Sbostic  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
2748799Sbostic  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
288993Sroot  */
2948799Sbostic #include <sys/syslimits.h>
3048799Sbostic 
3148799Sbostic #define	MAXCOMLEN	16		/* max command name remembered */
3240631Skarels #define	MAXINTERP	32		/* max interpreter file name length */
3348799Sbostic #define	MAXLOGNAME	12		/* max login name length */
3448799Sbostic #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
3548799Sbostic #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
3640631Skarels #define	NGROUPS		NGROUPS_MAX	/* max number groups */
3748799Sbostic #define	NOFILE		OPEN_MAX	/* max open files per process */
3840631Skarels #define	NOGROUP		65535		/* marker for empty group set member */
3948799Sbostic #define MAXHOSTNAMELEN	256		/* max hostname size */
4011808Ssam 
4148799Sbostic /* More types and definitions used throughout the kernel. */
4247539Skarels #ifdef KERNEL
4347539Skarels #include <sys/cdefs.h>
4447539Skarels #include <sys/errno.h>
4547539Skarels #include <sys/time.h>
4647539Skarels #include <sys/resource.h>
4747539Skarels #include <sys/ucred.h>
4847539Skarels #include <sys/uio.h>
4947539Skarels #endif
5047539Skarels 
5148799Sbostic /* Signals. */
5238783Skarels #include <sys/signal.h>
5363Sbill 
5448799Sbostic /* Machine type dependent parameters. */
5545793Sbostic #include <machine/param.h>
5645793Sbostic #include <machine/endian.h>
5745793Sbostic #include <machine/limits.h>
5830406Skarels 
5948389Skarels /*
6048799Sbostic  * Priorities.  Note that with 32 run queues, differences less than 4 are
6148799Sbostic  * insignificant.
6248389Skarels  */
6348389Skarels #define	PSWP	0
6448389Skarels #define	PVM	4
6548389Skarels #define	PINOD	8
6648389Skarels #define	PRIBIO	16
6748389Skarels #define	PVFS	20
68*49237Skarels #define	PZERO	22		/* No longer magic, shouldn't be here.  XXX */
6948389Skarels #define	PSOCK	24
7048389Skarels #define	PWAIT	32
7148389Skarels #define	PLOCK	36
7248389Skarels #define	PPAUSE	40
7348389Skarels #define	PUSER	50
7448799Sbostic #define	MAXPRI	127		/* Priorities range from 0 through MAXPRI. */
7548389Skarels 
7648389Skarels #define	PRIMASK	0x0ff
7748799Sbostic #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
7848389Skarels 
7948389Skarels #define	NZERO	0		/* default "nice" */
8048389Skarels 
8148799Sbostic #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
8263Sbill 
8348799Sbostic #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
8448799Sbostic #define	NODEV	(dev_t)(-1)	/* non-existent device */
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  */
915080Swnj #define	CLBYTES		(CLSIZE*NBPG)
922637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
935080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
945080Swnj #define	CLOFF		CLOFSET
958993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
9663Sbill 
978993Sroot #if CLSIZE==1
988993Sroot #define	clbase(i)	(i)
998993Sroot #define	clrnd(i)	(i)
1008993Sroot #else
10148799Sbostic /* Give the base virtual address (first of CLSIZE). */
10263Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
10348799Sbostic /* Round a number of clicks up to a whole cluster. */
10463Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1058993Sroot #endif
10663Sbill 
10748799Sbostic #define	CBLOCK	64		/* Clist block size, must be a power of 2. */
10848799Sbostic #define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
10948799Sbostic 				/* Data chars/clist. */
11048799Sbostic #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
11148799Sbostic #define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
11263Sbill 
11363Sbill /*
1146564Smckusic  * File system parameters and macros.
1156564Smckusic  *
11648799Sbostic  * The file system is made out of blocks of at most MAXBSIZE units, with
11748799Sbostic  * smaller units (fragments) only in the last direct block.  MAXBSIZE
11848799Sbostic  * primarily determines the size of buffers in the buffer pool.  It may be
11948799Sbostic  * made larger without any effect on existing file systems; however making
12048799Sbostic  * it smaller make make some file systems unmountable.
1213069Swnj  */
1226564Smckusic #define	MAXBSIZE	8192
1236564Smckusic #define MAXFRAG 	8
1246564Smckusic 
1256564Smckusic /*
12648799Sbostic  * MAXPATHLEN defines the longest permissable path length after expanding
12748799Sbostic  * symbolic links. It is used to allocate a temporary buffer from the buffer
12848799Sbostic  * pool in which to do the name expansion, hence should be a power of two,
12948799Sbostic  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
13048799Sbostic  * maximum number of symbolic links that may be expanded in a path name.
13148799Sbostic  * It should be set high enough to allow all legitimate uses, but halt
13248799Sbostic  * infinite loops reasonably quickly.
1336564Smckusic  */
13436805Sbostic #define	MAXPATHLEN	PATH_MAX
1356564Smckusic #define MAXSYMLINKS	8
1366564Smckusic 
13748799Sbostic /* Bit map related macros. */
13840209Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
13940209Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
14040209Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
14140209Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
14240209Skarels 
14348799Sbostic /* Macros for counting and rounding. */
14440209Skarels #ifndef howmany
14540209Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
14640209Skarels #endif
14740209Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
14840209Skarels #define powerof2(x)	((((x)-1)&(x))==0)
14940209Skarels 
15048799Sbostic /* Macros for fast min/max: with inline expansion, the "function" is faster. */
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.
17048799Sbostic  *
17148799Sbostic  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
17248799Sbostic  * MAXALLOCSIZE must be a power of two.
17331414Smckusick  */
17431414Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
17531414Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
17631414Smckusick 
17731414Smckusick /*
17838161Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
17938161Smckusick  *
18038161Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
18138161Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
18238161Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
18338161Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
18438161Smckusick  *
18538161Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
18638161Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
18738161Smckusick  */
18838161Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
18938161Smckusick #define FSCALE	(1<<FSHIFT)
190