xref: /titanic_41/usr/src/lib/libbc/inc/include/sys/param.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1989 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #ifndef	__sys_param_h
30*7c478bd9Sstevel@tonic-gate #define	__sys_param_h
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate /*
33*7c478bd9Sstevel@tonic-gate  * Machine type dependent parameters.
34*7c478bd9Sstevel@tonic-gate  */
35*7c478bd9Sstevel@tonic-gate #include <machine/param.h>
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #define	NPTEPG		(NBPG/(sizeof (struct pte)))
38*7c478bd9Sstevel@tonic-gate 
39*7c478bd9Sstevel@tonic-gate /*
40*7c478bd9Sstevel@tonic-gate  * Machine-independent constants
41*7c478bd9Sstevel@tonic-gate  */
42*7c478bd9Sstevel@tonic-gate #define	NMOUNT	40		/* est. of # mountable fs for quota calc */
43*7c478bd9Sstevel@tonic-gate #define	MSWAPX	15		/* pseudo mount table index for swapdev */
44*7c478bd9Sstevel@tonic-gate #define	MAXUPRC	25		/* max processes per user */
45*7c478bd9Sstevel@tonic-gate #define	NOFILE	256		/* max open files per process */
46*7c478bd9Sstevel@tonic-gate #define	MAXPID	30000		/* max process id */
47*7c478bd9Sstevel@tonic-gate #define	MAXUID	0xfffd		/* max user id (from 60000)  */
48*7c478bd9Sstevel@tonic-gate #define	MAXLINK	32767		/* max links */
49*7c478bd9Sstevel@tonic-gate #define	CANBSIZ	256		/* max size of typewriter line */
50*7c478bd9Sstevel@tonic-gate #define	VDISABLE 0		/* use this to turn off c_cc[i] */
51*7c478bd9Sstevel@tonic-gate #define	PIPE_BUF 4096		/* pipe buffer size */
52*7c478bd9Sstevel@tonic-gate #ifndef	KERNEL
53*7c478bd9Sstevel@tonic-gate /*
54*7c478bd9Sstevel@tonic-gate  * HZ defines the ticks/second for system calls, eg, times(), which
55*7c478bd9Sstevel@tonic-gate  * return values just in ticks; but not for getrusage(), which returns
56*7c478bd9Sstevel@tonic-gate  * values in ticks*pages.  HZ *must* be 60 for compatibility reasons.
57*7c478bd9Sstevel@tonic-gate  */
58*7c478bd9Sstevel@tonic-gate #define	HZ	60
59*7c478bd9Sstevel@tonic-gate #endif
60*7c478bd9Sstevel@tonic-gate #define	NCARGS	0x100000	/* (absolute) max # characters in exec arglist */
61*7c478bd9Sstevel@tonic-gate /* If NGROUPS changes, change <sys/limits.h> NGROUPS_MAX at the same time. */
62*7c478bd9Sstevel@tonic-gate #define	NGROUPS	16		/* max number groups */
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate #define	NOGROUP	-1		/* marker for empty group set member */
65*7c478bd9Sstevel@tonic-gate 
66*7c478bd9Sstevel@tonic-gate #ifdef	KERNEL
67*7c478bd9Sstevel@tonic-gate /*
68*7c478bd9Sstevel@tonic-gate  * Priorities
69*7c478bd9Sstevel@tonic-gate  */
70*7c478bd9Sstevel@tonic-gate #define	PMASK	0177
71*7c478bd9Sstevel@tonic-gate #define	PCATCH	0400		/* return if sleep interrupted, don't longjmp */
72*7c478bd9Sstevel@tonic-gate #define	PSWP	0
73*7c478bd9Sstevel@tonic-gate #define	PINOD	10
74*7c478bd9Sstevel@tonic-gate #define	PAMAP	10
75*7c478bd9Sstevel@tonic-gate #define	PRIBIO	20
76*7c478bd9Sstevel@tonic-gate #define	PRIUBA	24
77*7c478bd9Sstevel@tonic-gate #define	PZERO	25
78*7c478bd9Sstevel@tonic-gate #define	PPIPE	26
79*7c478bd9Sstevel@tonic-gate #define	PVFS	27
80*7c478bd9Sstevel@tonic-gate #define	PWAIT	30
81*7c478bd9Sstevel@tonic-gate #define	PLOCK	35
82*7c478bd9Sstevel@tonic-gate #define	PSLEP	40
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate #ifdef	VPIX
85*7c478bd9Sstevel@tonic-gate #define	PV86	41
86*7c478bd9Sstevel@tonic-gate #endif
87*7c478bd9Sstevel@tonic-gate 
88*7c478bd9Sstevel@tonic-gate #define	PFLCK	42	/* File/Record lock */
89*7c478bd9Sstevel@tonic-gate 
90*7c478bd9Sstevel@tonic-gate #define	PUSER	50
91*7c478bd9Sstevel@tonic-gate 
92*7c478bd9Sstevel@tonic-gate #define	NZERO	20
93*7c478bd9Sstevel@tonic-gate #endif	/* KERNEL */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate /*
96*7c478bd9Sstevel@tonic-gate  * Signals
97*7c478bd9Sstevel@tonic-gate  */
98*7c478bd9Sstevel@tonic-gate #include <sys/signal.h>
99*7c478bd9Sstevel@tonic-gate 
100*7c478bd9Sstevel@tonic-gate #define	ISSIG(p, flag) \
101*7c478bd9Sstevel@tonic-gate 	((p)->p_sig && ((p)->p_flag&STRC || \
102*7c478bd9Sstevel@tonic-gate 	 ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig(flag))
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate #define	NBPW	sizeof (int)	/* number of bytes in an integer */
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate #ifndef	NULL
107*7c478bd9Sstevel@tonic-gate #define	NULL	0
108*7c478bd9Sstevel@tonic-gate #endif
109*7c478bd9Sstevel@tonic-gate #define	CMASK	0		/* default mask for file creation */
110*7c478bd9Sstevel@tonic-gate #define	NODEV	(dev_t)(-1)
111*7c478bd9Sstevel@tonic-gate 
112*7c478bd9Sstevel@tonic-gate #ifndef	INTRLVE
113*7c478bd9Sstevel@tonic-gate /* macros replacing interleaving functions */
114*7c478bd9Sstevel@tonic-gate #define	dkblock(bp)	((bp)->b_blkno)
115*7c478bd9Sstevel@tonic-gate #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
116*7c478bd9Sstevel@tonic-gate #endif
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate #define	CBSIZE	28		/* number of chars in a clist block */
119*7c478bd9Sstevel@tonic-gate #define	CROUND	0x1F		/* clist rounding; sizeof (int *) + CBSIZE-1 */
120*7c478bd9Sstevel@tonic-gate 
121*7c478bd9Sstevel@tonic-gate #if	!defined(LOCORE) || !defined(KERNEL)
122*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
123*7c478bd9Sstevel@tonic-gate #endif
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate /*
126*7c478bd9Sstevel@tonic-gate  * File system parameters and macros.
127*7c478bd9Sstevel@tonic-gate  *
128*7c478bd9Sstevel@tonic-gate  * The file system is made out of blocks of at most MAXBSIZE units,
129*7c478bd9Sstevel@tonic-gate  * with smaller units (fragments) only in the last direct block.
130*7c478bd9Sstevel@tonic-gate  * MAXBSIZE primarily determines the size of buffers in the buffer
131*7c478bd9Sstevel@tonic-gate  * pool. It may be made larger without any effect on existing
132*7c478bd9Sstevel@tonic-gate  * file systems; however making it smaller make make some file
133*7c478bd9Sstevel@tonic-gate  * systems unmountable.
134*7c478bd9Sstevel@tonic-gate  *
135*7c478bd9Sstevel@tonic-gate  * Note that the blocked devices are assumed to have DEV_BSIZE
136*7c478bd9Sstevel@tonic-gate  * "sectors" and that fragments must be some multiple of this size.
137*7c478bd9Sstevel@tonic-gate  */
138*7c478bd9Sstevel@tonic-gate #define	MAXBSIZE	8192
139*7c478bd9Sstevel@tonic-gate #define	DEV_BSIZE	512
140*7c478bd9Sstevel@tonic-gate #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
141*7c478bd9Sstevel@tonic-gate #define	MAXFRAG 	8
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate #define	btodb(bytes)			/* calculates (bytes / DEV_BSIZE) */ \
144*7c478bd9Sstevel@tonic-gate 	((unsigned)(bytes) >> DEV_BSHIFT)
145*7c478bd9Sstevel@tonic-gate #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
146*7c478bd9Sstevel@tonic-gate 	((unsigned)(db) << DEV_BSHIFT)
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate /*
149*7c478bd9Sstevel@tonic-gate  * Map a ``block device block'' to a file system block.
150*7c478bd9Sstevel@tonic-gate  * XXX - this is currently only being used for tape drives.
151*7c478bd9Sstevel@tonic-gate  */
152*7c478bd9Sstevel@tonic-gate #define	BLKDEV_IOSIZE	2048
153*7c478bd9Sstevel@tonic-gate #define	bdbtofsb(bn)	((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
154*7c478bd9Sstevel@tonic-gate 
155*7c478bd9Sstevel@tonic-gate /*
156*7c478bd9Sstevel@tonic-gate  * MAXPATHLEN defines the longest permissable path length,
157*7c478bd9Sstevel@tonic-gate  * including the terminating null, after expanding symbolic links.
158*7c478bd9Sstevel@tonic-gate  * MAXSYMLINKS defines the maximum number of symbolic links
159*7c478bd9Sstevel@tonic-gate  * that may be expanded in a path name. It should be set high
160*7c478bd9Sstevel@tonic-gate  * enough to allow all legitimate uses, but halt infinite loops
161*7c478bd9Sstevel@tonic-gate  * reasonably quickly.
162*7c478bd9Sstevel@tonic-gate  */
163*7c478bd9Sstevel@tonic-gate #define	MAXPATHLEN	1024
164*7c478bd9Sstevel@tonic-gate #define	MAXSYMLINKS	20
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate /*
167*7c478bd9Sstevel@tonic-gate  * bit map related macros
168*7c478bd9Sstevel@tonic-gate  */
169*7c478bd9Sstevel@tonic-gate #define	setbit(a,i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
170*7c478bd9Sstevel@tonic-gate #define	clrbit(a,i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
171*7c478bd9Sstevel@tonic-gate #define	isset(a,i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
172*7c478bd9Sstevel@tonic-gate #define	isclr(a,i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate /*
175*7c478bd9Sstevel@tonic-gate  * Macros for fast min/max.
176*7c478bd9Sstevel@tonic-gate  */
177*7c478bd9Sstevel@tonic-gate #ifndef	MIN
178*7c478bd9Sstevel@tonic-gate #define	MIN(a,b) (((a)<(b))?(a):(b))
179*7c478bd9Sstevel@tonic-gate #endif
180*7c478bd9Sstevel@tonic-gate #ifndef	MAX
181*7c478bd9Sstevel@tonic-gate #define	MAX(a,b) (((a)>(b))?(a):(b))
182*7c478bd9Sstevel@tonic-gate #endif
183*7c478bd9Sstevel@tonic-gate 
184*7c478bd9Sstevel@tonic-gate /*
185*7c478bd9Sstevel@tonic-gate  * Macros for counting and rounding.
186*7c478bd9Sstevel@tonic-gate  */
187*7c478bd9Sstevel@tonic-gate #ifdef	sun386
188*7c478bd9Sstevel@tonic-gate #define	howmany(x, y)   ((((u_int)(x))+(((u_int)(y))-1))/((u_int)(y)))
189*7c478bd9Sstevel@tonic-gate #define	roundup(x, y)   ((((u_int)(x)+((u_int)(y)-1))/(u_int)(y))*(u_int)(y))
190*7c478bd9Sstevel@tonic-gate #else
191*7c478bd9Sstevel@tonic-gate #define	howmany(x, y)	(((x)+((y)-1))/(y))
192*7c478bd9Sstevel@tonic-gate #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
193*7c478bd9Sstevel@tonic-gate #endif
194*7c478bd9Sstevel@tonic-gate 
195*7c478bd9Sstevel@tonic-gate /*
196*7c478bd9Sstevel@tonic-gate  * Scale factor for scaled integers used to count
197*7c478bd9Sstevel@tonic-gate  * %cpu time and load averages.
198*7c478bd9Sstevel@tonic-gate  */
199*7c478bd9Sstevel@tonic-gate #define	FSHIFT	8		/* bits to right of fixed binary point */
200*7c478bd9Sstevel@tonic-gate #define	FSCALE	(1<<FSHIFT)
201*7c478bd9Sstevel@tonic-gate 
202*7c478bd9Sstevel@tonic-gate /*
203*7c478bd9Sstevel@tonic-gate  * Maximum size of hostname recognized and stored in the kernel.
204*7c478bd9Sstevel@tonic-gate  */
205*7c478bd9Sstevel@tonic-gate #define	MAXHOSTNAMELEN  64
206*7c478bd9Sstevel@tonic-gate 
207*7c478bd9Sstevel@tonic-gate #endif	/* !__sys_param_h */
208