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