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