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