xref: /csrg-svn/sys/sys/param.h (revision 61064)
148799Sbostic /*-
2*61064Sbostic  * Copyright (c) 1982, 1986, 1989, 1993
3*61064Sbostic  *	The Regents of the University of California.  All rights reserved.
423430Smckusick  *
548799Sbostic  * %sccs.include.redist.c%
648799Sbostic  *
7*61064Sbostic  *	@(#)param.h	8.1 (Berkeley) 06/02/93
823430Smckusick  */
963Sbill 
1059536Sbostic #define	BSD	199306		/* System version (year & month). */
1125297Skarels #define BSD4_3	1
1259536Sbostic #define BSD4_4	1
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/limits.h>
5730406Skarels 
5848389Skarels /*
5948799Sbostic  * Priorities.  Note that with 32 run queues, differences less than 4 are
6048799Sbostic  * insignificant.
6148389Skarels  */
6248389Skarels #define	PSWP	0
6348389Skarels #define	PVM	4
6448389Skarels #define	PINOD	8
6548389Skarels #define	PRIBIO	16
6648389Skarels #define	PVFS	20
6749237Skarels #define	PZERO	22		/* No longer magic, shouldn't be here.  XXX */
6848389Skarels #define	PSOCK	24
6948389Skarels #define	PWAIT	32
7048389Skarels #define	PLOCK	36
7148389Skarels #define	PPAUSE	40
7248389Skarels #define	PUSER	50
7348799Sbostic #define	MAXPRI	127		/* Priorities range from 0 through MAXPRI. */
7448389Skarels 
7548389Skarels #define	PRIMASK	0x0ff
7648799Sbostic #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
7748389Skarels 
7848389Skarels #define	NZERO	0		/* default "nice" */
7948389Skarels 
8048799Sbostic #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
8163Sbill 
8248799Sbostic #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
8348799Sbostic #define	NODEV	(dev_t)(-1)	/* non-existent device */
8463Sbill 
8563Sbill /*
8663Sbill  * Clustering of hardware pages on machines with ridiculously small
8763Sbill  * page sizes is done here.  The paging subsystem deals with units of
8830406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
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
10048799Sbostic /* Give the base virtual address (first of CLSIZE). */
10163Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
10248799Sbostic /* Round a number of clicks up to a whole cluster. */
10363Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1048993Sroot #endif
10563Sbill 
10648799Sbostic #define	CBLOCK	64		/* Clist block size, must be a power of 2. */
10748799Sbostic #define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
10848799Sbostic 				/* Data chars/clist. */
10948799Sbostic #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
11048799Sbostic #define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
11163Sbill 
11263Sbill /*
1136564Smckusic  * File system parameters and macros.
1146564Smckusic  *
11548799Sbostic  * The file system is made out of blocks of at most MAXBSIZE units, with
11648799Sbostic  * smaller units (fragments) only in the last direct block.  MAXBSIZE
11748799Sbostic  * primarily determines the size of buffers in the buffer pool.  It may be
11848799Sbostic  * made larger without any effect on existing file systems; however making
11948799Sbostic  * it smaller make make some file systems unmountable.
1203069Swnj  */
12157034Smargo #define	MAXBSIZE	MAXPHYS
1226564Smckusic #define MAXFRAG 	8
1236564Smckusic 
1246564Smckusic /*
12548799Sbostic  * MAXPATHLEN defines the longest permissable path length after expanding
12648799Sbostic  * symbolic links. It is used to allocate a temporary buffer from the buffer
12748799Sbostic  * pool in which to do the name expansion, hence should be a power of two,
12848799Sbostic  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
12948799Sbostic  * maximum number of symbolic links that may be expanded in a path name.
13048799Sbostic  * It should be set high enough to allow all legitimate uses, but halt
13148799Sbostic  * infinite loops reasonably quickly.
1326564Smckusic  */
13336805Sbostic #define	MAXPATHLEN	PATH_MAX
1346564Smckusic #define MAXSYMLINKS	8
1356564Smckusic 
13648799Sbostic /* Bit map related macros. */
13740209Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
13840209Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
13940209Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
14040209Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
14140209Skarels 
14248799Sbostic /* Macros for counting and rounding. */
14340209Skarels #ifndef howmany
14440209Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
14540209Skarels #endif
14640209Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
14740209Skarels #define powerof2(x)	((((x)-1)&(x))==0)
14840209Skarels 
14955075Sbostic /* Macros for min/max. */
15055075Sbostic #ifndef KERNEL
15140209Skarels #define	MIN(a,b) (((a)<(b))?(a):(b))
15240209Skarels #define	MAX(a,b) (((a)>(b))?(a):(b))
15340209Skarels #endif
15440209Skarels 
15540209Skarels /*
15631414Smckusick  * Constants for setting the parameters of the kernel memory allocator.
15731414Smckusick  *
15831414Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
15931414Smckusick  * allocated. It must be at least large enough to hold a pointer.
16031414Smckusick  *
16131414Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
16231414Smckusick  * allocate physical memory; requests for these size pieces of
16331414Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
16431414Smckusick  * always allocate and free physical memory; requests for these
16531414Smckusick  * size allocations should be done infrequently as they will be slow.
16648799Sbostic  *
16748799Sbostic  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
16848799Sbostic  * MAXALLOCSIZE must be a power of two.
16931414Smckusick  */
17031414Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
17131414Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
17231414Smckusick 
17331414Smckusick /*
17438161Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
17538161Smckusick  *
17638161Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
17738161Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
17838161Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
17938161Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
18038161Smckusick  *
18138161Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
18238161Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
18338161Smckusick  */
18438161Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
18538161Smckusick #define FSCALE	(1<<FSHIFT)
186