xref: /csrg-svn/sys/sys/param.h (revision 30576)
123430Smckusick /*
229036Smckusick  * Copyright (c) 1982, 1986 Regents of the University of California.
323430Smckusick  * All rights reserved.  The Berkeley software License Agreement
423430Smckusick  * specifies the terms and conditions for redistribution.
523430Smckusick  *
6*30576Sbostic  *	@(#)param.h	7.4 (Berkeley) 03/03/87
723430Smckusick  */
863Sbill 
925297Skarels #define	BSD	43		/* 4.3 * 10, as cpp doesn't do floats */
1025297Skarels #define BSD4_3	1
1124654Sbloom 
1263Sbill /*
138993Sroot  * Machine-independent constants
148993Sroot  */
1517556Skarels #define	NMOUNT	20		/* number of mountable file systems */
1616796Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
1715070Skarels #define	MSWAPX	NMOUNT		/* pseudo mount table index for swapdev */
1825297Skarels #define	MAXUPRC	40		/* max processes per user */
1919955Skarels #define	NOFILE	64		/* max open files per process */
2063Sbill #define	CANBSIZ	256		/* max size of typewriter line */
2117556Skarels #define	NCARGS	20480		/* # characters in exec arglist */
22*30576Sbostic #define	MAXINTERP	32	/* maximum interpreter file name length */
2317996Skarels #define	NGROUPS	16		/* max number groups */
2430406Skarels #define MAXHOSTNAMELEN	64	/* maximum hostname size */
252751Swnj 
2626257Skarels #define	NOGROUP	65535		/* marker for empty group set member */
2711808Ssam 
2863Sbill /*
298993Sroot  * Priorities
3063Sbill  */
3163Sbill #define	PSWP	0
3263Sbill #define	PINOD	10
3363Sbill #define	PRIBIO	20
3463Sbill #define	PRIUBA	24
3563Sbill #define	PZERO	25
3663Sbill #define	PPIPE	26
3763Sbill #define	PWAIT	30
387688Ssam #define	PLOCK	35
3963Sbill #define	PSLEP	40
4063Sbill #define	PUSER	50
4163Sbill 
4217556Skarels #define	NZERO	0
4363Sbill 
4430406Skarels #ifndef KERNEL
4530406Skarels #include	<sys/types.h>
4630406Skarels #else
4730406Skarels #ifndef LOCORE
4830406Skarels #include	"types.h"
4930406Skarels #endif
5030406Skarels #endif
5130406Skarels 
5263Sbill /*
538993Sroot  * Signals
5463Sbill  */
5512880Ssam #ifdef KERNEL
5617033Sbloom #include "signal.h"
5712880Ssam #else
58176Sbill #include <signal.h>
59176Sbill #endif
6063Sbill 
6112880Ssam #define	ISSIG(p) \
6212880Ssam 	((p)->p_sig && ((p)->p_flag&STRC || \
6312965Sroot 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
648467Sroot 
6530406Skarels /*
6630406Skarels  * Machine type dependent parameters.
6730406Skarels  */
6830406Skarels #ifdef KERNEL
6930406Skarels #include "../machine/machparam.h"
7030406Skarels #else
7130406Skarels #include <machine/machparam.h>
7230406Skarels #endif
7330406Skarels 
7412880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
7563Sbill 
7663Sbill #define	NULL	0
7716796Skarels #define	CMASK	022		/* default mask for file creation */
7863Sbill #define	NODEV	(dev_t)(-1)
7963Sbill 
8063Sbill /*
8163Sbill  * Clustering of hardware pages on machines with ridiculously small
8263Sbill  * page sizes is done here.  The paging subsystem deals with units of
8330406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
8463Sbill  *
8563Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8663Sbill  */
875080Swnj #define	CLBYTES		(CLSIZE*NBPG)
882637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
895080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
905080Swnj #define	CLOFF		CLOFSET
918993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
9263Sbill 
938993Sroot #if CLSIZE==1
948993Sroot #define	clbase(i)	(i)
958993Sroot #define	clrnd(i)	(i)
968993Sroot #else
9763Sbill /* give the base virtual address (first of CLSIZE) */
9863Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
9963Sbill /* round a number of clicks up to a whole cluster */
10063Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1018993Sroot #endif
10263Sbill 
10324930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */
10424930Skarels #define	CBLOCK	64
10524930Skarels #define	CBSIZE	(CBLOCK - sizeof(struct cblock *))	/* data chars/clist */
10624930Skarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
10763Sbill 
10863Sbill /*
1096564Smckusic  * File system parameters and macros.
1106564Smckusic  *
1116564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1126564Smckusic  * with smaller units (fragments) only in the last direct block.
1136564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1146564Smckusic  * pool. It may be made larger without any effect on existing
1156564Smckusic  * file systems; however making it smaller make make some file
1166564Smckusic  * systems unmountable.
1176564Smckusic  *
1186564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1196564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1207147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1217147Smckusick  * be a power of two and in the range of
1227147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1237147Smckusick  * This size has no effect upon the file system, but is usually set
1247147Smckusick  * to the block size of the root file system, so as to maximize the
1257147Smckusick  * speed of ``fsck''.
1263069Swnj  */
1276564Smckusic #define	MAXBSIZE	8192
1286564Smckusic #define MAXFRAG 	8
1296564Smckusic 
1306564Smckusic /*
1316564Smckusic  * MAXPATHLEN defines the longest permissable path length
1326564Smckusic  * after expanding symbolic links. It is used to allocate
1336564Smckusic  * a temporary buffer from the buffer pool in which to do the
1346564Smckusic  * name expansion, hence should be a power of two, and must
1356564Smckusic  * be less than or equal to MAXBSIZE.
1366564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1376564Smckusic  * that may be expanded in a path name. It should be set high
1386564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1396564Smckusic  * reasonably quickly.
1406564Smckusic  */
1416564Smckusic #define MAXPATHLEN	1024
1426564Smckusic #define MAXSYMLINKS	8
1436564Smckusic 
1446564Smckusic /*
1456564Smckusic  * bit map related macros
1466564Smckusic  */
1476564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1486564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1496564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1506564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1516564Smckusic 
1526564Smckusic /*
1536564Smckusic  * Macros for fast min/max.
1546564Smckusic  */
1556564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1566564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1576564Smckusic 
1586564Smckusic /*
1596564Smckusic  * Macros for counting and rounding.
1606564Smckusic  */
16123756Skarels #ifndef howmany
1626564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
16323756Skarels #endif
1646564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
165