xref: /csrg-svn/sys/sys/param.h (revision 48799)
1*48799Sbostic /*-
2*48799Sbostic  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
3*48799Sbostic  * All rights reserved.
423430Smckusick  *
5*48799Sbostic  * %sccs.include.redist.c%
6*48799Sbostic  *
7*48799Sbostic  *	@(#)param.h	7.22 (Berkeley) 04/28/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 
14*48799Sbostic #ifndef NULL
15*48799Sbostic #define	NULL	0
16*48799Sbostic #endif
1736805Sbostic 
1848389Skarels #ifndef LOCORE
1948389Skarels #include <sys/types.h>
2048389Skarels #endif
2148389Skarels 
2263Sbill /*
23*48799Sbostic  * Machine-independent constants (some used in following include files).
24*48799Sbostic  * Redefined constants are from POSIX 1003.1 limits file.
25*48799Sbostic  *
26*48799Sbostic  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
27*48799Sbostic  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
288993Sroot  */
29*48799Sbostic #include <sys/syslimits.h>
30*48799Sbostic 
31*48799Sbostic #define	MAXCOMLEN	16		/* max command name remembered */
3240631Skarels #define	MAXINTERP	32		/* max interpreter file name length */
33*48799Sbostic #define	MAXLOGNAME	12		/* max login name length */
34*48799Sbostic #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
35*48799Sbostic #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
3640631Skarels #define	NGROUPS		NGROUPS_MAX	/* max number groups */
37*48799Sbostic #define	NOFILE		OPEN_MAX	/* max open files per process */
3840631Skarels #define	NOGROUP		65535		/* marker for empty group set member */
39*48799Sbostic #define MAXHOSTNAMELEN	256		/* max hostname size */
4011808Ssam 
41*48799Sbostic /* 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 
51*48799Sbostic /* Signals. */
5238783Skarels #include <sys/signal.h>
5363Sbill 
54*48799Sbostic /* Machine type dependent parameters. */
5545793Sbostic #include <machine/param.h>
5645793Sbostic #include <machine/endian.h>
5745793Sbostic #include <machine/limits.h>
5830406Skarels 
5948389Skarels /*
60*48799Sbostic  * Priorities.  Note that with 32 run queues, differences less than 4 are
61*48799Sbostic  * insignificant.
6248389Skarels  */
6348389Skarels #define	PSWP	0
6448389Skarels #define	PVM	4
6548389Skarels #define	PINOD	8
6648389Skarels #define	PRIBIO	16
6748389Skarels #define	PVFS	20
6848389Skarels #define	PSOCK	24
69*48799Sbostic #define	PZERO	25		/* No longer magic, shouldn't be here.  XXX */
7048389Skarels #define	PWAIT	32
7148389Skarels #define	PLOCK	36
7248389Skarels #define	PPAUSE	40
7348389Skarels #define	PUSER	50
74*48799Sbostic #define	MAXPRI	127		/* Priorities range from 0 through MAXPRI. */
7548389Skarels 
7648389Skarels #define	PRIMASK	0x0ff
77*48799Sbostic #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
7848389Skarels 
7948389Skarels #define	NZERO	0		/* default "nice" */
8048389Skarels 
81*48799Sbostic #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
8263Sbill 
83*48799Sbostic #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
84*48799Sbostic #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
101*48799Sbostic /* Give the base virtual address (first of CLSIZE). */
10263Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
103*48799Sbostic /* Round a number of clicks up to a whole cluster. */
10463Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1058993Sroot #endif
10663Sbill 
107*48799Sbostic #define	CBLOCK	64		/* Clist block size, must be a power of 2. */
108*48799Sbostic #define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
109*48799Sbostic 				/* Data chars/clist. */
110*48799Sbostic #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
111*48799Sbostic #define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
11263Sbill 
11363Sbill /*
1146564Smckusic  * File system parameters and macros.
1156564Smckusic  *
116*48799Sbostic  * The file system is made out of blocks of at most MAXBSIZE units, with
117*48799Sbostic  * smaller units (fragments) only in the last direct block.  MAXBSIZE
118*48799Sbostic  * primarily determines the size of buffers in the buffer pool.  It may be
119*48799Sbostic  * made larger without any effect on existing file systems; however making
120*48799Sbostic  * it smaller make make some file systems unmountable.
1213069Swnj  */
1226564Smckusic #define	MAXBSIZE	8192
1236564Smckusic #define MAXFRAG 	8
1246564Smckusic 
1256564Smckusic /*
126*48799Sbostic  * MAXPATHLEN defines the longest permissable path length after expanding
127*48799Sbostic  * symbolic links. It is used to allocate a temporary buffer from the buffer
128*48799Sbostic  * pool in which to do the name expansion, hence should be a power of two,
129*48799Sbostic  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
130*48799Sbostic  * maximum number of symbolic links that may be expanded in a path name.
131*48799Sbostic  * It should be set high enough to allow all legitimate uses, but halt
132*48799Sbostic  * infinite loops reasonably quickly.
1336564Smckusic  */
13436805Sbostic #define	MAXPATHLEN	PATH_MAX
1356564Smckusic #define MAXSYMLINKS	8
1366564Smckusic 
137*48799Sbostic /* 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 
143*48799Sbostic /* 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 
150*48799Sbostic /* 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.
170*48799Sbostic  *
171*48799Sbostic  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
172*48799Sbostic  * 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