xref: /original-bsd/sys/sys/param.h (revision ab9556f9)
19ae9ad29Sbostic /*-
283adbb3cSbostic  * Copyright (c) 1982, 1986, 1989, 1993
383adbb3cSbostic  *	The Regents of the University of California.  All rights reserved.
460749750Sbostic  * (c) UNIX System Laboratories, Inc.
560749750Sbostic  * All or some portions of this file are derived from material licensed
660749750Sbostic  * to the University of California by American Telephone and Telegraph
760749750Sbostic  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
860749750Sbostic  * the permission of UNIX System Laboratories, Inc.
965a1cfb1Smckusick  *
109ae9ad29Sbostic  * %sccs.include.redist.c%
119ae9ad29Sbostic  *
12*ab9556f9Smckusick  *	@(#)param.h	8.3 (Berkeley) 04/04/95
1365a1cfb1Smckusick  */
145db792e4Sbill 
15*ab9556f9Smckusick #define	BSD	199506		/* System version (year & month). */
161a9e6e3cSkarels #define BSD4_3	1
1750ed812dSbostic #define BSD4_4	1
182867d692Sbloom 
199ae9ad29Sbostic #ifndef NULL
209ae9ad29Sbostic #define	NULL	0
219ae9ad29Sbostic #endif
224a9959f4Sbostic 
231ba81c5bSkarels #ifndef LOCORE
241ba81c5bSkarels #include <sys/types.h>
251ba81c5bSkarels #endif
261ba81c5bSkarels 
275db792e4Sbill /*
289ae9ad29Sbostic  * Machine-independent constants (some used in following include files).
299ae9ad29Sbostic  * Redefined constants are from POSIX 1003.1 limits file.
309ae9ad29Sbostic  *
319ae9ad29Sbostic  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
329ae9ad29Sbostic  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
33b481cdefSroot  */
349ae9ad29Sbostic #include <sys/syslimits.h>
359ae9ad29Sbostic 
369ae9ad29Sbostic #define	MAXCOMLEN	16		/* max command name remembered */
3757ce53b7Skarels #define	MAXINTERP	32		/* max interpreter file name length */
389ae9ad29Sbostic #define	MAXLOGNAME	12		/* max login name length */
399ae9ad29Sbostic #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
409ae9ad29Sbostic #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
414a9959f4Sbostic #define	NGROUPS		NGROUPS_MAX	/* max number groups */
429ae9ad29Sbostic #define	NOFILE		OPEN_MAX	/* max open files per process */
43ebd4ffb8Skarels #define	NOGROUP		65535		/* marker for empty group set member */
449ae9ad29Sbostic #define MAXHOSTNAMELEN	256		/* max hostname size */
45e74c57f3Ssam 
469ae9ad29Sbostic /* More types and definitions used throughout the kernel. */
47f34b934bSkarels #ifdef KERNEL
48f34b934bSkarels #include <sys/cdefs.h>
49f34b934bSkarels #include <sys/errno.h>
50f34b934bSkarels #include <sys/time.h>
51f34b934bSkarels #include <sys/resource.h>
52f34b934bSkarels #include <sys/ucred.h>
53f34b934bSkarels #include <sys/uio.h>
54f34b934bSkarels #endif
55f34b934bSkarels 
569ae9ad29Sbostic /* Signals. */
570c67d176Skarels #include <sys/signal.h>
5803c2128fSroot 
599ae9ad29Sbostic /* Machine type dependent parameters. */
6064716fc5Sbostic #include <machine/param.h>
6164716fc5Sbostic #include <machine/limits.h>
62f520e942Skarels 
631ba81c5bSkarels /*
649ae9ad29Sbostic  * Priorities.  Note that with 32 run queues, differences less than 4 are
659ae9ad29Sbostic  * insignificant.
661ba81c5bSkarels  */
671ba81c5bSkarels #define	PSWP	0
681ba81c5bSkarels #define	PVM	4
691ba81c5bSkarels #define	PINOD	8
701ba81c5bSkarels #define	PRIBIO	16
711ba81c5bSkarels #define	PVFS	20
721041662dSkarels #define	PZERO	22		/* No longer magic, shouldn't be here.  XXX */
731ba81c5bSkarels #define	PSOCK	24
741ba81c5bSkarels #define	PWAIT	32
751ba81c5bSkarels #define	PLOCK	36
761ba81c5bSkarels #define	PPAUSE	40
771ba81c5bSkarels #define	PUSER	50
789ae9ad29Sbostic #define	MAXPRI	127		/* Priorities range from 0 through MAXPRI. */
791ba81c5bSkarels 
801ba81c5bSkarels #define	PRIMASK	0x0ff
819ae9ad29Sbostic #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
821ba81c5bSkarels 
831ba81c5bSkarels #define	NZERO	0		/* default "nice" */
841ba81c5bSkarels 
859ae9ad29Sbostic #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
865db792e4Sbill 
879ae9ad29Sbostic #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
889ae9ad29Sbostic #define	NODEV	(dev_t)(-1)	/* non-existent device */
895db792e4Sbill 
905db792e4Sbill /*
915db792e4Sbill  * Clustering of hardware pages on machines with ridiculously small
925db792e4Sbill  * page sizes is done here.  The paging subsystem deals with units of
93f520e942Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
945db792e4Sbill  */
95248881f8Swnj #define	CLBYTES		(CLSIZE*NBPG)
96e163c03cSwnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
97248881f8Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
98248881f8Swnj #define	CLOFF		CLOFSET
99b481cdefSroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
1005db792e4Sbill 
101b481cdefSroot #if CLSIZE==1
102b481cdefSroot #define	clbase(i)	(i)
103b481cdefSroot #define	clrnd(i)	(i)
104b481cdefSroot #else
1059ae9ad29Sbostic /* Give the base virtual address (first of CLSIZE). */
1065db792e4Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
1079ae9ad29Sbostic /* Round a number of clicks up to a whole cluster. */
1085db792e4Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
109b481cdefSroot #endif
1105db792e4Sbill 
1119ae9ad29Sbostic #define	CBLOCK	64		/* Clist block size, must be a power of 2. */
1129ae9ad29Sbostic #define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
1139ae9ad29Sbostic 				/* Data chars/clist. */
1149ae9ad29Sbostic #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
1159ae9ad29Sbostic #define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
1165db792e4Sbill 
1175db792e4Sbill /*
118389af1dfSmckusic  * File system parameters and macros.
119389af1dfSmckusic  *
1209ae9ad29Sbostic  * The file system is made out of blocks of at most MAXBSIZE units, with
1219ae9ad29Sbostic  * smaller units (fragments) only in the last direct block.  MAXBSIZE
1229ae9ad29Sbostic  * primarily determines the size of buffers in the buffer pool.  It may be
1239ae9ad29Sbostic  * made larger without any effect on existing file systems; however making
1249ae9ad29Sbostic  * it smaller make make some file systems unmountable.
125389af1dfSmckusic  */
1269433929dSmargo #define	MAXBSIZE	MAXPHYS
127389af1dfSmckusic #define MAXFRAG 	8
128389af1dfSmckusic 
129edc472f6Skre /*
1309ae9ad29Sbostic  * MAXPATHLEN defines the longest permissable path length after expanding
1319ae9ad29Sbostic  * symbolic links. It is used to allocate a temporary buffer from the buffer
1329ae9ad29Sbostic  * pool in which to do the name expansion, hence should be a power of two,
1339ae9ad29Sbostic  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
1349ae9ad29Sbostic  * maximum number of symbolic links that may be expanded in a path name.
1359ae9ad29Sbostic  * It should be set high enough to allow all legitimate uses, but halt
1369ae9ad29Sbostic  * infinite loops reasonably quickly.
137389af1dfSmckusic  */
1384a9959f4Sbostic #define	MAXPATHLEN	PATH_MAX
139389af1dfSmckusic #define MAXSYMLINKS	8
140389af1dfSmckusic 
1419ae9ad29Sbostic /* Bit map related macros. */
142ab090aa7Skarels #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
143ab090aa7Skarels #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
144ab090aa7Skarels #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
145ab090aa7Skarels #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
146ab090aa7Skarels 
1479ae9ad29Sbostic /* Macros for counting and rounding. */
148ab090aa7Skarels #ifndef howmany
149ab090aa7Skarels #define	howmany(x, y)	(((x)+((y)-1))/(y))
150ab090aa7Skarels #endif
151ab090aa7Skarels #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
152ab090aa7Skarels #define powerof2(x)	((((x)-1)&(x))==0)
153ab090aa7Skarels 
15403a7e507Sbostic /* Macros for min/max. */
15503a7e507Sbostic #ifndef KERNEL
156ab090aa7Skarels #define	MIN(a,b) (((a)<(b))?(a):(b))
157ab090aa7Skarels #define	MAX(a,b) (((a)>(b))?(a):(b))
158ab090aa7Skarels #endif
159ab090aa7Skarels 
160ab090aa7Skarels /*
1612fe64d92Smckusick  * Constants for setting the parameters of the kernel memory allocator.
1622fe64d92Smckusick  *
1632fe64d92Smckusick  * 2 ** MINBUCKET is the smallest unit of memory that will be
1642fe64d92Smckusick  * allocated. It must be at least large enough to hold a pointer.
1652fe64d92Smckusick  *
1662fe64d92Smckusick  * Units of memory less or equal to MAXALLOCSAVE will permanently
1672fe64d92Smckusick  * allocate physical memory; requests for these size pieces of
1682fe64d92Smckusick  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
1692fe64d92Smckusick  * always allocate and free physical memory; requests for these
1702fe64d92Smckusick  * size allocations should be done infrequently as they will be slow.
1719ae9ad29Sbostic  *
1729ae9ad29Sbostic  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
1739ae9ad29Sbostic  * MAXALLOCSIZE must be a power of two.
1742fe64d92Smckusick  */
1752fe64d92Smckusick #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
1762fe64d92Smckusick #define MAXALLOCSAVE	(2 * CLBYTES)
1772fe64d92Smckusick 
1782fe64d92Smckusick /*
1794233ee38Smckusick  * Scale factor for scaled integers used to count %cpu time and load avgs.
1804233ee38Smckusick  *
1814233ee38Smckusick  * The number of CPU `tick's that map to a unique `%age' can be expressed
1824233ee38Smckusick  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
1834233ee38Smckusick  * can be calculated (assuming 32 bits) can be closely approximated using
1844233ee38Smckusick  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
1854233ee38Smckusick  *
1864233ee38Smckusick  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
1874233ee38Smckusick  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
1884233ee38Smckusick  */
1894233ee38Smckusick #define	FSHIFT	11		/* bits to right of fixed binary point */
1904233ee38Smckusick #define FSCALE	(1<<FSHIFT)
191