xref: /csrg-svn/sys/sys/param.h (revision 23756)
123430Smckusick /*
223430Smckusick  * Copyright (c) 1982 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*23756Skarels  *	@(#)param.h	6.12 (Berkeley) 06/25/85
723430Smckusick  */
863Sbill 
963Sbill /*
1012508Ssam  * Machine type dependent parameters.
1163Sbill  */
129791Ssam #ifdef KERNEL
1317050Skarels #include "../machine/machparam.h"
149791Ssam #else
1517050Skarels #include <machine/machparam.h>
168993Sroot #endif
1763Sbill 
188993Sroot #define	NPTEPG		(NBPG/(sizeof (struct pte)))
198993Sroot 
208993Sroot /*
218993Sroot  * Machine-independent constants
228993Sroot  */
2317556Skarels #define	NMOUNT	20		/* number of mountable file systems */
2416796Skarels /* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
2515070Skarels #define	MSWAPX	NMOUNT		/* pseudo mount table index for swapdev */
2663Sbill #define	MAXUPRC	25		/* max processes per user */
2719955Skarels #define	NOFILE	64		/* max open files per process */
2863Sbill #define	CANBSIZ	256		/* max size of typewriter line */
2917556Skarels #define	NCARGS	20480		/* # characters in exec arglist */
3017996Skarels #define	NGROUPS	16		/* max number groups */
312751Swnj 
3211808Ssam #define	NOGROUP	-1		/* marker for empty group set member */
3311808Ssam 
3463Sbill /*
358993Sroot  * Priorities
3663Sbill  */
3763Sbill #define	PSWP	0
3863Sbill #define	PINOD	10
3963Sbill #define	PRIBIO	20
4063Sbill #define	PRIUBA	24
4163Sbill #define	PZERO	25
4263Sbill #define	PPIPE	26
4363Sbill #define	PWAIT	30
447688Ssam #define	PLOCK	35
4563Sbill #define	PSLEP	40
4663Sbill #define	PUSER	50
4763Sbill 
4817556Skarels #define	NZERO	0
4963Sbill 
5063Sbill /*
518993Sroot  * Signals
5263Sbill  */
5312880Ssam #ifdef KERNEL
5417033Sbloom #include "signal.h"
5512880Ssam #else
56176Sbill #include <signal.h>
57176Sbill #endif
5863Sbill 
5912880Ssam #define	ISSIG(p) \
6012880Ssam 	((p)->p_sig && ((p)->p_flag&STRC || \
6112965Sroot 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
628467Sroot 
6312880Ssam #define	NBPW	sizeof(int)	/* number of bytes in an integer */
6463Sbill 
6563Sbill #define	NULL	0
6616796Skarels #define	CMASK	022		/* default mask for file creation */
6763Sbill #define	NODEV	(dev_t)(-1)
6863Sbill 
6963Sbill /*
7063Sbill  * Clustering of hardware pages on machines with ridiculously small
7163Sbill  * page sizes is done here.  The paging subsystem deals with units of
7216796Skarels  * CLSIZE pte's describing NBPG (from vm.h) pages each.
7363Sbill  *
7463Sbill  * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
7563Sbill  */
765080Swnj #define	CLBYTES		(CLSIZE*NBPG)
772637Swnj #define	CLOFSET		(CLSIZE*NBPG-1)	/* for clusters, like PGOFSET */
785080Swnj #define	claligned(x)	((((int)(x))&CLOFSET)==0)
795080Swnj #define	CLOFF		CLOFSET
808993Sroot #define	CLSHIFT		(PGSHIFT+CLSIZELOG2)
8163Sbill 
828993Sroot #if CLSIZE==1
838993Sroot #define	clbase(i)	(i)
848993Sroot #define	clrnd(i)	(i)
858993Sroot #else
8663Sbill /* give the base virtual address (first of CLSIZE) */
8763Sbill #define	clbase(i)	((i) &~ (CLSIZE-1))
8863Sbill /* round a number of clicks up to a whole cluster */
8963Sbill #define	clrnd(i)	(((i) + (CLSIZE-1)) &~ (CLSIZE-1))
908993Sroot #endif
9163Sbill 
9263Sbill #ifndef INTRLVE
9363Sbill /* macros replacing interleaving functions */
9463Sbill #define	dkblock(bp)	((bp)->b_blkno)
9563Sbill #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
9663Sbill #endif
9763Sbill 
9863Sbill #define	CBSIZE	28		/* number of chars in a clist block */
9963Sbill #define	CROUND	0x1F		/* clist rounding; sizeof(int *) + CBSIZE -1*/
10063Sbill 
101*23756Skarels #ifndef KERNEL
102*23756Skarels #include	<sys/types.h>
103*23756Skarels #else
104*23756Skarels #ifndef LOCORE
105*23756Skarels #include	"types.h"
106*23756Skarels #endif
107*23756Skarels #endif
108*23756Skarels 
10963Sbill /*
1106564Smckusic  * File system parameters and macros.
1116564Smckusic  *
1126564Smckusic  * The file system is made out of blocks of at most MAXBSIZE units,
1136564Smckusic  * with smaller units (fragments) only in the last direct block.
1146564Smckusic  * MAXBSIZE primarily determines the size of buffers in the buffer
1156564Smckusic  * pool. It may be made larger without any effect on existing
1166564Smckusic  * file systems; however making it smaller make make some file
1176564Smckusic  * systems unmountable.
1186564Smckusic  *
1196564Smckusic  * Note that the blocked devices are assumed to have DEV_BSIZE
1206564Smckusic  * "sectors" and that fragments must be some multiple of this size.
1217147Smckusick  * Block devices are read in BLKDEV_IOSIZE units. This number must
1227147Smckusick  * be a power of two and in the range of
1237147Smckusick  *	DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
1247147Smckusick  * This size has no effect upon the file system, but is usually set
1257147Smckusick  * to the block size of the root file system, so as to maximize the
1267147Smckusick  * speed of ``fsck''.
1273069Swnj  */
1286564Smckusic #define	MAXBSIZE	8192
1296564Smckusic #define	DEV_BSIZE	512
13012651Ssam #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
13111225Ssam #define BLKDEV_IOSIZE	2048
1326564Smckusic #define MAXFRAG 	8
1336564Smckusic 
13412651Ssam #define	btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
13512651Ssam 	((unsigned)(bytes) >> DEV_BSHIFT)
13612651Ssam #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
13712651Ssam 	((unsigned)(db) << DEV_BSHIFT)
13812651Ssam 
1396564Smckusic /*
1407442Skre  * Map a ``block device block'' to a file system block.
1417442Skre  * This should be device dependent, and will be after we
1427442Skre  * add an entry to cdevsw for that purpose.  For now though
1437442Skre  * just use DEV_BSIZE.
1447442Skre  */
1458993Sroot #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
1467442Skre 
1477442Skre /*
1486564Smckusic  * MAXPATHLEN defines the longest permissable path length
1496564Smckusic  * after expanding symbolic links. It is used to allocate
1506564Smckusic  * a temporary buffer from the buffer pool in which to do the
1516564Smckusic  * name expansion, hence should be a power of two, and must
1526564Smckusic  * be less than or equal to MAXBSIZE.
1536564Smckusic  * MAXSYMLINKS defines the maximum number of symbolic links
1546564Smckusic  * that may be expanded in a path name. It should be set high
1556564Smckusic  * enough to allow all legitimate uses, but halt infinite loops
1566564Smckusic  * reasonably quickly.
1576564Smckusic  */
1586564Smckusic #define MAXPATHLEN	1024
1596564Smckusic #define MAXSYMLINKS	8
1606564Smckusic 
1616564Smckusic /*
1626564Smckusic  * bit map related macros
1636564Smckusic  */
1646564Smckusic #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
1656564Smckusic #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
1666564Smckusic #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
1676564Smckusic #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
1686564Smckusic 
1696564Smckusic /*
1706564Smckusic  * Macros for fast min/max.
1716564Smckusic  */
1726564Smckusic #define	MIN(a,b) (((a)<(b))?(a):(b))
1736564Smckusic #define	MAX(a,b) (((a)>(b))?(a):(b))
1746564Smckusic 
1756564Smckusic /*
1766564Smckusic  * Macros for counting and rounding.
1776564Smckusic  */
178*23756Skarels #ifndef howmany
1796564Smckusic #define	howmany(x, y)	(((x)+((y)-1))/(y))
180*23756Skarels #endif
1816564Smckusic #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
18222721Sbloom 
18322721Sbloom /*
18423521Skarels  * Maximum size of hostname recognized and stored in the kernel.
18522721Sbloom  */
18623521Skarels #define MAXHOSTNAMELEN	64
187