xref: /original-bsd/sys/sys/param.h (revision 9ae9ad29)
1*9ae9ad29Sbostic /*-
2*9ae9ad29Sbostic  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
3*9ae9ad29Sbostic  * All rights reserved.
465a1cfb1Smckusick  *
5*9ae9ad29Sbostic  * %sccs.include.redist.c%
6*9ae9ad29Sbostic  *
7*9ae9ad29Sbostic  *	@(#)param.h	7.22 (Berkeley) 04/28/91
865a1cfb1Smckusick  */
95db792e4Sbill 
101ba81c5bSkarels #define	BSD	199103		/* March, 1991 system version (year & month) */
111a9e6e3cSkarels #define BSD4_3	1
1257ce53b7Skarels #define BSD4_4	0.5
132867d692Sbloom 
14*9ae9ad29Sbostic #ifndef NULL
15*9ae9ad29Sbostic #define	NULL	0
16*9ae9ad29Sbostic #endif
174a9959f4Sbostic 
181ba81c5bSkarels #ifndef LOCORE
191ba81c5bSkarels #include <sys/types.h>
201ba81c5bSkarels #endif
211ba81c5bSkarels 
225db792e4Sbill /*
23*9ae9ad29Sbostic  * Machine-independent constants (some used in following include files).
24*9ae9ad29Sbostic  * Redefined constants are from POSIX 1003.1 limits file.
25*9ae9ad29Sbostic  *
26*9ae9ad29Sbostic  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
27*9ae9ad29Sbostic  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
28b481cdefSroot  */
29*9ae9ad29Sbostic #include <sys/syslimits.h>
30*9ae9ad29Sbostic 
31*9ae9ad29Sbostic #define	MAXCOMLEN	16		/* max command name remembered */
3257ce53b7Skarels #define	MAXINTERP	32		/* max interpreter file name length */
33*9ae9ad29Sbostic #define	MAXLOGNAME	12		/* max login name length */
34*9ae9ad29Sbostic #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
35*9ae9ad29Sbostic #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
364a9959f4Sbostic #define	NGROUPS		NGROUPS_MAX	/* max number groups */
37*9ae9ad29Sbostic #define	NOFILE		OPEN_MAX	/* max open files per process */
38ebd4ffb8Skarels #define	NOGROUP		65535		/* marker for empty group set member */
39*9ae9ad29Sbostic #define MAXHOSTNAMELEN	256		/* max hostname size */
40e74c57f3Ssam 
41*9ae9ad29Sbostic /* More types and definitions used throughout the kernel. */
42f34b934bSkarels #ifdef KERNEL
43f34b934bSkarels #include <sys/cdefs.h>
44f34b934bSkarels #include <sys/errno.h>
45f34b934bSkarels #include <sys/time.h>
46f34b934bSkarels #include <sys/resource.h>
47f34b934bSkarels #include <sys/ucred.h>
48f34b934bSkarels #include <sys/uio.h>
49f34b934bSkarels #endif
50f34b934bSkarels 
51*9ae9ad29Sbostic /* Signals. */
520c67d176Skarels #include <sys/signal.h>
5303c2128fSroot 
54*9ae9ad29Sbostic /* Machine type dependent parameters. */
5564716fc5Sbostic #include <machine/param.h>
5664716fc5Sbostic #include <machine/endian.h>
5764716fc5Sbostic #include <machine/limits.h>
58f520e942Skarels 
591ba81c5bSkarels /*
60*9ae9ad29Sbostic  * Priorities.  Note that with 32 run queues, differences less than 4 are
61*9ae9ad29Sbostic  * insignificant.
621ba81c5bSkarels  */
631ba81c5bSkarels #define	PSWP	0
641ba81c5bSkarels #define	PVM	4
651ba81c5bSkarels #define	PINOD	8
661ba81c5bSkarels #define	PRIBIO	16
671ba81c5bSkarels #define	PVFS	20
681ba81c5bSkarels #define	PSOCK	24
69*9ae9ad29Sbostic #define	PZERO	25		/* No longer magic, shouldn't be here.  XXX */
701ba81c5bSkarels #define	PWAIT	32
711ba81c5bSkarels #define	PLOCK	36
721ba81c5bSkarels #define	PPAUSE	40
731ba81c5bSkarels #define	PUSER	50
74*9ae9ad29Sbostic #define	MAXPRI	127		/* Priorities range from 0 through MAXPRI. */
751ba81c5bSkarels 
761ba81c5bSkarels #define	PRIMASK	0x0ff
77*9ae9ad29Sbostic #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
781ba81c5bSkarels 
791ba81c5bSkarels #define	NZERO	0		/* default "nice" */
801ba81c5bSkarels 
81*9ae9ad29Sbostic #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
825db792e4Sbill 
83*9ae9ad29Sbostic #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
84*9ae9ad29Sbostic #define	NODEV	(dev_t)(-1)	/* non-existent device */
855db792e4Sbill 
865db792e4Sbill /*
875db792e4Sbill  * Clustering of hardware pages on machines with ridiculously small
885db792e4Sbill  * page sizes is done here.  The paging subsystem deals with units of
89f520e942Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
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
101*9ae9ad29Sbostic /* Give the base virtual address (first of CLSIZE). */
1025db792e4Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
103*9ae9ad29Sbostic /* Round a number of clicks up to a whole cluster. */
1045db792e4Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
105b481cdefSroot #endif
1065db792e4Sbill 
107*9ae9ad29Sbostic #define	CBLOCK	64		/* Clist block size, must be a power of 2. */
108*9ae9ad29Sbostic #define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
109*9ae9ad29Sbostic 				/* Data chars/clist. */
110*9ae9ad29Sbostic #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
111*9ae9ad29Sbostic #define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
1125db792e4Sbill 
1135db792e4Sbill /*
114389af1dfSmckusic  * File system parameters and macros.
115389af1dfSmckusic  *
116*9ae9ad29Sbostic  * The file system is made out of blocks of at most MAXBSIZE units, with
117*9ae9ad29Sbostic  * smaller units (fragments) only in the last direct block.  MAXBSIZE
118*9ae9ad29Sbostic  * primarily determines the size of buffers in the buffer pool.  It may be
119*9ae9ad29Sbostic  * made larger without any effect on existing file systems; however making
120*9ae9ad29Sbostic  * it smaller make make some file systems unmountable.
121389af1dfSmckusic  */
122389af1dfSmckusic #define	MAXBSIZE	8192
123389af1dfSmckusic #define MAXFRAG 	8
124389af1dfSmckusic 
125edc472f6Skre /*
126*9ae9ad29Sbostic  * MAXPATHLEN defines the longest permissable path length after expanding
127*9ae9ad29Sbostic  * symbolic links. It is used to allocate a temporary buffer from the buffer
128*9ae9ad29Sbostic  * pool in which to do the name expansion, hence should be a power of two,
129*9ae9ad29Sbostic  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
130*9ae9ad29Sbostic  * maximum number of symbolic links that may be expanded in a path name.
131*9ae9ad29Sbostic  * It should be set high enough to allow all legitimate uses, but halt
132*9ae9ad29Sbostic  * infinite loops reasonably quickly.
133389af1dfSmckusic  */
1344a9959f4Sbostic #define	MAXPATHLEN	PATH_MAX
135389af1dfSmckusic #define MAXSYMLINKS	8
136389af1dfSmckusic 
137*9ae9ad29Sbostic /* Bit map related macros. */
138ab090aa7Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
139ab090aa7Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
140ab090aa7Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
141ab090aa7Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
142ab090aa7Skarels 
143*9ae9ad29Sbostic /* Macros for counting and rounding. */
144ab090aa7Skarels #ifndef howmany
145ab090aa7Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
146ab090aa7Skarels #endif
147ab090aa7Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
148ab090aa7Skarels #define powerof2(x)	((((x)-1)&(x))==0)
149ab090aa7Skarels 
150*9ae9ad29Sbostic /* Macros for fast min/max: with inline expansion, the "function" is faster. */
151ab090aa7Skarels #ifdef KERNEL
152ab090aa7Skarels #define	MIN(a,b) min((a), (b))
153ab090aa7Skarels #define	MAX(a,b) max((a), (b))
154ab090aa7Skarels #else
155ab090aa7Skarels #define	MIN(a,b) (((a)<(b))?(a):(b))
156ab090aa7Skarels #define	MAX(a,b) (((a)>(b))?(a):(b))
157ab090aa7Skarels #endif
158ab090aa7Skarels 
159ab090aa7Skarels /*
1602fe64d92Smckusick  * Constants for setting the parameters of the kernel memory allocator.
1612fe64d92Smckusick  *
1622fe64d92Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
1632fe64d92Smckusick  * allocated. It must be at least large enough to hold a pointer.
1642fe64d92Smckusick  *
1652fe64d92Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
1662fe64d92Smckusick  * allocate physical memory; requests for these size pieces of
1672fe64d92Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
1682fe64d92Smckusick  * always allocate and free physical memory; requests for these
1692fe64d92Smckusick  * size allocations should be done infrequently as they will be slow.
170*9ae9ad29Sbostic  *
171*9ae9ad29Sbostic  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
172*9ae9ad29Sbostic  * MAXALLOCSIZE must be a power of two.
1732fe64d92Smckusick  */
1742fe64d92Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
1752fe64d92Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
1762fe64d92Smckusick 
1772fe64d92Smckusick /*
1784233ee38Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
1794233ee38Smckusick  *
1804233ee38Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
1814233ee38Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
1824233ee38Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
1834233ee38Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
1844233ee38Smckusick  *
1854233ee38Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
1864233ee38Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
1874233ee38Smckusick  */
1884233ee38Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
1894233ee38Smckusick #define FSCALE	(1<<FSHIFT)
190