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