xref: /illumos-gate/usr/src/boot/sys/sys/param.h (revision 55fea89d)
1199767f8SToomas Soome /*-
2199767f8SToomas Soome  * Copyright (c) 1982, 1986, 1989, 1993
3199767f8SToomas Soome  *	The Regents of the University of California.  All rights reserved.
4199767f8SToomas Soome  * (c) UNIX System Laboratories, Inc.
5199767f8SToomas Soome  * All or some portions of this file are derived from material licensed
6199767f8SToomas Soome  * to the University of California by American Telephone and Telegraph
7199767f8SToomas Soome  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8199767f8SToomas Soome  * the permission of UNIX System Laboratories, Inc.
9199767f8SToomas Soome  *
10199767f8SToomas Soome  * Redistribution and use in source and binary forms, with or without
11199767f8SToomas Soome  * modification, are permitted provided that the following conditions
12199767f8SToomas Soome  * are met:
13199767f8SToomas Soome  * 1. Redistributions of source code must retain the above copyright
14199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer.
15199767f8SToomas Soome  * 2. Redistributions in binary form must reproduce the above copyright
16199767f8SToomas Soome  *    notice, this list of conditions and the following disclaimer in the
17199767f8SToomas Soome  *    documentation and/or other materials provided with the distribution.
18199767f8SToomas Soome  * 4. Neither the name of the University nor the names of its contributors
19199767f8SToomas Soome  *    may be used to endorse or promote products derived from this software
20199767f8SToomas Soome  *    without specific prior written permission.
21199767f8SToomas Soome  *
22199767f8SToomas Soome  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23199767f8SToomas Soome  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24199767f8SToomas Soome  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25199767f8SToomas Soome  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26199767f8SToomas Soome  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27199767f8SToomas Soome  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28199767f8SToomas Soome  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29199767f8SToomas Soome  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30199767f8SToomas Soome  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31199767f8SToomas Soome  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32199767f8SToomas Soome  * SUCH DAMAGE.
33199767f8SToomas Soome  *
34199767f8SToomas Soome  *	@(#)param.h	8.3 (Berkeley) 4/4/95
35199767f8SToomas Soome  * $FreeBSD$
36199767f8SToomas Soome  */
37199767f8SToomas Soome 
38199767f8SToomas Soome #ifndef _SYS_PARAM_H_
39199767f8SToomas Soome #define _SYS_PARAM_H_
40199767f8SToomas Soome 
41199767f8SToomas Soome #include <sys/_null.h>
42199767f8SToomas Soome 
43199767f8SToomas Soome #define	BSD	199506		/* System version (year & month). */
44199767f8SToomas Soome #define BSD4_3	1
45199767f8SToomas Soome #define BSD4_4	1
46199767f8SToomas Soome 
47*55fea89dSDan Cross /*
48199767f8SToomas Soome  * __FreeBSD_version numbers are documented in the Porter's Handbook.
49199767f8SToomas Soome  * If you bump the version for any reason, you should update the documentation
50199767f8SToomas Soome  * there.
51199767f8SToomas Soome  * Currently this lives here in the doc/ repository:
52199767f8SToomas Soome  *
53199767f8SToomas Soome  *	head/en_US.ISO8859-1/books/porters-handbook/versions/chapter.xml
54199767f8SToomas Soome  *
55199767f8SToomas Soome  * scheme is:  <major><two digit minor>Rxx
56199767f8SToomas Soome  *		'R' is in the range 0 to 4 if this is a release branch or
57199767f8SToomas Soome  *		x.0-CURRENT before RELENG_*_0 is created, otherwise 'R' is
58199767f8SToomas Soome  *		in the range 5 to 9.
59199767f8SToomas Soome  */
60199767f8SToomas Soome #undef __FreeBSD_version
61199767f8SToomas Soome #define __FreeBSD_version 1100100	/* Master, propagated to newvers */
62199767f8SToomas Soome 
63199767f8SToomas Soome /*
64199767f8SToomas Soome  * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
65199767f8SToomas Soome  * which by definition is always true on FreeBSD. This macro is also defined
66199767f8SToomas Soome  * on other systems that use the kernel of FreeBSD, such as GNU/kFreeBSD.
67199767f8SToomas Soome  *
68199767f8SToomas Soome  * It is tempting to use this macro in userland code when we want to enable
69199767f8SToomas Soome  * kernel-specific routines, and in fact it's fine to do this in code that
70199767f8SToomas Soome  * is part of FreeBSD itself.  However, be aware that as presence of this
71199767f8SToomas Soome  * macro is still not widespread (e.g. older FreeBSD versions, 3rd party
72199767f8SToomas Soome  * compilers, etc), it is STRONGLY DISCOURAGED to check for this macro in
73199767f8SToomas Soome  * external applications without also checking for __FreeBSD__ as an
74199767f8SToomas Soome  * alternative.
75199767f8SToomas Soome  */
76199767f8SToomas Soome #undef __FreeBSD_kernel__
77199767f8SToomas Soome #define __FreeBSD_kernel__
78199767f8SToomas Soome 
79199767f8SToomas Soome #ifdef _KERNEL
80199767f8SToomas Soome #define	P_OSREL_SIGWAIT			700000
81199767f8SToomas Soome #define	P_OSREL_SIGSEGV			700004
82199767f8SToomas Soome #define	P_OSREL_MAP_ANON		800104
83199767f8SToomas Soome #define	P_OSREL_MAP_FSTRICT		1100036
84199767f8SToomas Soome #define	P_OSREL_SHUTDOWN_ENOTCONN	1100077
85199767f8SToomas Soome 
86199767f8SToomas Soome #define	P_OSREL_MAJOR(x)		((x) / 100000)
87199767f8SToomas Soome #endif
88199767f8SToomas Soome 
89199767f8SToomas Soome #ifndef LOCORE
90199767f8SToomas Soome #include <sys/types.h>
91199767f8SToomas Soome #endif
92199767f8SToomas Soome 
93199767f8SToomas Soome /*
94199767f8SToomas Soome  * Machine-independent constants (some used in following include files).
95199767f8SToomas Soome  * Redefined constants are from POSIX 1003.1 limits file.
96199767f8SToomas Soome  *
97199767f8SToomas Soome  * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
98199767f8SToomas Soome  */
99199767f8SToomas Soome #include <sys/syslimits.h>
100199767f8SToomas Soome 
101199767f8SToomas Soome #define	MAXCOMLEN	19		/* max command name remembered */
102199767f8SToomas Soome #define	MAXINTERP	PATH_MAX	/* max interpreter file name length */
103199767f8SToomas Soome #define	MAXLOGNAME	33		/* max login name length (incl. NUL) */
104199767f8SToomas Soome #define	MAXUPRC		CHILD_MAX	/* max simultaneous processes */
105199767f8SToomas Soome #define	NCARGS		ARG_MAX		/* max bytes for an exec function */
106199767f8SToomas Soome #define	NGROUPS		(NGROUPS_MAX+1)	/* max number groups */
107199767f8SToomas Soome #define	NOFILE		OPEN_MAX	/* max open files per process */
108199767f8SToomas Soome #define	NOGROUP		65535		/* marker for empty group set member */
109199767f8SToomas Soome #define MAXHOSTNAMELEN	256		/* max hostname size */
110199767f8SToomas Soome #define SPECNAMELEN	63		/* max length of devicename */
111199767f8SToomas Soome 
112199767f8SToomas Soome /* More types and definitions used throughout the kernel. */
113199767f8SToomas Soome #ifdef _KERNEL
114199767f8SToomas Soome #include <sys/cdefs.h>
115199767f8SToomas Soome #include <sys/errno.h>
116199767f8SToomas Soome #ifndef LOCORE
117199767f8SToomas Soome #include <sys/time.h>
118199767f8SToomas Soome #include <sys/priority.h>
119199767f8SToomas Soome #endif
120199767f8SToomas Soome 
121199767f8SToomas Soome #ifndef FALSE
122199767f8SToomas Soome #define	FALSE	0
123199767f8SToomas Soome #endif
124199767f8SToomas Soome #ifndef TRUE
125199767f8SToomas Soome #define	TRUE	1
126199767f8SToomas Soome #endif
127199767f8SToomas Soome #endif
128199767f8SToomas Soome 
129199767f8SToomas Soome #ifndef _KERNEL
130199767f8SToomas Soome /* Signals. */
131199767f8SToomas Soome #include <sys/signal.h>
132199767f8SToomas Soome #endif
133199767f8SToomas Soome 
134199767f8SToomas Soome /* Machine type dependent parameters. */
135199767f8SToomas Soome #include <machine/param.h>
136199767f8SToomas Soome #ifndef _KERNEL
137199767f8SToomas Soome #include <sys/limits.h>
138199767f8SToomas Soome #endif
139199767f8SToomas Soome 
140199767f8SToomas Soome #ifndef DEV_BSHIFT
141199767f8SToomas Soome #define	DEV_BSHIFT	9		/* log2(DEV_BSIZE) */
142199767f8SToomas Soome #endif
143199767f8SToomas Soome #define	DEV_BSIZE	(1<<DEV_BSHIFT)
144199767f8SToomas Soome 
145199767f8SToomas Soome #ifndef BLKDEV_IOSIZE
146199767f8SToomas Soome #define BLKDEV_IOSIZE  PAGE_SIZE	/* default block device I/O size */
147199767f8SToomas Soome #endif
148199767f8SToomas Soome #ifndef DFLTPHYS
149199767f8SToomas Soome #define DFLTPHYS	(64 * 1024)	/* default max raw I/O transfer size */
150199767f8SToomas Soome #endif
151199767f8SToomas Soome #ifndef MAXPHYS
152199767f8SToomas Soome #define MAXPHYS		(128 * 1024)	/* max raw I/O transfer size */
153199767f8SToomas Soome #endif
154199767f8SToomas Soome #ifndef MAXDUMPPGS
155199767f8SToomas Soome #define MAXDUMPPGS	(DFLTPHYS/PAGE_SIZE)
156199767f8SToomas Soome #endif
157199767f8SToomas Soome 
158199767f8SToomas Soome /*
159199767f8SToomas Soome  * Constants related to network buffer management.
160199767f8SToomas Soome  * MCLBYTES must be no larger than PAGE_SIZE.
161199767f8SToomas Soome  */
162199767f8SToomas Soome #ifndef	MSIZE
163199767f8SToomas Soome #define	MSIZE		256		/* size of an mbuf */
164199767f8SToomas Soome #endif
165199767f8SToomas Soome 
166199767f8SToomas Soome #ifndef	MCLSHIFT
167199767f8SToomas Soome #define MCLSHIFT	11		/* convert bytes to mbuf clusters */
168199767f8SToomas Soome #endif	/* MCLSHIFT */
169199767f8SToomas Soome 
170199767f8SToomas Soome #define MCLBYTES	(1 << MCLSHIFT)	/* size of an mbuf cluster */
171199767f8SToomas Soome 
172199767f8SToomas Soome #if PAGE_SIZE < 2048
173199767f8SToomas Soome #define	MJUMPAGESIZE	MCLBYTES
174199767f8SToomas Soome #elif PAGE_SIZE <= 8192
175199767f8SToomas Soome #define	MJUMPAGESIZE	PAGE_SIZE
176199767f8SToomas Soome #else
177199767f8SToomas Soome #define	MJUMPAGESIZE	(8 * 1024)
178199767f8SToomas Soome #endif
179199767f8SToomas Soome 
180199767f8SToomas Soome #define	MJUM9BYTES	(9 * 1024)	/* jumbo cluster 9k */
181199767f8SToomas Soome #define	MJUM16BYTES	(16 * 1024)	/* jumbo cluster 16k */
182199767f8SToomas Soome 
183199767f8SToomas Soome /*
184199767f8SToomas Soome  * Some macros for units conversion
185199767f8SToomas Soome  */
186199767f8SToomas Soome 
187199767f8SToomas Soome /* clicks to bytes */
188199767f8SToomas Soome #ifndef ctob
189199767f8SToomas Soome #define ctob(x)	((x)<<PAGE_SHIFT)
190199767f8SToomas Soome #endif
191199767f8SToomas Soome 
192199767f8SToomas Soome /* bytes to clicks */
193199767f8SToomas Soome #ifndef btoc
194199767f8SToomas Soome #define btoc(x)	(((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
195199767f8SToomas Soome #endif
196199767f8SToomas Soome 
197199767f8SToomas Soome /*
198199767f8SToomas Soome  * btodb() is messy and perhaps slow because `bytes' may be an off_t.  We
199199767f8SToomas Soome  * want to shift an unsigned type to avoid sign extension and we don't
200199767f8SToomas Soome  * want to widen `bytes' unnecessarily.  Assume that the result fits in
201199767f8SToomas Soome  * a daddr_t.
202199767f8SToomas Soome  */
203199767f8SToomas Soome #ifndef btodb
204199767f8SToomas Soome #define btodb(bytes)	 		/* calculates (bytes / DEV_BSIZE) */ \
205199767f8SToomas Soome 	(sizeof (bytes) > sizeof(long) \
206199767f8SToomas Soome 	 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
207199767f8SToomas Soome 	 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
208199767f8SToomas Soome #endif
209199767f8SToomas Soome 
210199767f8SToomas Soome #ifndef dbtob
211199767f8SToomas Soome #define dbtob(db)			/* calculates (db * DEV_BSIZE) */ \
212199767f8SToomas Soome 	((off_t)(db) << DEV_BSHIFT)
213199767f8SToomas Soome #endif
214199767f8SToomas Soome 
215199767f8SToomas Soome #define	PRIMASK	0x0ff
216199767f8SToomas Soome #define	PCATCH	0x100		/* OR'd with pri for tsleep to check signals */
217199767f8SToomas Soome #define	PDROP	0x200	/* OR'd with pri to stop re-entry of interlock mutex */
218199767f8SToomas Soome 
219199767f8SToomas Soome #define	NZERO	0		/* default "nice" */
220199767f8SToomas Soome 
221199767f8SToomas Soome #define	NBBY	8		/* number of bits in a byte */
222199767f8SToomas Soome #define	NBPW	sizeof(int)	/* number of bytes per word (integer) */
223199767f8SToomas Soome 
224199767f8SToomas Soome #define	CMASK	022		/* default file mask: S_IWGRP|S_IWOTH */
225199767f8SToomas Soome 
226199767f8SToomas Soome #define	NODEV	(dev_t)(-1)	/* non-existent device */
227199767f8SToomas Soome 
228199767f8SToomas Soome /*
229199767f8SToomas Soome  * File system parameters and macros.
230199767f8SToomas Soome  *
231199767f8SToomas Soome  * MAXBSIZE -	Filesystems are made out of blocks of at most MAXBSIZE bytes
232199767f8SToomas Soome  *		per block.  MAXBSIZE may be made larger without effecting
233199767f8SToomas Soome  *		any existing filesystems as long as it does not exceed MAXPHYS,
234199767f8SToomas Soome  *		and may be made smaller at the risk of not being able to use
235199767f8SToomas Soome  *		filesystems which require a block size exceeding MAXBSIZE.
236199767f8SToomas Soome  *
237199767f8SToomas Soome  * MAXBCACHEBUF - Maximum size of a buffer in the buffer cache.  This must
238199767f8SToomas Soome  *		be >= MAXBSIZE and can be set differently for different
239199767f8SToomas Soome  *		architectures by defining it in <machine/param.h>.
240199767f8SToomas Soome  *		Making this larger allows NFS to do larger reads/writes.
241199767f8SToomas Soome  *
242199767f8SToomas Soome  * BKVASIZE -	Nominal buffer space per buffer, in bytes.  BKVASIZE is the
243199767f8SToomas Soome  *		minimum KVM memory reservation the kernel is willing to make.
244*55fea89dSDan Cross  *		Filesystems can of course request smaller chunks.  Actual
245199767f8SToomas Soome  *		backing memory uses a chunk size of a page (PAGE_SIZE).
246199767f8SToomas Soome  *		The default value here can be overridden on a per-architecture
247199767f8SToomas Soome  *		basis by defining it in <machine/param.h>.  This should
248199767f8SToomas Soome  *		probably be done to increase its value, when MAXBCACHEBUF is
249199767f8SToomas Soome  *		defined as a larger value in <machine/param.h>.
250199767f8SToomas Soome  *
251199767f8SToomas Soome  *		If you make BKVASIZE too small you risk seriously fragmenting
252199767f8SToomas Soome  *		the buffer KVM map which may slow things down a bit.  If you
253*55fea89dSDan Cross  *		make it too big the kernel will not be able to optimally use
254*55fea89dSDan Cross  *		the KVM memory reserved for the buffer cache and will wind
255199767f8SToomas Soome  *		up with too-few buffers.
256199767f8SToomas Soome  *
257199767f8SToomas Soome  *		The default is 16384, roughly 2x the block size used by a
258199767f8SToomas Soome  *		normal UFS filesystem.
259199767f8SToomas Soome  */
260199767f8SToomas Soome #define MAXBSIZE	65536	/* must be power of 2 */
261199767f8SToomas Soome #ifndef	MAXBCACHEBUF
262199767f8SToomas Soome #define	MAXBCACHEBUF	MAXBSIZE /* must be a power of 2 >= MAXBSIZE */
263199767f8SToomas Soome #endif
264199767f8SToomas Soome #ifndef	BKVASIZE
265199767f8SToomas Soome #define BKVASIZE	16384	/* must be power of 2 */
266199767f8SToomas Soome #endif
267199767f8SToomas Soome #define BKVAMASK	(BKVASIZE-1)
268199767f8SToomas Soome 
269199767f8SToomas Soome /*
270199767f8SToomas Soome  * MAXPATHLEN defines the longest permissible path length after expanding
271199767f8SToomas Soome  * symbolic links. It is used to allocate a temporary buffer from the buffer
272199767f8SToomas Soome  * pool in which to do the name expansion, hence should be a power of two,
273199767f8SToomas Soome  * and must be less than or equal to MAXBSIZE.  MAXSYMLINKS defines the
274199767f8SToomas Soome  * maximum number of symbolic links that may be expanded in a path name.
275199767f8SToomas Soome  * It should be set high enough to allow all legitimate uses, but halt
276199767f8SToomas Soome  * infinite loops reasonably quickly.
277199767f8SToomas Soome  */
278199767f8SToomas Soome #define	MAXPATHLEN	PATH_MAX
279199767f8SToomas Soome #define MAXSYMLINKS	32
280199767f8SToomas Soome 
281199767f8SToomas Soome /* Bit map related macros. */
282199767f8SToomas Soome #define	setbit(a,i)	(((unsigned char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
283199767f8SToomas Soome #define	clrbit(a,i)	(((unsigned char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
284199767f8SToomas Soome #define	isset(a,i)							\
285199767f8SToomas Soome 	(((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
286199767f8SToomas Soome #define	isclr(a,i)							\
287199767f8SToomas Soome 	((((const unsigned char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
288199767f8SToomas Soome 
289199767f8SToomas Soome /* Macros for counting and rounding. */
290199767f8SToomas Soome #ifndef howmany
291199767f8SToomas Soome #define	howmany(x, y)	(((x)+((y)-1))/(y))
292199767f8SToomas Soome #endif
293199767f8SToomas Soome #define	nitems(x)	(sizeof((x)) / sizeof((x)[0]))
294199767f8SToomas Soome #define	rounddown(x, y)	(((x)/(y))*(y))
295199767f8SToomas Soome #define	rounddown2(x, y) ((x)&(~((y)-1)))          /* if y is power of two */
296199767f8SToomas Soome #define	roundup(x, y)	((((x)+((y)-1))/(y))*(y))  /* to any y */
297199767f8SToomas Soome #define	roundup2(x, y)	(((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
298199767f8SToomas Soome #define powerof2(x)	((((x)-1)&(x))==0)
299199767f8SToomas Soome 
300199767f8SToomas Soome /* Macros for min/max. */
301199767f8SToomas Soome #define	MIN(a,b) (((a)<(b))?(a):(b))
302199767f8SToomas Soome #define	MAX(a,b) (((a)>(b))?(a):(b))
303199767f8SToomas Soome 
304199767f8SToomas Soome #ifdef _KERNEL
305199767f8SToomas Soome /*
306199767f8SToomas Soome  * Basic byte order function prototypes for non-inline functions.
307199767f8SToomas Soome  */
308199767f8SToomas Soome #ifndef LOCORE
309199767f8SToomas Soome #ifndef _BYTEORDER_PROTOTYPED
310199767f8SToomas Soome #define	_BYTEORDER_PROTOTYPED
311199767f8SToomas Soome __BEGIN_DECLS
312199767f8SToomas Soome __uint32_t	 htonl(__uint32_t);
313199767f8SToomas Soome __uint16_t	 htons(__uint16_t);
314199767f8SToomas Soome __uint32_t	 ntohl(__uint32_t);
315199767f8SToomas Soome __uint16_t	 ntohs(__uint16_t);
316199767f8SToomas Soome __END_DECLS
317199767f8SToomas Soome #endif
318199767f8SToomas Soome #endif
319199767f8SToomas Soome 
320199767f8SToomas Soome #ifndef lint
321199767f8SToomas Soome #ifndef _BYTEORDER_FUNC_DEFINED
322199767f8SToomas Soome #define	_BYTEORDER_FUNC_DEFINED
323199767f8SToomas Soome #define	htonl(x)	__htonl(x)
324199767f8SToomas Soome #define	htons(x)	__htons(x)
325199767f8SToomas Soome #define	ntohl(x)	__ntohl(x)
326199767f8SToomas Soome #define	ntohs(x)	__ntohs(x)
327199767f8SToomas Soome #endif /* !_BYTEORDER_FUNC_DEFINED */
328199767f8SToomas Soome #endif /* lint */
329199767f8SToomas Soome #endif /* _KERNEL */
330199767f8SToomas Soome 
331199767f8SToomas Soome /*
332199767f8SToomas Soome  * Scale factor for scaled integers used to count %cpu time and load avgs.
333199767f8SToomas Soome  *
334199767f8SToomas Soome  * The number of CPU `tick's that map to a unique `%age' can be expressed
335199767f8SToomas Soome  * by the formula (1 / (2 ^ (FSHIFT - 11))).  The maximum load average that
336199767f8SToomas Soome  * can be calculated (assuming 32 bits) can be closely approximated using
337199767f8SToomas Soome  * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
338199767f8SToomas Soome  *
339199767f8SToomas Soome  * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
340199767f8SToomas Soome  * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
341199767f8SToomas Soome  */
342199767f8SToomas Soome #define	FSHIFT	11		/* bits to right of fixed binary point */
343199767f8SToomas Soome #define FSCALE	(1<<FSHIFT)
344199767f8SToomas Soome 
345199767f8SToomas Soome #define dbtoc(db)			/* calculates devblks to pages */ \
346199767f8SToomas Soome 	((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
347*55fea89dSDan Cross 
348199767f8SToomas Soome #define ctodb(db)			/* calculates pages to devblks */ \
349199767f8SToomas Soome 	((db) << (PAGE_SHIFT - DEV_BSHIFT))
350199767f8SToomas Soome 
351199767f8SToomas Soome /*
352199767f8SToomas Soome  * Old spelling of __containerof().
353199767f8SToomas Soome  */
354199767f8SToomas Soome #define	member2struct(s, m, x)						\
355199767f8SToomas Soome 	((struct s *)(void *)((char *)(x) - offsetof(struct s, m)))
356199767f8SToomas Soome 
357199767f8SToomas Soome /*
358199767f8SToomas Soome  * Access a variable length array that has been declared as a fixed
359199767f8SToomas Soome  * length array.
360199767f8SToomas Soome  */
361199767f8SToomas Soome #define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])
362199767f8SToomas Soome 
363199767f8SToomas Soome #endif	/* _SYS_PARAM_H_ */
364