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