xref: /original-bsd/sys/sys/param.h (revision f1324ba5)
1 /*
2  * Copyright (c) 1982, 1986 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.6 (Berkeley) 10/18/88
7  */
8 
9 #define	BSD	198810		/* system version  (year & month) */
10 #define BSD4_3	1
11 
12 /*
13  * Machine-independent constants
14  */
15 #define	NMOUNT	20		/* number of mountable file systems */
16 /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
17 #define	MSWAPX	NMOUNT		/* pseudo mount table index for swapdev */
18 #define	MAXUPRC	40		/* max processes per user */
19 #define	NOFILE	64		/* max open files per process */
20 #define	CANBSIZ	256		/* max size of typewriter line */
21 #define	NCARGS	20480		/* # characters in exec arglist */
22 #define	MAXINTERP	32	/* maximum interpreter file name length */
23 #define	NGROUPS	16		/* max number groups */
24 #define MAXHOSTNAMELEN	64	/* maximum hostname size */
25 
26 #define	NOGROUP	65535		/* marker for empty group set member */
27 
28 /*
29  * Priorities
30  */
31 #define	PSWP	0
32 #define	PINOD	10
33 #define	PRIBIO	20
34 #define	PRIUBA	24
35 #define	PZERO	25
36 #define	PPIPE	26
37 #define	PWAIT	30
38 #define	PLOCK	35
39 #define	PSLEP	40
40 #define	PUSER	50
41 
42 #define	NZERO	0
43 
44 #ifndef KERNEL
45 #include	<sys/types.h>
46 #else
47 #ifndef LOCORE
48 #include	"types.h"
49 #endif
50 #endif
51 
52 /*
53  * Signals
54  */
55 #ifdef KERNEL
56 #include "signal.h"
57 #else
58 #include <signal.h>
59 #endif
60 
61 #define	ISSIG(p) \
62 	((p)->p_sig && ((p)->p_flag&STRC || \
63 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
64 
65 /*
66  * Machine type dependent parameters.
67  */
68 #ifdef KERNEL
69 #include "../machine/machparam.h"
70 #else
71 #include <machine/machparam.h>
72 #endif
73 
74 #define	NBPW	sizeof(int)	/* number of bytes in an integer */
75 
76 #define	NULL	0
77 #define	CMASK	022		/* default mask for file creation */
78 #define	NODEV	(dev_t)(-1)
79 
80 /*
81  * Clustering of hardware pages on machines with ridiculously small
82  * page sizes is done here.  The paging subsystem deals with units of
83  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
84  *
85  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
86  */
87 #define	CLBYTES		(CLSIZE*NBPG)
88 #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
89 #define	claligned(x)	((((int)(x))&CLOFSET)==0)
90 #define	CLOFF		CLOFSET
91 #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
92 
93 #if CLSIZE==1
94 #define	clbase(i)	(i)
95 #define	clrnd(i)	(i)
96 #else
97 /* give the base virtual address (first of CLSIZE) */
98 #define	clbase(i)	((i) &~ (CLSIZE-1))
99 /* round a number of clicks up to a whole cluster */
100 #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
101 #endif
102 
103 /* CBLOCK is the size of a clist block, must be power of 2 */
104 #define	CBLOCK	64
105 #define CBQSIZE	(CBLOCK/NBBY)	/* quote bytes/cblock - can do better */
106 #define	CBSIZE	(CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
107 #define	CROUND	(CBLOCK - 1)				/* clist rounding */
108 
109 /*
110  * File system parameters and macros.
111  *
112  * The file system is made out of blocks of at most MAXBSIZE units,
113  * with smaller units (fragments) only in the last direct block.
114  * MAXBSIZE primarily determines the size of buffers in the buffer
115  * pool. It may be made larger without any effect on existing
116  * file systems; however making it smaller make make some file
117  * systems unmountable.
118  *
119  * Note that the blocked devices are assumed to have DEV_BSIZE
120  * "sectors" and that fragments must be some multiple of this size.
121  * Block devices are read in BLKDEV_IOSIZE units. This number must
122  * be a power of two and in the range of
123  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
124  * This size has no effect upon the file system, but is usually set
125  * to the block size of the root file system, so as to maximize the
126  * speed of ``fsck''.
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	1024
143 #define MAXSYMLINKS	8
144 
145 /*
146  * Constants for setting the parameters of the kernel memory allocator.
147  *
148  * 2 ** MINBUCKET is the smallest unit of memory that will be
149  * allocated. It must be at least large enough to hold a pointer.
150  *
151  * Units of memory less or equal to MAXALLOCSAVE will permanently
152  * allocate physical memory; requests for these size pieces of
153  * memory are quite fast. Allocations greater than MAXALLOCSAVE must
154  * always allocate and free physical memory; requests for these
155  * size allocations should be done infrequently as they will be slow.
156  * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
157  * and MAXALLOCSIZE must be a power of two.
158  */
159 #define MINBUCKET	4		/* 4 => min allocation of 16 bytes */
160 #define MAXALLOCSAVE	(2 * CLBYTES)
161 
162 /*
163  * bit map related macros
164  */
165 #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
166 #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
167 #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
168 #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
169 
170 /*
171  * Macros for fast min/max.
172  */
173 #define	MIN(a,b) (((a)<(b))?(a):(b))
174 #define	MAX(a,b) (((a)>(b))?(a):(b))
175 
176 /*
177  * Macros for counting and rounding.
178  */
179 #ifndef howmany
180 #define	howmany(x, y)	(((x)+((y)-1))/(y))
181 #endif
182 #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
183 #define powerof2(x)	((((x)-1)&(x))==0)
184