xref: /original-bsd/sys/sys/param.h (revision 57ce53b7)
165a1cfb1Smckusick /*
20c67d176Skarels  * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
365a1cfb1Smckusick  * All rights reserved.  The Berkeley software License Agreement
465a1cfb1Smckusick  * specifies the terms and conditions for redistribution.
565a1cfb1Smckusick  *
6*57ce53b7Skarels  *	@(#)param.h	7.13 (Berkeley) 03/25/90
765a1cfb1Smckusick  */
85db792e4Sbill 
9*57ce53b7Skarels #define	BSD	199003		/* system version (year & month) */
101a9e6e3cSkarels #define BSD4_3	1
11*57ce53b7Skarels #define BSD4_4	0.5
122867d692Sbloom 
134a9959f4Sbostic #include <sys/syslimits.h>
144a9959f4Sbostic 
155db792e4Sbill /*
16b481cdefSroot  * Machine-independent constants
17b481cdefSroot  */
18ab090aa7Skarels #define	NMOUNT		30		/* number of mountable file systems */
19f0028148Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
20*57ce53b7Skarels #define	MSWAPX		NMOUNT		/* pseudo mount index for swapdev */
214a9959f4Sbostic #define	MAXUPRC		CHILD_MAX	/* max processes per user */
224a9959f4Sbostic #define	NOFILE		OPEN_MAX	/* max open files per process */
23ab090aa7Skarels #define	CANBSIZ		256		/* max size of tty input line */
244a9959f4Sbostic #define	NCARGS		ARG_MAX		/* # characters in exec arglist */
25*57ce53b7Skarels #define	MAXINTERP	32		/* max interpreter file name length */
264a9959f4Sbostic #define	NGROUPS		NGROUPS_MAX	/* max number groups */
27f520e942Skarels #define MAXHOSTNAMELEN	64		/* maximum hostname size */
2845ac661dSwnj 
29ebd4ffb8Skarels #define	NOGROUP		65535		/* marker for empty group set member */
30e74c57f3Ssam 
315db792e4Sbill /*
32b481cdefSroot  * Priorities
335db792e4Sbill  */
345db792e4Sbill #define	PSWP	0
355db792e4Sbill #define	PINOD	10
365db792e4Sbill #define	PRIBIO	20
37c9c63310Smckusick #define	PVFS	22
385db792e4Sbill #define	PZERO	25
39*57ce53b7Skarels #define	PSOCK	26
405db792e4Sbill #define	PWAIT	30
41bea46c20Ssam #define	PLOCK	35
42*57ce53b7Skarels #define	PPAUSE	40
435db792e4Sbill #define	PUSER	50
44*57ce53b7Skarels #define	PRIMASK	0x0ff
45*57ce53b7Skarels #define	PCATCH	0x100		/* or'd with pri for tsleep to check signals */
46*57ce53b7Skarels #define	PABORT	0x200		/* or'd with pri for tsleep to longjmp XXX */
475db792e4Sbill 
4874c6c69bSkarels #define	NZERO	0
495db792e4Sbill 
50f520e942Skarels #ifndef KERNEL
51f520e942Skarels #include	<sys/types.h>
52f520e942Skarels #else
53f520e942Skarels #ifndef LOCORE
54f520e942Skarels #include	"types.h"
55f520e942Skarels #endif
56f520e942Skarels #endif
57f520e942Skarels 
585db792e4Sbill /*
59b481cdefSroot  * Signals
605db792e4Sbill  */
61586761c3Ssam #ifdef KERNEL
6264691dc4Sbloom #include "signal.h"
630c67d176Skarels #else
640c67d176Skarels #include <sys/signal.h>
650c67d176Skarels #endif
6603c2128fSroot 
67f520e942Skarels /*
68f520e942Skarels  * Machine type dependent parameters.
69f520e942Skarels  */
70f520e942Skarels #ifdef KERNEL
7193571777Smckusick #include "machine/machparam.h"
72f520e942Skarels #else
73f520e942Skarels #include <machine/machparam.h>
74f520e942Skarels #endif
75f520e942Skarels 
765db792e4Sbill #define	NBPW	sizeof(int)	/* number of bytes in an integer */
775db792e4Sbill 
780c67d176Skarels #ifndef NULL
795db792e4Sbill #define	NULL	0
800c67d176Skarels #endif
81f0028148Skarels #define	CMASK	022		/* default mask for file creation */
825db792e4Sbill #define	NODEV	(dev_t)(-1)
835db792e4Sbill 
845db792e4Sbill /*
855db792e4Sbill  * Clustering of hardware pages on machines with ridiculously small
865db792e4Sbill  * page sizes is done here.  The paging subsystem deals with units of
87f520e942Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
885db792e4Sbill  *
895db792e4Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
905db792e4Sbill  */
91248881f8Swnj #define	CLBYTES		(CLSIZE*NBPG)
92e163c03cSwnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
93248881f8Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
94248881f8Swnj #define	CLOFF		CLOFSET
95b481cdefSroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
965db792e4Sbill 
97b481cdefSroot #if CLSIZE==1
98b481cdefSroot #define	clbase(i)	(i)
99b481cdefSroot #define	clrnd(i)	(i)
100b481cdefSroot #else
1015db792e4Sbill /* give the base virtual address (first of CLSIZE) */
1025db792e4Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
1035db792e4Sbill /* round a number of clicks up to a whole cluster */
1045db792e4Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
105b481cdefSroot #endif
1065db792e4Sbill 
1074bda8b2fSkarels /* CBLOCK is the size of a clist block, must be power of 2 */
1084bda8b2fSkarels #define	CBLOCK	64
1092a0e599eSmarc #define CBQSIZE	(CBLOCK/NBBY)	/* quote bytes/cblock - can do better */
1102a0e599eSmarc #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
1114bda8b2fSkarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
1125db792e4Sbill 
1135db792e4Sbill /*
114389af1dfSmckusic  * File system parameters and macros.
115389af1dfSmckusic  *
116389af1dfSmckusic  * The file system is made out of blocks of at most MAXBSIZE units,
117389af1dfSmckusic  * with smaller units (fragments) only in the last direct block.
118389af1dfSmckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
119389af1dfSmckusic  * pool. It may be made larger without any effect on existing
120389af1dfSmckusic  * file systems; however making it smaller make make some file
121389af1dfSmckusic  * systems unmountable.
122389af1dfSmckusic  */
123389af1dfSmckusic #define	MAXBSIZE	8192
124389af1dfSmckusic #define MAXFRAG 	8
125389af1dfSmckusic 
126edc472f6Skre /*
127389af1dfSmckusic  * MAXPATHLEN defines the longest permissable path length
128389af1dfSmckusic  * after expanding symbolic links. It is used to allocate
129389af1dfSmckusic  * a temporary buffer from the buffer pool in which to do the
130389af1dfSmckusic  * name expansion, hence should be a power of two, and must
131389af1dfSmckusic  * be less than or equal to MAXBSIZE.
132389af1dfSmckusic  * MAXSYMLINKS defines the maximum number of symbolic links
133389af1dfSmckusic  * that may be expanded in a path name. It should be set high
134389af1dfSmckusic  * enough to allow all legitimate uses, but halt infinite loops
135389af1dfSmckusic  * reasonably quickly.
136389af1dfSmckusic  */
1374a9959f4Sbostic #define	MAXPATHLEN	PATH_MAX
138389af1dfSmckusic #define MAXSYMLINKS	8
139389af1dfSmckusic 
140389af1dfSmckusic /*
141ab090aa7Skarels  * bit map related macros
142ab090aa7Skarels  */
143ab090aa7Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
144ab090aa7Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
145ab090aa7Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
146ab090aa7Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
147ab090aa7Skarels 
148ab090aa7Skarels /*
149ab090aa7Skarels  * Macros for counting and rounding.
150ab090aa7Skarels  */
151ab090aa7Skarels #ifndef howmany
152ab090aa7Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
153ab090aa7Skarels #endif
154ab090aa7Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
155ab090aa7Skarels #define powerof2(x)	((((x)-1)&(x))==0)
156ab090aa7Skarels 
157ab090aa7Skarels /*
158ab090aa7Skarels  * Macros for fast min/max:
159ab090aa7Skarels  * with inline expansion, the "function" is faster.
160ab090aa7Skarels  */
161ab090aa7Skarels #ifdef KERNEL
162ab090aa7Skarels #define	MIN(a,b) min((a), (b))
163ab090aa7Skarels #define	MAX(a,b) max((a), (b))
164ab090aa7Skarels #else
165ab090aa7Skarels #define	MIN(a,b) (((a)<(b))?(a):(b))
166ab090aa7Skarels #define	MAX(a,b) (((a)>(b))?(a):(b))
167ab090aa7Skarels #endif
168ab090aa7Skarels 
169ab090aa7Skarels /*
1702fe64d92Smckusick  * Constants for setting the parameters of the kernel memory allocator.
1712fe64d92Smckusick  *
1722fe64d92Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
1732fe64d92Smckusick  * allocated. It must be at least large enough to hold a pointer.
1742fe64d92Smckusick  *
1752fe64d92Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
1762fe64d92Smckusick  * allocate physical memory; requests for these size pieces of
1772fe64d92Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
1782fe64d92Smckusick  * always allocate and free physical memory; requests for these
1792fe64d92Smckusick  * size allocations should be done infrequently as they will be slow.
1802fe64d92Smckusick  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
1812fe64d92Smckusick  * and MAXALLOCSIZE must be a power of two.
1822fe64d92Smckusick  */
1832fe64d92Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
1842fe64d92Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
1852fe64d92Smckusick 
1862fe64d92Smckusick /*
1874233ee38Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
1884233ee38Smckusick  *
1894233ee38Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
1904233ee38Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
1914233ee38Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
1924233ee38Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
1934233ee38Smckusick  *
1944233ee38Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
1954233ee38Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
1964233ee38Smckusick  */
1974233ee38Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
1984233ee38Smckusick #define FSCALE	(1<<FSHIFT)
199