xref: /original-bsd/sys/sys/param.h (revision e2944021)
1 /*
2  * Copyright (c) 1982 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	6.16 (Berkeley) 02/19/86
7  */
8 
9 #define	BSD	43		/* 4.3 * 10, as cpp doesn't do floats */
10 #define BSD4_3	1
11 
12 /*
13  * Machine type dependent parameters.
14  */
15 #ifdef KERNEL
16 #include "../machine/machparam.h"
17 #else
18 #include <machine/machparam.h>
19 #endif
20 
21 #define	NPTEPG		(NBPG/(sizeof (struct pte)))
22 
23 /*
24  * Machine-independent constants
25  */
26 #define	NMOUNT	20		/* number of mountable file systems */
27 /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
28 #define	MSWAPX	NMOUNT		/* pseudo mount table index for swapdev */
29 #define	MAXUPRC	40		/* max processes per user */
30 #define	NOFILE	64		/* max open files per process */
31 #define	CANBSIZ	256		/* max size of typewriter line */
32 #define	NCARGS	20480		/* # characters in exec arglist */
33 #define	NGROUPS	16		/* max number groups */
34 
35 #define	NOGROUP	65535		/* marker for empty group set member */
36 
37 /*
38  * Priorities
39  */
40 #define	PSWP	0
41 #define	PINOD	10
42 #define	PRIBIO	20
43 #define	PRIUBA	24
44 #define	PZERO	25
45 #define	PPIPE	26
46 #define	PWAIT	30
47 #define	PLOCK	35
48 #define	PSLEP	40
49 #define	PUSER	50
50 
51 #define	NZERO	0
52 
53 /*
54  * Signals
55  */
56 #ifdef KERNEL
57 #include "signal.h"
58 #else
59 #include <signal.h>
60 #endif
61 
62 #define	ISSIG(p) \
63 	((p)->p_sig && ((p)->p_flag&STRC || \
64 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
65 
66 #define	NBPW	sizeof(int)	/* number of bytes in an integer */
67 
68 #define	NULL	0
69 #define	CMASK	022		/* default mask for file creation */
70 #define	NODEV	(dev_t)(-1)
71 
72 /*
73  * Clustering of hardware pages on machines with ridiculously small
74  * page sizes is done here.  The paging subsystem deals with units of
75  * CLSIZE pte's describing NBPG (from vm.h) pages each.
76  *
77  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
78  */
79 #define	CLBYTES		(CLSIZE*NBPG)
80 #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
81 #define	claligned(x)	((((int)(x))&CLOFSET)==0)
82 #define	CLOFF		CLOFSET
83 #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
84 
85 #if CLSIZE==1
86 #define	clbase(i)	(i)
87 #define	clrnd(i)	(i)
88 #else
89 /* give the base virtual address (first of CLSIZE) */
90 #define	clbase(i)	((i) &~ (CLSIZE-1))
91 /* round a number of clicks up to a whole cluster */
92 #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
93 #endif
94 
95 /* CBLOCK is the size of a clist block, must be power of 2 */
96 #define	CBLOCK	64
97 #define	CBSIZE	(CBLOCK - sizeof(struct cblock *))	/* data chars/clist */
98 #define	CROUND	(CBLOCK - 1)				/* clist rounding */
99 
100 #ifndef KERNEL
101 #include	<sys/types.h>
102 #else
103 #ifndef LOCORE
104 #include	"types.h"
105 #endif
106 #endif
107 
108 /*
109  * File system parameters and macros.
110  *
111  * The file system is made out of blocks of at most MAXBSIZE units,
112  * with smaller units (fragments) only in the last direct block.
113  * MAXBSIZE primarily determines the size of buffers in the buffer
114  * pool. It may be made larger without any effect on existing
115  * file systems; however making it smaller make make some file
116  * systems unmountable.
117  *
118  * Note that the blocked devices are assumed to have DEV_BSIZE
119  * "sectors" and that fragments must be some multiple of this size.
120  * Block devices are read in BLKDEV_IOSIZE units. This number must
121  * be a power of two and in the range of
122  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
123  * This size has no effect upon the file system, but is usually set
124  * to the block size of the root file system, so as to maximize the
125  * speed of ``fsck''.
126  */
127 #define	MAXBSIZE	8192
128 #define	DEV_BSIZE	512
129 #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
130 #define BLKDEV_IOSIZE	2048
131 #define MAXFRAG 	8
132 
133 #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
134 	((unsigned)(bytes) >> DEV_BSHIFT)
135 #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
136 	((unsigned)(db) << DEV_BSHIFT)
137 
138 /*
139  * Map a ``block device block'' to a file system block.
140  * This should be device dependent, and will be after we
141  * add an entry to cdevsw for that purpose.  For now though
142  * just use DEV_BSIZE.
143  */
144 #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
145 
146 /*
147  * MAXPATHLEN defines the longest permissable path length
148  * after expanding symbolic links. It is used to allocate
149  * a temporary buffer from the buffer pool in which to do the
150  * name expansion, hence should be a power of two, and must
151  * be less than or equal to MAXBSIZE.
152  * MAXSYMLINKS defines the maximum number of symbolic links
153  * that may be expanded in a path name. It should be set high
154  * enough to allow all legitimate uses, but halt infinite loops
155  * reasonably quickly.
156  */
157 #define MAXPATHLEN	1024
158 #define MAXSYMLINKS	8
159 
160 /*
161  * bit map related macros
162  */
163 #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
164 #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
165 #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
166 #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
167 
168 /*
169  * Macros for fast min/max.
170  */
171 #define	MIN(a,b) (((a)<(b))?(a):(b))
172 #define	MAX(a,b) (((a)>(b))?(a):(b))
173 
174 /*
175  * Macros for counting and rounding.
176  */
177 #ifndef howmany
178 #define	howmany(x, y)	(((x)+((y)-1))/(y))
179 #endif
180 #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
181 
182 /*
183  * Maximum size of hostname recognized and stored in the kernel.
184  */
185 #define MAXHOSTNAMELEN	64
186