xref: /illumos-gate/usr/src/ucbhead/sys/param.h (revision 4870e0a7)
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 2004 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 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * University Copyright- Copyright (c) 1982, 1986, 1988
32*7c478bd9Sstevel@tonic-gate  * The Regents of the University of California
33*7c478bd9Sstevel@tonic-gate  * All Rights Reserved
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * University Acknowledgment- Portions of this document are derived from
36*7c478bd9Sstevel@tonic-gate  * software developed by the University of California, Berkeley, and its
37*7c478bd9Sstevel@tonic-gate  * contributors.
38*7c478bd9Sstevel@tonic-gate  */
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_PARAM_H
41*7c478bd9Sstevel@tonic-gate #define	_SYS_PARAM_H
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate 
44*7c478bd9Sstevel@tonic-gate /*
45*7c478bd9Sstevel@tonic-gate  * Fundamental variables; don't change too often.
46*7c478bd9Sstevel@tonic-gate  *
47*7c478bd9Sstevel@tonic-gate  * This file is included here for compatibility with
48*7c478bd9Sstevel@tonic-gate  * SunOS, but it does *not* include all the values
49*7c478bd9Sstevel@tonic-gate  * define in the SunOS version of this file.
50*7c478bd9Sstevel@tonic-gate  */
51*7c478bd9Sstevel@tonic-gate 
52*7c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
53*7c478bd9Sstevel@tonic-gate #include <limits.h>
54*7c478bd9Sstevel@tonic-gate #include <unistd.h>
55*7c478bd9Sstevel@tonic-gate 
56*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
57*7c478bd9Sstevel@tonic-gate extern "C" {
58*7c478bd9Sstevel@tonic-gate #endif
59*7c478bd9Sstevel@tonic-gate 
60*7c478bd9Sstevel@tonic-gate #ifndef	MAX_INPUT
61*7c478bd9Sstevel@tonic-gate #define	MAX_INPUT	512	/* Maximum bytes stored in the input queue */
62*7c478bd9Sstevel@tonic-gate #endif
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate #ifndef	MAX_CANON
65*7c478bd9Sstevel@tonic-gate #define	MAX_CANON	256	/* Maximum bytes for canoical processing */
66*7c478bd9Sstevel@tonic-gate #endif
67*7c478bd9Sstevel@tonic-gate 
68*7c478bd9Sstevel@tonic-gate #define	UID_NOBODY	60001
69*7c478bd9Sstevel@tonic-gate #define	GID_NOBODY	60001
70*7c478bd9Sstevel@tonic-gate 
71*7c478bd9Sstevel@tonic-gate #define	UID_NOACCESS	60002	/* user ID no access */
72*7c478bd9Sstevel@tonic-gate 
73*7c478bd9Sstevel@tonic-gate #define	MAXPID	((pid_t)sysconf(_SC_MAXPID))	/* max process id */
74*7c478bd9Sstevel@tonic-gate #define	MAXUID	2147483647	/* max user id */
75*7c478bd9Sstevel@tonic-gate #define	MAXLINK	32767		/* max links */
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate #define	NMOUNT		40	/* est. of # mountable fs for quota calc */
78*7c478bd9Sstevel@tonic-gate 
79*7c478bd9Sstevel@tonic-gate /* The values below are defined in limits.h */
80*7c478bd9Sstevel@tonic-gate #define	NOFILE	OPEN_MAX	/* max open files per process */
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #define	CANBSIZ	256		/* max size of typewriter line	*/
83*7c478bd9Sstevel@tonic-gate #define	HZ	((int)sysconf(_SC_CLK_TCK))  /* ticks/second of the clock */
84*7c478bd9Sstevel@tonic-gate #define	TICK	(1000000000/((int)sysconf(_SC_CLK_TCK)))
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate #define	NCARGS	0x100000	/* # characters in exec arglist */
87*7c478bd9Sstevel@tonic-gate 				/*   must be multiple of NBPW.  */
88*7c478bd9Sstevel@tonic-gate /*
89*7c478bd9Sstevel@tonic-gate  * These define the maximum and minimum allowable values of the
90*7c478bd9Sstevel@tonic-gate  * configurable parameter NGROUPS_MAX.
91*7c478bd9Sstevel@tonic-gate  */
92*7c478bd9Sstevel@tonic-gate #define	NGROUPS_UMAX	32
93*7c478bd9Sstevel@tonic-gate #define	NGROUPS_UMIN	8
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate #define	NGROUPS		NGROUPS_MAX	/* max number groups, from limits.h */
96*7c478bd9Sstevel@tonic-gate #define	NOGROUP		-1	/* marker for empty group set member */
97*7c478bd9Sstevel@tonic-gate 
98*7c478bd9Sstevel@tonic-gate /*
99*7c478bd9Sstevel@tonic-gate  * Priorities.  Should not be altered too much.
100*7c478bd9Sstevel@tonic-gate  */
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate #define	PMASK	0177
103*7c478bd9Sstevel@tonic-gate #define	PCATCH	0400
104*7c478bd9Sstevel@tonic-gate #define	PNOSTOP	01000
105*7c478bd9Sstevel@tonic-gate #define	PSWP	0
106*7c478bd9Sstevel@tonic-gate #define	PINOD	10
107*7c478bd9Sstevel@tonic-gate #define	PSNDD	PINOD
108*7c478bd9Sstevel@tonic-gate #define	PAMAP	PINOD
109*7c478bd9Sstevel@tonic-gate #define	PPMAP	PINOD
110*7c478bd9Sstevel@tonic-gate #define	PRIBIO	20
111*7c478bd9Sstevel@tonic-gate #define	PZERO	25
112*7c478bd9Sstevel@tonic-gate #define	PMEM	0
113*7c478bd9Sstevel@tonic-gate #define	NZERO	20
114*7c478bd9Sstevel@tonic-gate #define	PPIPE	26
115*7c478bd9Sstevel@tonic-gate #define	PVFS	27
116*7c478bd9Sstevel@tonic-gate #define	PWAIT	30
117*7c478bd9Sstevel@tonic-gate #define	PLOCK	35
118*7c478bd9Sstevel@tonic-gate #define	PSLEP	39
119*7c478bd9Sstevel@tonic-gate #define	PUSER	60
120*7c478bd9Sstevel@tonic-gate #define	PIDLE	127
121*7c478bd9Sstevel@tonic-gate 
122*7c478bd9Sstevel@tonic-gate /*
123*7c478bd9Sstevel@tonic-gate  * Fundamental constants of the implementation--cannot be changed easily.
124*7c478bd9Sstevel@tonic-gate  */
125*7c478bd9Sstevel@tonic-gate 
126*7c478bd9Sstevel@tonic-gate #define	NBPS	0x20000		/* Number of bytes per segment */
127*7c478bd9Sstevel@tonic-gate #define	NBPW	sizeof (int)	/* number of bytes in an integer */
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate #define	CMASK	0		/* default mask for file creation */
130*7c478bd9Sstevel@tonic-gate #define	CDLIMIT	(1L<<11)	/* default max write address */
131*7c478bd9Sstevel@tonic-gate #define	NODEV	(dev_t)(-1)
132*7c478bd9Sstevel@tonic-gate #define	NBPSCTR		512	/* Bytes per disk sector.	*/
133*7c478bd9Sstevel@tonic-gate #define	UBSIZE		512	/* unix block size.		*/
134*7c478bd9Sstevel@tonic-gate #define	SCTRSHFT	9	/* Shift for BPSECT.		*/
135*7c478bd9Sstevel@tonic-gate 
136*7c478bd9Sstevel@tonic-gate #define	lobyte(X)	(((unsigned char *)&(X))[1])
137*7c478bd9Sstevel@tonic-gate #define	hibyte(X)	(((unsigned char *)&(X))[0])
138*7c478bd9Sstevel@tonic-gate #define	loword(X)	(((ushort_t *)&(X))[1])
139*7c478bd9Sstevel@tonic-gate #define	hiword(X)	(((ushort_t *)&(X))[0])
140*7c478bd9Sstevel@tonic-gate 
141*7c478bd9Sstevel@tonic-gate /* REMOTE -- whether machine is primary, secondary, or regular */
142*7c478bd9Sstevel@tonic-gate #define	SYSNAME 9		/* # chars in system name */
143*7c478bd9Sstevel@tonic-gate #define	PREMOTE 39
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate /*
146*7c478bd9Sstevel@tonic-gate  * MAXPATHLEN defines the longest permissible path length,
147*7c478bd9Sstevel@tonic-gate  * including the terminating null, after expanding symbolic links.
148*7c478bd9Sstevel@tonic-gate  * MAXSYMLINKS defines the maximum number of symbolic links
149*7c478bd9Sstevel@tonic-gate  * that may be expanded in a path name. It should be set high
150*7c478bd9Sstevel@tonic-gate  * enough to allow all legitimate uses, but halt infinite loops
151*7c478bd9Sstevel@tonic-gate  * reasonably quickly.
152*7c478bd9Sstevel@tonic-gate  * MAXNAMELEN is the length (including the terminating null) of
153*7c478bd9Sstevel@tonic-gate  * the longest permissible file (component) name.
154*7c478bd9Sstevel@tonic-gate  */
155*7c478bd9Sstevel@tonic-gate #define	MAXPATHLEN	1024
156*7c478bd9Sstevel@tonic-gate #define	MAXSYMLINKS	20
157*7c478bd9Sstevel@tonic-gate #define	MAXNAMELEN	256
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #ifndef	NADDR
160*7c478bd9Sstevel@tonic-gate #define	NADDR 13
161*7c478bd9Sstevel@tonic-gate #endif
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate /*
164*7c478bd9Sstevel@tonic-gate  * The following are defined to be the same as
165*7c478bd9Sstevel@tonic-gate  * defined in /usr/include/limits.h.  They are
166*7c478bd9Sstevel@tonic-gate  * needed for pipe and FIFO compatibility.
167*7c478bd9Sstevel@tonic-gate  */
168*7c478bd9Sstevel@tonic-gate #ifndef	PIPE_BUF	/* max # bytes atomic in write to a pipe */
169*7c478bd9Sstevel@tonic-gate #define	PIPE_BUF	5120
170*7c478bd9Sstevel@tonic-gate #endif	/* PIPE_BUF */
171*7c478bd9Sstevel@tonic-gate 
172*7c478bd9Sstevel@tonic-gate #ifndef	PIPE_MAX	/* max # bytes written to a pipe in a write */
173*7c478bd9Sstevel@tonic-gate #define	PIPE_MAX	5120
174*7c478bd9Sstevel@tonic-gate #endif	/* PIPE_MAX */
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate #define	PIPEBUF PIPE_BUF	/* pipe buffer size */
177*7c478bd9Sstevel@tonic-gate 
178*7c478bd9Sstevel@tonic-gate #ifndef	NBBY
179*7c478bd9Sstevel@tonic-gate #define	NBBY	8			/* number of bits per byte */
180*7c478bd9Sstevel@tonic-gate #endif
181*7c478bd9Sstevel@tonic-gate 
182*7c478bd9Sstevel@tonic-gate /* macros replacing interleaving functions */
183*7c478bd9Sstevel@tonic-gate #define	dkblock(bp)	((bp)->b_blkno)
184*7c478bd9Sstevel@tonic-gate #define	dkunit(bp)	(minor((bp)->b_dev) >> 3)
185*7c478bd9Sstevel@tonic-gate 
186*7c478bd9Sstevel@tonic-gate /*
187*7c478bd9Sstevel@tonic-gate  * File system parameters and macros.
188*7c478bd9Sstevel@tonic-gate  *
189*7c478bd9Sstevel@tonic-gate  * The file system is made out of blocks of at most MAXBSIZE units,
190*7c478bd9Sstevel@tonic-gate  * with smaller units (fragments) only in the last direct block.
191*7c478bd9Sstevel@tonic-gate  * MAXBSIZE primarily determines the size of buffers in the buffer
192*7c478bd9Sstevel@tonic-gate  * pool. It may be made larger without any effect on existing
193*7c478bd9Sstevel@tonic-gate  * file systems; however making it smaller make make some file
194*7c478bd9Sstevel@tonic-gate  * systems unmountable.
195*7c478bd9Sstevel@tonic-gate  *
196*7c478bd9Sstevel@tonic-gate  * Note that the blocked devices are assumed to have DEV_BSIZE
197*7c478bd9Sstevel@tonic-gate  * "sectors" and that fragments must be some multiple of this size.
198*7c478bd9Sstevel@tonic-gate  */
199*7c478bd9Sstevel@tonic-gate #define	MAXBSIZE	8192
200*7c478bd9Sstevel@tonic-gate #define	DEV_BSIZE	512
201*7c478bd9Sstevel@tonic-gate #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
202*7c478bd9Sstevel@tonic-gate #define	MAXFRAG 	8
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate #ifdef  _LP64
205*7c478bd9Sstevel@tonic-gate #define	MAXOFF_T	0x7fffffffffffffffl
206*7c478bd9Sstevel@tonic-gate #define	MAXOFFSET_T	0x7fffffffffffffffll
207*7c478bd9Sstevel@tonic-gate #else
208*7c478bd9Sstevel@tonic-gate #define	MAXOFF_T	0x7fffffff
209*7c478bd9Sstevel@tonic-gate #ifndef _LONGLONG_TYPE
210*7c478bd9Sstevel@tonic-gate #define	MAXOFFSET_T	0x7fffffff
211*7c478bd9Sstevel@tonic-gate #else
212*7c478bd9Sstevel@tonic-gate #define	MAXOFFSET_T	0x7fffffffffffffffLL
213*7c478bd9Sstevel@tonic-gate #endif
214*7c478bd9Sstevel@tonic-gate #endif  /* _LP64 */
215*7c478bd9Sstevel@tonic-gate 
216*7c478bd9Sstevel@tonic-gate #define	btodb(bytes)			/* calculates (bytes / DEV_BSIZE) */ \
217*7c478bd9Sstevel@tonic-gate 	((unsigned)(bytes) >> DEV_BSHIFT)
218*7c478bd9Sstevel@tonic-gate #define	dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
219*7c478bd9Sstevel@tonic-gate 	((unsigned)(db) << DEV_BSHIFT)
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate /*
222*7c478bd9Sstevel@tonic-gate  * PAGES* describes the logical page size used by the system.
223*7c478bd9Sstevel@tonic-gate  */
224*7c478bd9Sstevel@tonic-gate 
225*7c478bd9Sstevel@tonic-gate #define	PAGESIZE	(sysconf(_SC_PAGESIZE))	/* All the above, for logical */
226*7c478bd9Sstevel@tonic-gate #define	PAGEOFFSET	(PAGESIZE - 1)
227*7c478bd9Sstevel@tonic-gate #define	PAGEMASK	(~PAGEOFFSET)
228*7c478bd9Sstevel@tonic-gate 
229*7c478bd9Sstevel@tonic-gate /*
230*7c478bd9Sstevel@tonic-gate  * Some random macros for units conversion.
231*7c478bd9Sstevel@tonic-gate  */
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate /*
234*7c478bd9Sstevel@tonic-gate  * pages to bytes, and back (with and without rounding)
235*7c478bd9Sstevel@tonic-gate  */
236*7c478bd9Sstevel@tonic-gate #define	ptob(x)		((x) * PAGESIZE)
237*7c478bd9Sstevel@tonic-gate #define	btop(x)		(((unsigned)(x)) / PAGESIZE)
238*7c478bd9Sstevel@tonic-gate #define	btopr(x)	((((unsigned)(x) + PAGEOFFSET) / PAGESIZE))
239*7c478bd9Sstevel@tonic-gate 
240*7c478bd9Sstevel@tonic-gate /*
241*7c478bd9Sstevel@tonic-gate  * Signals
242*7c478bd9Sstevel@tonic-gate  */
243*7c478bd9Sstevel@tonic-gate 
244*7c478bd9Sstevel@tonic-gate #include <sys/signal.h>
245*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate /*
248*7c478bd9Sstevel@tonic-gate  * bit map related macros
249*7c478bd9Sstevel@tonic-gate  */
250*7c478bd9Sstevel@tonic-gate #define	setbit(a, i)	((a)[(i)/NBBY] |= 1<<((i)%NBBY))
251*7c478bd9Sstevel@tonic-gate #define	clrbit(a, i)	((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
252*7c478bd9Sstevel@tonic-gate #define	isset(a, i)	((a)[(i)/NBBY] & (1<<((i)%NBBY)))
253*7c478bd9Sstevel@tonic-gate #define	isclr(a, i)	(((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate /*
256*7c478bd9Sstevel@tonic-gate  * Macros for fast min/max.
257*7c478bd9Sstevel@tonic-gate  */
258*7c478bd9Sstevel@tonic-gate #ifndef	MIN
259*7c478bd9Sstevel@tonic-gate #define	MIN(a, b)	(((a) < (b))?(a):(b))
260*7c478bd9Sstevel@tonic-gate #endif
261*7c478bd9Sstevel@tonic-gate #ifndef	MAX
262*7c478bd9Sstevel@tonic-gate #define	MAX(a, b)	(((a) > (b))?(a):(b))
263*7c478bd9Sstevel@tonic-gate #endif
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate #define	howmany(x, y)	(((x)+((y)-1))/(y))
266*7c478bd9Sstevel@tonic-gate #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate /*
269*7c478bd9Sstevel@tonic-gate  * Scale factor for scaled integers used to count
270*7c478bd9Sstevel@tonic-gate  * %cpu time and load averages.
271*7c478bd9Sstevel@tonic-gate  */
272*7c478bd9Sstevel@tonic-gate #define	FSHIFT	8		/* bits to right of fixed binary point */
273*7c478bd9Sstevel@tonic-gate #define	FSCALE	(1<<FSHIFT)
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate /*
276*7c478bd9Sstevel@tonic-gate  * Maximum size of hostname recognized and stored in the kernel.
277*7c478bd9Sstevel@tonic-gate  * Same as in /usr/include/netdb.h
278*7c478bd9Sstevel@tonic-gate  */
279*7c478bd9Sstevel@tonic-gate #ifndef	MAXHOSTNAMELEN
280*7c478bd9Sstevel@tonic-gate #define	MAXHOSTNAMELEN	256
281*7c478bd9Sstevel@tonic-gate #endif
282*7c478bd9Sstevel@tonic-gate 
283*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus
284*7c478bd9Sstevel@tonic-gate }
285*7c478bd9Sstevel@tonic-gate #endif
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_PARAM_H */
288