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