xref: /original-bsd/sys/sys/param.h (revision 76c367be)
1 /*-
2  * Copyright (c) 1982, 1986, 1989 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)param.h	7.23 (Berkeley) 05/06/91
8  */
9 
10 #define	BSD	199103		/* March, 1991 system version (year & month) */
11 #define BSD4_3	1
12 #define BSD4_4	0.5
13 
14 #ifndef NULL
15 #define	NULL	0
16 #endif
17 
18 #ifndef LOCORE
19 #include <sys/types.h>
20 #endif
21 
22 /*
23  * Machine-independent constants (some used in following include files).
24  * Redefined constants are from POSIX 1003.1 limits file.
25  *
26  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
27  * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
28  */
29 #include <sys/syslimits.h>
30 
31 #define	MAXCOMLEN	16		/* max command name remembered */
32 #define	MAXINTERP	32		/* max interpreter file name length */
33 #define	MAXLOGNAME	12		/* max login name length */
34 #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
35 #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
36 #define	NGROUPS		NGROUPS_MAX	/* max number groups */
37 #define	NOFILE		OPEN_MAX	/* max open files per process */
38 #define	NOGROUP		65535		/* marker for empty group set member */
39 #define MAXHOSTNAMELEN	256		/* max hostname size */
40 
41 /* More types and definitions used throughout the kernel. */
42 #ifdef KERNEL
43 #include <sys/cdefs.h>
44 #include <sys/errno.h>
45 #include <sys/time.h>
46 #include <sys/resource.h>
47 #include <sys/ucred.h>
48 #include <sys/uio.h>
49 #endif
50 
51 /* Signals. */
52 #include <sys/signal.h>
53 
54 /* Machine type dependent parameters. */
55 #include <machine/param.h>
56 #include <machine/endian.h>
57 #include <machine/limits.h>
58 
59 /*
60  * Priorities.  Note that with 32 run queues, differences less than 4 are
61  * insignificant.
62  */
63 #define	PSWP	0
64 #define	PVM	4
65 #define	PINOD	8
66 #define	PRIBIO	16
67 #define	PVFS	20
68 #define	PZERO	22		/* No longer magic, shouldn't be here.  XXX */
69 #define	PSOCK	24
70 #define	PWAIT	32
71 #define	PLOCK	36
72 #define	PPAUSE	40
73 #define	PUSER	50
74 #define	MAXPRI	127		/* Priorities range from 0 through MAXPRI. */
75 
76 #define	PRIMASK	0x0ff
77 #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
78 
79 #define	NZERO	0		/* default "nice" */
80 
81 #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
82 
83 #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
84 #define	NODEV	(dev_t)(-1)	/* non-existent device */
85 
86 /*
87  * Clustering of hardware pages on machines with ridiculously small
88  * page sizes is done here.  The paging subsystem deals with units of
89  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
90  */
91 #define	CLBYTES		(CLSIZE*NBPG)
92 #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
93 #define	claligned(x)	((((int)(x))&CLOFSET)==0)
94 #define	CLOFF		CLOFSET
95 #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
96 
97 #if CLSIZE==1
98 #define	clbase(i)	(i)
99 #define	clrnd(i)	(i)
100 #else
101 /* Give the base virtual address (first of CLSIZE). */
102 #define	clbase(i)	((i) &~ (CLSIZE-1))
103 /* Round a number of clicks up to a whole cluster. */
104 #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
105 #endif
106 
107 #define	CBLOCK	64		/* Clist block size, must be a power of 2. */
108 #define CBQSIZE	(CBLOCK/NBBY)	/* Quote bytes/cblock - can do better. */
109 				/* Data chars/clist. */
110 #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE)
111 #define	CROUND	(CBLOCK - 1)	/* Clist rounding. */
112 
113 /*
114  * File system parameters and macros.
115  *
116  * The file system is made out of blocks of at most MAXBSIZE units, with
117  * smaller units (fragments) only in the last direct block.  MAXBSIZE
118  * primarily determines the size of buffers in the buffer pool.  It may be
119  * made larger without any effect on existing file systems; however making
120  * it smaller make make some file systems unmountable.
121  */
122 #define	MAXBSIZE	8192
123 #define MAXFRAG 	8
124 
125 /*
126  * MAXPATHLEN defines the longest permissable path length after expanding
127  * symbolic links. It is used to allocate a temporary buffer from the buffer
128  * pool in which to do the name expansion, hence should be a power of two,
129  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
130  * maximum number of symbolic links that may be expanded in a path name.
131  * It should be set high enough to allow all legitimate uses, but halt
132  * infinite loops reasonably quickly.
133  */
134 #define	MAXPATHLEN	PATH_MAX
135 #define MAXSYMLINKS	8
136 
137 /* Bit map related macros. */
138 #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
139 #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
140 #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
141 #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
142 
143 /* Macros for counting and rounding. */
144 #ifndef howmany
145 #define	howmany(x, y)	(((x)+((y)-1))/(y))
146 #endif
147 #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
148 #define powerof2(x)	((((x)-1)&(x))==0)
149 
150 /* Macros for fast min/max: with inline expansion, the "function" is faster. */
151 #ifdef KERNEL
152 #define	MIN(a,b) min((a), (b))
153 #define	MAX(a,b) max((a), (b))
154 #else
155 #define	MIN(a,b) (((a)<(b))?(a):(b))
156 #define	MAX(a,b) (((a)>(b))?(a):(b))
157 #endif
158 
159 /*
160  * Constants for setting the parameters of the kernel memory allocator.
161  *
162  * 2 ** MINBUCKET is the smallest unit of memory that will be
163  * allocated. It must be at least large enough to hold a pointer.
164  *
165  * Units of memory less or equal to MAXALLOCSAVE will permanently
166  * allocate physical memory; requests for these size pieces of
167  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
168  * always allocate and free physical memory; requests for these
169  * size allocations should be done infrequently as they will be slow.
170  *
171  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
172  * MAXALLOCSIZE must be a power of two.
173  */
174 #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
175 #define MAXALLOCSAVE	(2 * CLBYTES)
176 
177 /*
178  * Scale factor for scaled integers used to count %cpu time and load avgs.
179  *
180  * The number of CPU `tick's that map to a unique `%age' can be expressed
181  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
182  * can be calculated (assuming 32 bits) can be closely approximated using
183  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
184  *
185  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
186  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
187  */
188 #define	FSHIFT	11		/* bits to right of fixed binary point */
189 #define FSCALE	(1<<FSHIFT)
190