xref: /titanic_52/usr/src/boot/sys/sys/param.h (revision 4a5d661a82b942b6538acd26209d959ce98b593a)
1*4a5d661aSToomas Soome /*-
2*4a5d661aSToomas Soome  * Copyright (c) 1982, 1986, 1989, 1993
3*4a5d661aSToomas Soome  *	The Regents of the University of California.  All rights reserved.
4*4a5d661aSToomas Soome  * (c) UNIX System Laboratories, Inc.
5*4a5d661aSToomas Soome  * All or some portions of this file are derived from material licensed
6*4a5d661aSToomas Soome  * to the University of California by American Telephone and Telegraph
7*4a5d661aSToomas Soome  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8*4a5d661aSToomas Soome  * the permission of UNIX System Laboratories, Inc.
9*4a5d661aSToomas Soome  *
10*4a5d661aSToomas Soome  * Redistribution and use in source and binary forms, with or without
11*4a5d661aSToomas Soome  * modification, are permitted provided that the following conditions
12*4a5d661aSToomas Soome  * are met:
13*4a5d661aSToomas Soome  * 1. Redistributions of source code must retain the above copyright
14*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer.
15*4a5d661aSToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
16*4a5d661aSToomas Soome  *    notice, this list of conditions and the following disclaimer in the
17*4a5d661aSToomas Soome  *    documentation and/or other materials provided with the distribution.
18*4a5d661aSToomas Soome  * 4. Neither the name of the University nor the names of its contributors
19*4a5d661aSToomas Soome  *    may be used to endorse or promote products derived from this software
20*4a5d661aSToomas Soome  *    without specific prior written permission.
21*4a5d661aSToomas Soome  *
22*4a5d661aSToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*4a5d661aSToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*4a5d661aSToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*4a5d661aSToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*4a5d661aSToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*4a5d661aSToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*4a5d661aSToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*4a5d661aSToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*4a5d661aSToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*4a5d661aSToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*4a5d661aSToomas Soome  * SUCH DAMAGE.
33*4a5d661aSToomas Soome  *
34*4a5d661aSToomas Soome  *	@(#)param.h	8.3 (Berkeley) 4/4/95
35*4a5d661aSToomas Soome  * $FreeBSD$
36*4a5d661aSToomas Soome  */
37*4a5d661aSToomas Soome 
38*4a5d661aSToomas Soome #ifndef _SYS_PARAM_H_
39*4a5d661aSToomas Soome #define _SYS_PARAM_H_
40*4a5d661aSToomas Soome 
41*4a5d661aSToomas Soome #include <sys/_null.h>
42*4a5d661aSToomas Soome 
43*4a5d661aSToomas Soome #define	BSD	199506		/* System version (year & month). */
44*4a5d661aSToomas Soome #define BSD4_3	1
45*4a5d661aSToomas Soome #define BSD4_4	1
46*4a5d661aSToomas Soome 
47*4a5d661aSToomas Soome /*
48*4a5d661aSToomas Soome  * __FreeBSD_version numbers are documented in the Porter's Handbook.
49*4a5d661aSToomas Soome  * If you bump the version for any reason, you should update the documentation
50*4a5d661aSToomas Soome  * there.
51*4a5d661aSToomas Soome  * Currently this lives here in the doc/ repository:
52*4a5d661aSToomas Soome  *
53*4a5d661aSToomas Soome  *	head/en_US.ISO8859-1/books/porters-handbook/versions/chapter.xml
54*4a5d661aSToomas Soome  *
55*4a5d661aSToomas Soome  * scheme is:  <major><two digit minor>Rxx
56*4a5d661aSToomas Soome  *		'R' is in the range 0 to 4 if this is a release branch or
57*4a5d661aSToomas Soome  *		x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is
58*4a5d661aSToomas Soome  *		in the range 5 to 9.
59*4a5d661aSToomas Soome  */
60*4a5d661aSToomas Soome #undef __FreeBSD_version
61*4a5d661aSToomas Soome #define __FreeBSD_version 1100100	/* Master, propagated to newvers */
62*4a5d661aSToomas Soome 
63*4a5d661aSToomas Soome /*
64*4a5d661aSToomas Soome  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
65*4a5d661aSToomas Soome  * which by definition is always true on FreeBSD. This macro is also defined
66*4a5d661aSToomas Soome  * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD.
67*4a5d661aSToomas Soome  *
68*4a5d661aSToomas Soome  * It is tempting to use this macro in userland code when we want to enable
69*4a5d661aSToomas Soome  * kernel-specific routines, and in fact it's fine to do this in code that
70*4a5d661aSToomas Soome  * is part of FreeBSD itself.  However, be aware that as presence of this
71*4a5d661aSToomas Soome  * macro is still not widespread (e.g. older FreeBSD versions, 3rd party
72*4a5d661aSToomas Soome  * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in
73*4a5d661aSToomas Soome  * external applications without also checking for __FreeBSD__ as an
74*4a5d661aSToomas Soome  * alternative.
75*4a5d661aSToomas Soome  */
76*4a5d661aSToomas Soome #undef __FreeBSD_kernel__
77*4a5d661aSToomas Soome #define __FreeBSD_kernel__
78*4a5d661aSToomas Soome 
79*4a5d661aSToomas Soome #ifdef _KERNEL
80*4a5d661aSToomas Soome #define	P_OSREL_SIGWAIT			700000
81*4a5d661aSToomas Soome #define	P_OSREL_SIGSEGV			700004
82*4a5d661aSToomas Soome #define	P_OSREL_MAP_ANON		800104
83*4a5d661aSToomas Soome #define	P_OSREL_MAP_FSTRICT		1100036
84*4a5d661aSToomas Soome #define	P_OSREL_SHUTDOWN_ENOTCONN	1100077
85*4a5d661aSToomas Soome 
86*4a5d661aSToomas Soome #define	P_OSREL_MAJOR(x)		((x) / 100000)
87*4a5d661aSToomas Soome #endif
88*4a5d661aSToomas Soome 
89*4a5d661aSToomas Soome #ifndef LOCORE
90*4a5d661aSToomas Soome #include <sys/types.h>
91*4a5d661aSToomas Soome #endif
92*4a5d661aSToomas Soome 
93*4a5d661aSToomas Soome /*
94*4a5d661aSToomas Soome  * Machine-independent constants (some used in following include files).
95*4a5d661aSToomas Soome  * Redefined constants are from POSIX 1003.1 limits file.
96*4a5d661aSToomas Soome  *
97*4a5d661aSToomas Soome  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
98*4a5d661aSToomas Soome  */
99*4a5d661aSToomas Soome #include <sys/syslimits.h>
100*4a5d661aSToomas Soome 
101*4a5d661aSToomas Soome #define	MAXCOMLEN	19		/* max command name remembered */
102*4a5d661aSToomas Soome #define	MAXINTERP	PATH_MAX	/* max interpreter file name length */
103*4a5d661aSToomas Soome #define	MAXLOGNAME	33		/* max login name length (incl. NUL) */
104*4a5d661aSToomas Soome #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
105*4a5d661aSToomas Soome #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
106*4a5d661aSToomas Soome #define	NGROUPS		(NGROUPS_MAX+1)	/* max number groups */
107*4a5d661aSToomas Soome #define	NOFILE		OPEN_MAX	/* max open files per process */
108*4a5d661aSToomas Soome #define	NOGROUP		65535		/* marker for empty group set member */
109*4a5d661aSToomas Soome #define MAXHOSTNAMELEN	256		/* max hostname size */
110*4a5d661aSToomas Soome #define SPECNAMELEN	63		/* max length of devicename */
111*4a5d661aSToomas Soome 
112*4a5d661aSToomas Soome /* More types and definitions used throughout the kernel. */
113*4a5d661aSToomas Soome #ifdef _KERNEL
114*4a5d661aSToomas Soome #include <sys/cdefs.h>
115*4a5d661aSToomas Soome #include <sys/errno.h>
116*4a5d661aSToomas Soome #ifndef LOCORE
117*4a5d661aSToomas Soome #include <sys/time.h>
118*4a5d661aSToomas Soome #include <sys/priority.h>
119*4a5d661aSToomas Soome #endif
120*4a5d661aSToomas Soome 
121*4a5d661aSToomas Soome #ifndef FALSE
122*4a5d661aSToomas Soome #define	FALSE	0
123*4a5d661aSToomas Soome #endif
124*4a5d661aSToomas Soome #ifndef TRUE
125*4a5d661aSToomas Soome #define	TRUE	1
126*4a5d661aSToomas Soome #endif
127*4a5d661aSToomas Soome #endif
128*4a5d661aSToomas Soome 
129*4a5d661aSToomas Soome #ifndef _KERNEL
130*4a5d661aSToomas Soome /* Signals. */
131*4a5d661aSToomas Soome #include <sys/signal.h>
132*4a5d661aSToomas Soome #endif
133*4a5d661aSToomas Soome 
134*4a5d661aSToomas Soome /* Machine type dependent parameters. */
135*4a5d661aSToomas Soome #include <machine/param.h>
136*4a5d661aSToomas Soome #ifndef _KERNEL
137*4a5d661aSToomas Soome #include <sys/limits.h>
138*4a5d661aSToomas Soome #endif
139*4a5d661aSToomas Soome 
140*4a5d661aSToomas Soome #ifndef DEV_BSHIFT
141*4a5d661aSToomas Soome #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
142*4a5d661aSToomas Soome #endif
143*4a5d661aSToomas Soome #define	DEV_BSIZE	(1<<DEV_BSHIFT)
144*4a5d661aSToomas Soome 
145*4a5d661aSToomas Soome #ifndef BLKDEV_IOSIZE
146*4a5d661aSToomas Soome #define BLKDEV_IOSIZE  PAGE_SIZE	/* default block device I/O size */
147*4a5d661aSToomas Soome #endif
148*4a5d661aSToomas Soome #ifndef DFLTPHYS
149*4a5d661aSToomas Soome #define DFLTPHYS	(64 * 1024)	/* default max raw I/O transfer size */
150*4a5d661aSToomas Soome #endif
151*4a5d661aSToomas Soome #ifndef MAXPHYS
152*4a5d661aSToomas Soome #define MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
153*4a5d661aSToomas Soome #endif
154*4a5d661aSToomas Soome #ifndef MAXDUMPPGS
155*4a5d661aSToomas Soome #define MAXDUMPPGS	(DFLTPHYS/PAGE_SIZE)
156*4a5d661aSToomas Soome #endif
157*4a5d661aSToomas Soome 
158*4a5d661aSToomas Soome /*
159*4a5d661aSToomas Soome  * Constants related to network buffer management.
160*4a5d661aSToomas Soome  * MCLBYTES must be no larger than PAGE_SIZE.
161*4a5d661aSToomas Soome  */
162*4a5d661aSToomas Soome #ifndef	MSIZE
163*4a5d661aSToomas Soome #define	MSIZE		256		/* size of an mbuf */
164*4a5d661aSToomas Soome #endif
165*4a5d661aSToomas Soome 
166*4a5d661aSToomas Soome #ifndef	MCLSHIFT
167*4a5d661aSToomas Soome #define MCLSHIFT	11		/* convert bytes to mbuf clusters */
168*4a5d661aSToomas Soome #endif	/* MCLSHIFT */
169*4a5d661aSToomas Soome 
170*4a5d661aSToomas Soome #define MCLBYTES	(1 << MCLSHIFT)	/* size of an mbuf cluster */
171*4a5d661aSToomas Soome 
172*4a5d661aSToomas Soome #if PAGE_SIZE < 2048
173*4a5d661aSToomas Soome #define	MJUMPAGESIZE	MCLBYTES
174*4a5d661aSToomas Soome #elif PAGE_SIZE <= 8192
175*4a5d661aSToomas Soome #define	MJUMPAGESIZE	PAGE_SIZE
176*4a5d661aSToomas Soome #else
177*4a5d661aSToomas Soome #define	MJUMPAGESIZE	(8 * 1024)
178*4a5d661aSToomas Soome #endif
179*4a5d661aSToomas Soome 
180*4a5d661aSToomas Soome #define	MJUM9BYTES	(9 * 1024)	/* jumbo cluster 9k */
181*4a5d661aSToomas Soome #define	MJUM16BYTES	(16 * 1024)	/* jumbo cluster 16k */
182*4a5d661aSToomas Soome 
183*4a5d661aSToomas Soome /*
184*4a5d661aSToomas Soome  * Some macros for units conversion
185*4a5d661aSToomas Soome  */
186*4a5d661aSToomas Soome 
187*4a5d661aSToomas Soome /* clicks to bytes */
188*4a5d661aSToomas Soome #ifndef ctob
189*4a5d661aSToomas Soome #define ctob(x)	((x)<<PAGE_SHIFT)
190*4a5d661aSToomas Soome #endif
191*4a5d661aSToomas Soome 
192*4a5d661aSToomas Soome /* bytes to clicks */
193*4a5d661aSToomas Soome #ifndef btoc
194*4a5d661aSToomas Soome #define btoc(x)	(((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
195*4a5d661aSToomas Soome #endif
196*4a5d661aSToomas Soome 
197*4a5d661aSToomas Soome /*
198*4a5d661aSToomas Soome  * btodb() is messy and perhaps slow because `bytes' may be an off_t.  We
199*4a5d661aSToomas Soome  * want to shift an unsigned type to avoid sign extension and we don't
200*4a5d661aSToomas Soome  * want to widen `bytes' unnecessarily.  Assume that the result fits in
201*4a5d661aSToomas Soome  * a daddr_t.
202*4a5d661aSToomas Soome  */
203*4a5d661aSToomas Soome #ifndef btodb
204*4a5d661aSToomas Soome #define btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
205*4a5d661aSToomas Soome 	(sizeof (bytes) > sizeof(long) \
206*4a5d661aSToomas Soome 	 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
207*4a5d661aSToomas Soome 	 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
208*4a5d661aSToomas Soome #endif
209*4a5d661aSToomas Soome 
210*4a5d661aSToomas Soome #ifndef dbtob
211*4a5d661aSToomas Soome #define dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
212*4a5d661aSToomas Soome 	((off_t)(db) << DEV_BSHIFT)
213*4a5d661aSToomas Soome #endif
214*4a5d661aSToomas Soome 
215*4a5d661aSToomas Soome #define	PRIMASK	0x0ff
216*4a5d661aSToomas Soome #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
217*4a5d661aSToomas Soome #define	PDROP	0x200	/* OR'd with pri to stop re-entry of interlock mutex */
218*4a5d661aSToomas Soome 
219*4a5d661aSToomas Soome #define	NZERO	0		/* default "nice" */
220*4a5d661aSToomas Soome 
221*4a5d661aSToomas Soome #define	NBBY	8		/* number of bits in a byte */
222*4a5d661aSToomas Soome #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
223*4a5d661aSToomas Soome 
224*4a5d661aSToomas Soome #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
225*4a5d661aSToomas Soome 
226*4a5d661aSToomas Soome #define	NODEV	(dev_t)(-1)	/* non-existent device */
227*4a5d661aSToomas Soome 
228*4a5d661aSToomas Soome /*
229*4a5d661aSToomas Soome  * File system parameters and macros.
230*4a5d661aSToomas Soome  *
231*4a5d661aSToomas Soome  * MAXBSIZE -	Filesystems are made out of blocks of at most MAXBSIZE bytes
232*4a5d661aSToomas Soome  *		per block.  MAXBSIZE may be made larger without effecting
233*4a5d661aSToomas Soome  *		any existing filesystems as long as it does not exceed MAXPHYS,
234*4a5d661aSToomas Soome  *		and may be made smaller at the risk of not being able to use
235*4a5d661aSToomas Soome  *		filesystems which require a block size exceeding MAXBSIZE.
236*4a5d661aSToomas Soome  *
237*4a5d661aSToomas Soome  * MAXBCACHEBUF - Maximum size of a buffer in the buffer cache.  This must
238*4a5d661aSToomas Soome  *		be >= MAXBSIZE and can be set differently for different
239*4a5d661aSToomas Soome  *		architectures by defining it in <machine/param.h>.
240*4a5d661aSToomas Soome  *		Making this larger allows NFS to do larger reads/writes.
241*4a5d661aSToomas Soome  *
242*4a5d661aSToomas Soome  * BKVASIZE -	Nominal buffer space per buffer, in bytes.  BKVASIZE is the
243*4a5d661aSToomas Soome  *		minimum KVM memory reservation the kernel is willing to make.
244*4a5d661aSToomas Soome  *		Filesystems can of course request smaller chunks.  Actual
245*4a5d661aSToomas Soome  *		backing memory uses a chunk size of a page (PAGE_SIZE).
246*4a5d661aSToomas Soome  *		The default value here can be overridden on a per-architecture
247*4a5d661aSToomas Soome  *		basis by defining it in <machine/param.h>.  This should
248*4a5d661aSToomas Soome  *		probably be done to increase its value, when MAXBCACHEBUF is
249*4a5d661aSToomas Soome  *		defined as a larger value in <machine/param.h>.
250*4a5d661aSToomas Soome  *
251*4a5d661aSToomas Soome  *		If you make BKVASIZE too small you risk seriously fragmenting
252*4a5d661aSToomas Soome  *		the buffer KVM map which may slow things down a bit.  If you
253*4a5d661aSToomas Soome  *		make it too big the kernel will not be able to optimally use
254*4a5d661aSToomas Soome  *		the KVM memory reserved for the buffer cache and will wind
255*4a5d661aSToomas Soome  *		up with too-few buffers.
256*4a5d661aSToomas Soome  *
257*4a5d661aSToomas Soome  *		The default is 16384, roughly 2x the block size used by a
258*4a5d661aSToomas Soome  *		normal UFS filesystem.
259*4a5d661aSToomas Soome  */
260*4a5d661aSToomas Soome #define MAXBSIZE	65536	/* must be power of 2 */
261*4a5d661aSToomas Soome #ifndef	MAXBCACHEBUF
262*4a5d661aSToomas Soome #define	MAXBCACHEBUF	MAXBSIZE /* must be a power of 2 >= MAXBSIZE */
263*4a5d661aSToomas Soome #endif
264*4a5d661aSToomas Soome #ifndef	BKVASIZE
265*4a5d661aSToomas Soome #define BKVASIZE	16384	/* must be power of 2 */
266*4a5d661aSToomas Soome #endif
267*4a5d661aSToomas Soome #define BKVAMASK	(BKVASIZE-1)
268*4a5d661aSToomas Soome 
269*4a5d661aSToomas Soome /*
270*4a5d661aSToomas Soome  * MAXPATHLEN defines the longest permissible path length after expanding
271*4a5d661aSToomas Soome  * symbolic links. It is used to allocate a temporary buffer from the buffer
272*4a5d661aSToomas Soome  * pool in which to do the name expansion, hence should be a power of two,
273*4a5d661aSToomas Soome  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
274*4a5d661aSToomas Soome  * maximum number of symbolic links that may be expanded in a path name.
275*4a5d661aSToomas Soome  * It should be set high enough to allow all legitimate uses, but halt
276*4a5d661aSToomas Soome  * infinite loops reasonably quickly.
277*4a5d661aSToomas Soome  */
278*4a5d661aSToomas Soome #define	MAXPATHLEN	PATH_MAX
279*4a5d661aSToomas Soome #define MAXSYMLINKS	32
280*4a5d661aSToomas Soome 
281*4a5d661aSToomas Soome /* Bit map related macros. */
282*4a5d661aSToomas Soome #define	setbit(a,i)	(((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
283*4a5d661aSToomas Soome #define	clrbit(a,i)	(((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
284*4a5d661aSToomas Soome #define	isset(a,i)							\
285*4a5d661aSToomas Soome 	(((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
286*4a5d661aSToomas Soome #define	isclr(a,i)							\
287*4a5d661aSToomas Soome 	((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
288*4a5d661aSToomas Soome 
289*4a5d661aSToomas Soome /* Macros for counting and rounding. */
290*4a5d661aSToomas Soome #ifndef howmany
291*4a5d661aSToomas Soome #define	howmany(x, y)	(((x)+((y)-1))/(y))
292*4a5d661aSToomas Soome #endif
293*4a5d661aSToomas Soome #define	nitems(x)	(sizeof((x)) / sizeof((x)[0]))
294*4a5d661aSToomas Soome #define	rounddown(x, y)	(((x)/(y))*(y))
295*4a5d661aSToomas Soome #define	rounddown2(x, y) ((x)&(~((y)-1)))          /* if y is power of two */
296*4a5d661aSToomas Soome #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
297*4a5d661aSToomas Soome #define	roundup2(x, y)	(((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
298*4a5d661aSToomas Soome #define powerof2(x)	((((x)-1)&(x))==0)
299*4a5d661aSToomas Soome 
300*4a5d661aSToomas Soome /* Macros for min/max. */
301*4a5d661aSToomas Soome #define	MIN(a,b) (((a)<(b))?(a):(b))
302*4a5d661aSToomas Soome #define	MAX(a,b) (((a)>(b))?(a):(b))
303*4a5d661aSToomas Soome 
304*4a5d661aSToomas Soome #ifdef _KERNEL
305*4a5d661aSToomas Soome /*
306*4a5d661aSToomas Soome  * Basic byte order function prototypes for non-inline functions.
307*4a5d661aSToomas Soome  */
308*4a5d661aSToomas Soome #ifndef LOCORE
309*4a5d661aSToomas Soome #ifndef _BYTEORDER_PROTOTYPED
310*4a5d661aSToomas Soome #define	_BYTEORDER_PROTOTYPED
311*4a5d661aSToomas Soome __BEGIN_DECLS
312*4a5d661aSToomas Soome __uint32_t	 htonl(__uint32_t);
313*4a5d661aSToomas Soome __uint16_t	 htons(__uint16_t);
314*4a5d661aSToomas Soome __uint32_t	 ntohl(__uint32_t);
315*4a5d661aSToomas Soome __uint16_t	 ntohs(__uint16_t);
316*4a5d661aSToomas Soome __END_DECLS
317*4a5d661aSToomas Soome #endif
318*4a5d661aSToomas Soome #endif
319*4a5d661aSToomas Soome 
320*4a5d661aSToomas Soome #ifndef lint
321*4a5d661aSToomas Soome #ifndef _BYTEORDER_FUNC_DEFINED
322*4a5d661aSToomas Soome #define	_BYTEORDER_FUNC_DEFINED
323*4a5d661aSToomas Soome #define	htonl(x)	__htonl(x)
324*4a5d661aSToomas Soome #define	htons(x)	__htons(x)
325*4a5d661aSToomas Soome #define	ntohl(x)	__ntohl(x)
326*4a5d661aSToomas Soome #define	ntohs(x)	__ntohs(x)
327*4a5d661aSToomas Soome #endif /* !_BYTEORDER_FUNC_DEFINED */
328*4a5d661aSToomas Soome #endif /* lint */
329*4a5d661aSToomas Soome #endif /* _KERNEL */
330*4a5d661aSToomas Soome 
331*4a5d661aSToomas Soome /*
332*4a5d661aSToomas Soome  * Scale factor for scaled integers used to count %cpu time and load avgs.
333*4a5d661aSToomas Soome  *
334*4a5d661aSToomas Soome  * The number of CPU `tick's that map to a unique `%age' can be expressed
335*4a5d661aSToomas Soome  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
336*4a5d661aSToomas Soome  * can be calculated (assuming 32 bits) can be closely approximated using
337*4a5d661aSToomas Soome  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
338*4a5d661aSToomas Soome  *
339*4a5d661aSToomas Soome  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
340*4a5d661aSToomas Soome  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
341*4a5d661aSToomas Soome  */
342*4a5d661aSToomas Soome #define	FSHIFT	11		/* bits to right of fixed binary point */
343*4a5d661aSToomas Soome #define FSCALE	(1<<FSHIFT)
344*4a5d661aSToomas Soome 
345*4a5d661aSToomas Soome #define dbtoc(db)			/* calculates devblks to pages */ \
346*4a5d661aSToomas Soome 	((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
347*4a5d661aSToomas Soome 
348*4a5d661aSToomas Soome #define ctodb(db)			/* calculates pages to devblks */ \
349*4a5d661aSToomas Soome 	((db) << (PAGE_SHIFT - DEV_BSHIFT))
350*4a5d661aSToomas Soome 
351*4a5d661aSToomas Soome /*
352*4a5d661aSToomas Soome  * Old spelling of __containerof().
353*4a5d661aSToomas Soome  */
354*4a5d661aSToomas Soome #define	member2struct(s, m, x)						\
355*4a5d661aSToomas Soome 	((struct s *)(void *)((char *)(x) - offsetof(struct s, m)))
356*4a5d661aSToomas Soome 
357*4a5d661aSToomas Soome /*
358*4a5d661aSToomas Soome  * Access a variable length array that has been declared as a fixed
359*4a5d661aSToomas Soome  * length array.
360*4a5d661aSToomas Soome  */
361*4a5d661aSToomas Soome #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])
362*4a5d661aSToomas Soome 
363*4a5d661aSToomas Soome #endif	/* _SYS_PARAM_H_ */
364