xref: /original-bsd/sys/sys/param.h (revision 2867d692)
165a1cfb1Smckusick /*
265a1cfb1Smckusick  * Copyright (c) 1982 Regents of the University of California.
365a1cfb1Smckusick  * All rights reserved.  The Berkeley software License Agreement
465a1cfb1Smckusick  * specifies the terms and conditions for redistribution.
565a1cfb1Smckusick  *
6*2867d692Sbloom  *	@(#)param.h	6.13 (Berkeley) 09/09/85
765a1cfb1Smckusick  */
85db792e4Sbill 
9*2867d692Sbloom #define	BSD	4.3
10*2867d692Sbloom #define BSD4_3
11*2867d692Sbloom 
125db792e4Sbill /*
134951e502Ssam  * Machine type dependent parameters.
145db792e4Sbill  */
158a98aca3Ssam #ifdef KERNEL
16d747881bSkarels #include "../machine/machparam.h"
178a98aca3Ssam #else
18d747881bSkarels #include <machine/machparam.h>
19b481cdefSroot #endif
205db792e4Sbill 
21b481cdefSroot #define	NPTEPG		(NBPG/(sizeof (struct pte)))
22b481cdefSroot 
23b481cdefSroot /*
24b481cdefSroot  * Machine-independent constants
25b481cdefSroot  */
2674c6c69bSkarels #define	NMOUNT	20		/* number of mountable file systems */
27f0028148Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
28818d21a2Skarels #define	MSWAPX	NMOUNT		/* pseudo mount table index for swapdev */
295db792e4Sbill #define	MAXUPRC	25		/* max processes per user */
30e3c8cc35Skarels #define	NOFILE	64		/* max open files per process */
315db792e4Sbill #define	CANBSIZ	256		/* max size of typewriter line */
3274c6c69bSkarels #define	NCARGS	20480		/* # characters in exec arglist */
330b98f570Skarels #define	NGROUPS	16		/* max number groups */
3445ac661dSwnj 
35e74c57f3Ssam #define	NOGROUP	-1		/* marker for empty group set member */
36e74c57f3Ssam 
375db792e4Sbill /*
38b481cdefSroot  * Priorities
395db792e4Sbill  */
405db792e4Sbill #define	PSWP	0
415db792e4Sbill #define	PINOD	10
425db792e4Sbill #define	PRIBIO	20
435db792e4Sbill #define	PRIUBA	24
445db792e4Sbill #define	PZERO	25
455db792e4Sbill #define	PPIPE	26
465db792e4Sbill #define	PWAIT	30
47bea46c20Ssam #define	PLOCK	35
485db792e4Sbill #define	PSLEP	40
495db792e4Sbill #define	PUSER	50
505db792e4Sbill 
5174c6c69bSkarels #define	NZERO	0
525db792e4Sbill 
535db792e4Sbill /*
54b481cdefSroot  * Signals
555db792e4Sbill  */
56586761c3Ssam #ifdef KERNEL
5764691dc4Sbloom #include "signal.h"
58586761c3Ssam #else
5946cc71adSbill #include <signal.h>
6046cc71adSbill #endif
61c6983186Sbill 
62586761c3Ssam #define	ISSIG(p) \
63586761c3Ssam 	((p)->p_sig && ((p)->p_flag&STRC || \
64eb2beebeSroot 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
6503c2128fSroot 
665db792e4Sbill #define	NBPW	sizeof(int)	/* number of bytes in an integer */
675db792e4Sbill 
685db792e4Sbill #define	NULL	0
69f0028148Skarels #define	CMASK	022		/* default mask for file creation */
705db792e4Sbill #define	NODEV	(dev_t)(-1)
715db792e4Sbill 
725db792e4Sbill /*
735db792e4Sbill  * Clustering of hardware pages on machines with ridiculously small
745db792e4Sbill  * page sizes is done here.  The paging subsystem deals with units of
75f0028148Skarels  * CLSIZE pte's describing NBPG (from vm.h) pages each.
765db792e4Sbill  *
775db792e4Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
785db792e4Sbill  */
79248881f8Swnj #define	CLBYTES		(CLSIZE*NBPG)
80e163c03cSwnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
81248881f8Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
82248881f8Swnj #define	CLOFF		CLOFSET
83b481cdefSroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
845db792e4Sbill 
85b481cdefSroot #if CLSIZE==1
86b481cdefSroot #define	clbase(i)	(i)
87b481cdefSroot #define	clrnd(i)	(i)
88b481cdefSroot #else
895db792e4Sbill /* give the base virtual address (first of CLSIZE) */
905db792e4Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
915db792e4Sbill /* round a number of clicks up to a whole cluster */
925db792e4Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
93b481cdefSroot #endif
945db792e4Sbill 
955db792e4Sbill #define	CBSIZE	28		/* number of chars in a clist block */
965db792e4Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
975db792e4Sbill 
9883a906b7Skarels #ifndef KERNEL
9983a906b7Skarels #include	<sys/types.h>
10083a906b7Skarels #else
10183a906b7Skarels #ifndef LOCORE
10283a906b7Skarels #include	"types.h"
10383a906b7Skarels #endif
10483a906b7Skarels #endif
10583a906b7Skarels 
1065db792e4Sbill /*
107389af1dfSmckusic  * File system parameters and macros.
108389af1dfSmckusic  *
109389af1dfSmckusic  * The file system is made out of blocks of at most MAXBSIZE units,
110389af1dfSmckusic  * with smaller units (fragments) only in the last direct block.
111389af1dfSmckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
112389af1dfSmckusic  * pool. It may be made larger without any effect on existing
113389af1dfSmckusic  * file systems; however making it smaller make make some file
114389af1dfSmckusic  * systems unmountable.
115389af1dfSmckusic  *
116389af1dfSmckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
117389af1dfSmckusic  * "sectors" and that fragments must be some multiple of this size.
11891d57239Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
11991d57239Smckusick  * be a power of two and in the range of
12091d57239Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
12191d57239Smckusick  * This size has no effect upon the file system, but is usually set
12291d57239Smckusick  * to the block size of the root file system, so as to maximize the
12391d57239Smckusick  * speed of ``fsck''.
124389af1dfSmckusic  */
125389af1dfSmckusic #define	MAXBSIZE	8192
126389af1dfSmckusic #define	DEV_BSIZE	512
127c6047a37Ssam #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
1281641975aSsam #define BLKDEV_IOSIZE	2048
129389af1dfSmckusic #define MAXFRAG 	8
130389af1dfSmckusic 
131c6047a37Ssam #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
132c6047a37Ssam 	((unsigned)(bytes) >> DEV_BSHIFT)
133c6047a37Ssam #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
134c6047a37Ssam 	((unsigned)(db) << DEV_BSHIFT)
135c6047a37Ssam 
136389af1dfSmckusic /*
137edc472f6Skre  * Map a ``block device block'' to a file system block.
138edc472f6Skre  * This should be device dependent, and will be after we
139edc472f6Skre  * add an entry to cdevsw for that purpose.  For now though
140edc472f6Skre  * just use DEV_BSIZE.
141edc472f6Skre  */
142b481cdefSroot #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
143edc472f6Skre 
144edc472f6Skre /*
145389af1dfSmckusic  * MAXPATHLEN defines the longest permissable path length
146389af1dfSmckusic  * after expanding symbolic links. It is used to allocate
147389af1dfSmckusic  * a temporary buffer from the buffer pool in which to do the
148389af1dfSmckusic  * name expansion, hence should be a power of two, and must
149389af1dfSmckusic  * be less than or equal to MAXBSIZE.
150389af1dfSmckusic  * MAXSYMLINKS defines the maximum number of symbolic links
151389af1dfSmckusic  * that may be expanded in a path name. It should be set high
152389af1dfSmckusic  * enough to allow all legitimate uses, but halt infinite loops
153389af1dfSmckusic  * reasonably quickly.
154389af1dfSmckusic  */
155389af1dfSmckusic #define MAXPATHLEN	1024
156389af1dfSmckusic #define MAXSYMLINKS	8
157389af1dfSmckusic 
158389af1dfSmckusic /*
159389af1dfSmckusic  * bit map related macros
160389af1dfSmckusic  */
161389af1dfSmckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
162389af1dfSmckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
163389af1dfSmckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
164389af1dfSmckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
165389af1dfSmckusic 
166389af1dfSmckusic /*
167389af1dfSmckusic  * Macros for fast min/max.
168389af1dfSmckusic  */
169389af1dfSmckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
170389af1dfSmckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
171389af1dfSmckusic 
172389af1dfSmckusic /*
173389af1dfSmckusic  * Macros for counting and rounding.
174389af1dfSmckusic  */
17583a906b7Skarels #ifndef howmany
176389af1dfSmckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
17783a906b7Skarels #endif
178389af1dfSmckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
179c446e4efSbloom 
180c446e4efSbloom /*
18135500b57Skarels  * Maximum size of hostname recognized and stored in the kernel.
182c446e4efSbloom  */
18335500b57Skarels #define MAXHOSTNAMELEN	64
184