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