xref: /csrg-svn/sys/sys/param.h (revision 30406)
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*30406Skarels  *	@(#)param.h	7.3 (Berkeley) 01/16/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 */
2217996Skarels #define	NGROUPS	16		/* max number groups */
23*30406Skarels #define MAXHOSTNAMELEN	64	/* maximum hostname size */
242751Swnj 
2526257Skarels #define	NOGROUP	65535		/* marker for empty group set member */
2611808Ssam 
2763Sbill /*
288993Sroot  * Priorities
2963Sbill  */
3063Sbill #define	PSWP	0
3163Sbill #define	PINOD	10
3263Sbill #define	PRIBIO	20
3363Sbill #define	PRIUBA	24
3463Sbill #define	PZERO	25
3563Sbill #define	PPIPE	26
3663Sbill #define	PWAIT	30
377688Ssam #define	PLOCK	35
3863Sbill #define	PSLEP	40
3963Sbill #define	PUSER	50
4063Sbill 
4117556Skarels #define	NZERO	0
4263Sbill 
43*30406Skarels #ifndef KERNEL
44*30406Skarels #include	<sys/types.h>
45*30406Skarels #else
46*30406Skarels #ifndef LOCORE
47*30406Skarels #include	"types.h"
48*30406Skarels #endif
49*30406Skarels #endif
50*30406Skarels 
5163Sbill /*
528993Sroot  * Signals
5363Sbill  */
5412880Ssam #ifdef KERNEL
5517033Sbloom #include "signal.h"
5612880Ssam #else
57176Sbill #include <signal.h>
58176Sbill #endif
5963Sbill 
6012880Ssam #define	ISSIG(p) \
6112880Ssam 	((p)->p_sig && ((p)->p_flag&STRC || \
6212965Sroot 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
638467Sroot 
64*30406Skarels /*
65*30406Skarels  * Machine type dependent parameters.
66*30406Skarels  */
67*30406Skarels #ifdef KERNEL
68*30406Skarels #include "../machine/machparam.h"
69*30406Skarels #else
70*30406Skarels #include <machine/machparam.h>
71*30406Skarels #endif
72*30406Skarels 
7312880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
7463Sbill 
7563Sbill #define	NULL	0
7616796Skarels #define	CMASK	022		/* default mask for file creation */
7763Sbill #define	NODEV	(dev_t)(-1)
7863Sbill 
7963Sbill /*
8063Sbill  * Clustering of hardware pages on machines with ridiculously small
8163Sbill  * page sizes is done here.  The paging subsystem deals with units of
82*30406Skarels  * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
8363Sbill  *
8463Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
8563Sbill  */
865080Swnj #define	CLBYTES		(CLSIZE*NBPG)
872637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
885080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
895080Swnj #define	CLOFF		CLOFSET
908993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
9163Sbill 
928993Sroot #if CLSIZE==1
938993Sroot #define	clbase(i)	(i)
948993Sroot #define	clrnd(i)	(i)
958993Sroot #else
9663Sbill /* give the base virtual address (first of CLSIZE) */
9763Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
9863Sbill /* round a number of clicks up to a whole cluster */
9963Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
1008993Sroot #endif
10163Sbill 
10224930Skarels /* CBLOCK is the size of a clist block, must be power of 2 */
10324930Skarels #define	CBLOCK	64
10424930Skarels #define	CBSIZE	(CBLOCK - sizeof(struct cblock *))	/* data chars/clist */
10524930Skarels #define	CROUND	(CBLOCK - 1)				/* clist rounding */
10663Sbill 
10763Sbill /*
1086564Smckusic  * File system parameters and macros.
1096564Smckusic  *
1106564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1116564Smckusic  * with smaller units (fragments) only in the last direct block.
1126564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1136564Smckusic  * pool. It may be made larger without any effect on existing
1146564Smckusic  * file systems; however making it smaller make make some file
1156564Smckusic  * systems unmountable.
1166564Smckusic  *
1176564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1186564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1197147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1207147Smckusick  * be a power of two and in the range of
1217147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1227147Smckusick  * This size has no effect upon the file system, but is usually set
1237147Smckusick  * to the block size of the root file system, so as to maximize the
1247147Smckusick  * speed of ``fsck''.
1253069Swnj  */
1266564Smckusic #define	MAXBSIZE	8192
1276564Smckusic #define MAXFRAG 	8
1286564Smckusic 
1296564Smckusic /*
1306564Smckusic  * MAXPATHLEN defines the longest permissable path length
1316564Smckusic  * after expanding symbolic links. It is used to allocate
1326564Smckusic  * a temporary buffer from the buffer pool in which to do the
1336564Smckusic  * name expansion, hence should be a power of two, and must
1346564Smckusic  * be less than or equal to MAXBSIZE.
1356564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1366564Smckusic  * that may be expanded in a path name. It should be set high
1376564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1386564Smckusic  * reasonably quickly.
1396564Smckusic  */
1406564Smckusic #define MAXPATHLEN	1024
1416564Smckusic #define MAXSYMLINKS	8
1426564Smckusic 
1436564Smckusic /*
1446564Smckusic  * bit map related macros
1456564Smckusic  */
1466564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1476564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1486564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1496564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1506564Smckusic 
1516564Smckusic /*
1526564Smckusic  * Macros for fast min/max.
1536564Smckusic  */
1546564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1556564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1566564Smckusic 
1576564Smckusic /*
1586564Smckusic  * Macros for counting and rounding.
1596564Smckusic  */
16023756Skarels #ifndef howmany
1616564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
16223756Skarels #endif
1636564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
164