xref: /csrg-svn/sys/sys/param.h (revision 48389)
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*48389Skarels  *	@(#)param.h	7.21 (Berkeley) 04/20/91
723430Smckusick  */
863Sbill 
9*48389Skarels #define	BSD	199103		/* March, 1991 system version (year & month) */
1025297Skarels #define BSD4_3	1
1140631Skarels #define BSD4_4	0.5
1224654Sbloom 
1336805Sbostic #include <sys/syslimits.h>
1436805Sbostic 
15*48389Skarels #ifndef LOCORE
16*48389Skarels #include <sys/types.h>
17*48389Skarels #endif
18*48389Skarels 
1963Sbill /*
20*48389Skarels  * Machine-independent constants (some used in following include files)
218993Sroot  */
2240631Skarels #define	MAXUPRC		CHILD_MAX	/* max processes per user */
2340631Skarels #define	NOFILE		OPEN_MAX	/* max open files per process */
2440631Skarels #define	NCARGS		ARG_MAX		/* # characters in exec arglist */
2540631Skarels #define	MAXINTERP	32		/* max interpreter file name length */
2640631Skarels #define	NGROUPS		NGROUPS_MAX	/* max number groups */
2743890Skarels #define MAXHOSTNAMELEN	256		/* maximum hostname size */
2843890Skarels #define	MAXCOMLEN	16		/* maximum command name remembered */
2943890Skarels 	/* MAXCOMLEN should be >= sizeof(ac_comm) (acct.h)  */
3043890Skarels #define	MAXLOGNAME	12		/* maximum login name length */
3143890Skarels 	/* MAXLOGNAME must be >= UT_NAMESIZE (<utmp.h>) */
322751Swnj 
3340631Skarels #define	NOGROUP		65535		/* marker for empty group set member */
3411808Ssam 
3563Sbill /*
3647539Skarels  * More types and definitions used throughout the kernel
3747539Skarels  */
3847539Skarels #ifdef KERNEL
3947539Skarels #include <sys/cdefs.h>
4047539Skarels #include <sys/errno.h>
4147539Skarels #include <sys/time.h>
4247539Skarels #include <sys/resource.h>
4347539Skarels #include <sys/ucred.h>
4447539Skarels #include <sys/uio.h>
4547539Skarels #endif
4647539Skarels 
4747539Skarels /*
488993Sroot  * Signals
4963Sbill  */
5038783Skarels #include <sys/signal.h>
5163Sbill 
5230406Skarels /*
5330406Skarels  * Machine type dependent parameters.
5430406Skarels  */
5545793Sbostic #include <machine/param.h>
5645793Sbostic #include <machine/endian.h>
5745793Sbostic #include <machine/limits.h>
5830406Skarels 
59*48389Skarels /*
60*48389Skarels  * Priorities.  Note that with 32 run queues,
61*48389Skarels  * differences less than 4 are insignificant.
62*48389Skarels  */
63*48389Skarels #define	PSWP	0
64*48389Skarels #define	PVM	4
65*48389Skarels #define	PINOD	8
66*48389Skarels #define	PRIBIO	16
67*48389Skarels #define	PVFS	20
68*48389Skarels #define	PSOCK	24
69*48389Skarels #define	PZERO	25		/* No longer magic, shouldn't be here XXX */
70*48389Skarels #define	PWAIT	32
71*48389Skarels #define	PLOCK	36
72*48389Skarels #define	PPAUSE	40
73*48389Skarels #define	PUSER	50
74*48389Skarels #define	MAXPRI	127		/* priorities range from 0 through MAXPRI */
75*48389Skarels 
76*48389Skarels #define	PRIMASK	0x0ff
77*48389Skarels #define	PCATCH	0x100		/* or'd with pri for tsleep to check signals */
78*48389Skarels 
79*48389Skarels #define	NZERO	0		/* default "nice" */
80*48389Skarels 
8112880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
8263Sbill 
8338783Skarels #ifndef NULL
8463Sbill #define	NULL	0
8538783Skarels #endif
8616796Skarels #define	CMASK	022		/* default mask for file creation */
8763Sbill #define	NODEV	(dev_t)(-1)
8863Sbill 
8963Sbill /*
9063Sbill  * Clustering of hardware pages on machines with ridiculously small
9163Sbill  * page sizes is done here.  The paging subsystem deals with units of
9230406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
9363Sbill  *
9463Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
9563Sbill  */
965080Swnj #define	CLBYTES		(CLSIZE*NBPG)
972637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
985080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
995080Swnj #define	CLOFF		CLOFSET
1008993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
10163Sbill 
1028993Sroot #if CLSIZE==1
1038993Sroot #define	clbase(i)	(i)
1048993Sroot #define	clrnd(i)	(i)
1058993Sroot #else
10663Sbill /* give the base virtual address (first of CLSIZE) */
10763Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
10863Sbill /* round a number of clicks up to a whole cluster */
10963Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1108993Sroot #endif
11163Sbill 
11224930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */
11324930Skarels #define	CBLOCK	64
11435813Smarc #define CBQSIZE	(CBLOCK/NBBY)	/* quote bytes/cblock - can do better */
11535813Smarc #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
11624930Skarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
11763Sbill 
11863Sbill /*
1196564Smckusic  * File system parameters and macros.
1206564Smckusic  *
1216564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1226564Smckusic  * with smaller units (fragments) only in the last direct block.
1236564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1246564Smckusic  * pool. It may be made larger without any effect on existing
1256564Smckusic  * file systems; however making it smaller make make some file
1266564Smckusic  * systems unmountable.
1273069Swnj  */
1286564Smckusic #define	MAXBSIZE	8192
1296564Smckusic #define MAXFRAG 	8
1306564Smckusic 
1316564Smckusic /*
1326564Smckusic  * MAXPATHLEN defines the longest permissable path length
1336564Smckusic  * after expanding symbolic links. It is used to allocate
1346564Smckusic  * a temporary buffer from the buffer pool in which to do the
1356564Smckusic  * name expansion, hence should be a power of two, and must
1366564Smckusic  * be less than or equal to MAXBSIZE.
1376564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1386564Smckusic  * that may be expanded in a path name. It should be set high
1396564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1406564Smckusic  * reasonably quickly.
1416564Smckusic  */
14236805Sbostic #define	MAXPATHLEN	PATH_MAX
1436564Smckusic #define MAXSYMLINKS	8
1446564Smckusic 
1456564Smckusic /*
14640209Skarels  * bit map related macros
14740209Skarels  */
14840209Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
14940209Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
15040209Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
15140209Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
15240209Skarels 
15340209Skarels /*
15440209Skarels  * Macros for counting and rounding.
15540209Skarels  */
15640209Skarels #ifndef howmany
15740209Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
15840209Skarels #endif
15940209Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
16040209Skarels #define powerof2(x)	((((x)-1)&(x))==0)
16140209Skarels 
16240209Skarels /*
16340209Skarels  * Macros for fast min/max:
16440209Skarels  * with inline expansion, the "function" is faster.
16540209Skarels  */
16640209Skarels #ifdef KERNEL
16740209Skarels #define	MIN(a,b) min((a), (b))
16840209Skarels #define	MAX(a,b) max((a), (b))
16940209Skarels #else
17040209Skarels #define	MIN(a,b) (((a)<(b))?(a):(b))
17140209Skarels #define	MAX(a,b) (((a)>(b))?(a):(b))
17240209Skarels #endif
17340209Skarels 
17440209Skarels /*
17531414Smckusick  * Constants for setting the parameters of the kernel memory allocator.
17631414Smckusick  *
17731414Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
17831414Smckusick  * allocated. It must be at least large enough to hold a pointer.
17931414Smckusick  *
18031414Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
18131414Smckusick  * allocate physical memory; requests for these size pieces of
18231414Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
18331414Smckusick  * always allocate and free physical memory; requests for these
18431414Smckusick  * size allocations should be done infrequently as they will be slow.
18531414Smckusick  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
18631414Smckusick  * and MAXALLOCSIZE must be a power of two.
18731414Smckusick  */
18831414Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
18931414Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
19031414Smckusick 
19131414Smckusick /*
19238161Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
19338161Smckusick  *
19438161Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
19538161Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
19638161Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
19738161Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
19838161Smckusick  *
19938161Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
20038161Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
20138161Smckusick  */
20238161Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
20338161Smckusick #define FSCALE	(1<<FSHIFT)
204