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