initial commit
[glibc.git] / sysdeps / unix / bsd / bsd4.4 / kfreebsd / bits / param.h
1 /* Copyright (C) 1995,1996,1997,2000,2001,2003 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA. */
18
19 #ifndef _SYS_PARAM_H
20 # error "Never use <bits/param.h> directly; include <sys/param.h> instead."
21 #endif
22
23 #include <limits.h>
24 #include <sys/syslimits.h>
25
26 /*
27 * __FreeBSD_version numbers are documented in the Porter's Handbook.
28 * If you bump the version for any reason, you should update the documentation
29 * there.
30 * Currently this lives here:
31 *
32 * doc/en_US.ISO8859-1/books/porters-handbook/book.sgml
33 *
34 * scheme is: <major><two digit minor><0 if release branch, otherwise 1>xx
35 */
36 #include <osreldate.h>
37
38 /* Some inet code expects that this file defines the 'u_int32_t' type. */
39 #include <stdint.h>
40
41 /* FreeBSD code expects that this file implicitly defines SIG* macros. */
42 #include <signal.h>
43
44 /*
45 * Machine-independent constants (some used in following include files).
46 * Redefined constants are from POSIX 1003.1 limits file.
47 *
48 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
49 * MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>)
50 */
51
52 #define MAXCOMLEN 19 /* max command name remembered */
53 #define MAXINTERP 32 /* max interpreter file name length */
54 #define MAXLOGNAME 33 /* max login name length (incl. NUL) */
55 #define MAXUPRC CHILD_MAX /* max simultaneous processes */
56 #define NGROUPS (NGROUPS_MAX+1) /* max number groups */
57 #define MAXHOSTNAMELEN 256 /* max hostname size */
58 #define SPECNAMELEN 63 /* max length of devicename */
59 #define TTY_NAME_MAX SPECNAMELEN
60
61 /* BSD names for some <limits.h> values. */
62
63 #define MAXSYMLINKS 32
64 #define CANBSIZ MAX_CANON
65
66 /* Machine type dependent parameters. */
67 #include <machine/param.h>
68
69 #ifndef BLKDEV_IOSIZE
70 #define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */
71 #endif
72 #ifndef DFLTPHYS
73 #define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */
74 #endif
75 #ifndef MAXPHYS
76 #define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
77 #endif
78 #ifndef MAXDUMPPGS
79 #define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
80 #endif
81
82 /*
83 * Constants related to network buffer management.
84 * MCLBYTES must be no larger than PAGE_SIZE.
85 */
86 #ifndef MSIZE
87 #define MSIZE 256 /* size of an mbuf */
88 #endif /* MSIZE */
89
90 #ifndef MCLSHIFT
91 #define MCLSHIFT 11 /* convert bytes to mbuf clusters */
92 #endif /* MCLSHIFT */
93
94 #define MCLBYTES (1 << MCLSHIFT) /* size of an mbuf cluster */
95
96 /*
97 * Some macros for units conversion
98 */
99
100 /* clicks to bytes */
101 #ifndef ctob
102 #define ctob(x) ((x)<<PAGE_SHIFT)
103 #endif
104
105 /* bytes to clicks */
106 #ifndef btoc
107 #define btoc(x) (((vm_offset_t)(x)+PAGE_MASK)>>PAGE_SHIFT)
108 #endif
109
110 /*
111 * btodb() is messy and perhaps slow because `bytes' may be an off_t. We
112 * want to shift an unsigned type to avoid sign extension and we don't
113 * want to widen `bytes' unnecessarily. Assume that the result fits in
114 * a daddr_t.
115 */
116 #ifndef btodb
117 #define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
118 (sizeof (bytes) > sizeof(long) \
119 ? (daddr_t)((unsigned long long)(bytes) >> DEV_BSHIFT) \
120 : (daddr_t)((unsigned long)(bytes) >> DEV_BSHIFT))
121 #endif
122
123 #ifndef dbtob
124 #define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
125 ((off_t)(db) << DEV_BSHIFT)
126 #endif
127
128 #define PRIMASK 0x0ff
129 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
130 #define PDROP 0x200 /* OR'd with pri to stop re-entry of interlock mutex */
131
132 #define NBPW sizeof(int) /* number of bytes per word (integer) */
133
134 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
135
136 #define NODEV (dev_t)(-1) /* non-existent device */
137
138 #define CBLOCK 128 /* Clist block size, must be a power of 2. */
139 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
140 /* Data chars/clist. */
141 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
142 #define CROUND (CBLOCK - 1) /* Clist rounding. */
143
144 /*
145 * File system parameters and macros.
146 *
147 * MAXBSIZE - Filesystems are made out of blocks of at most MAXBSIZE bytes
148 * per block. MAXBSIZE may be made larger without effecting
149 * any existing filesystems as long as it does not exceed MAXPHYS,
150 * and may be made smaller at the risk of not being able to use
151 * filesystems which require a block size exceeding MAXBSIZE.
152 *
153 * BKVASIZE - Nominal buffer space per buffer, in bytes. BKVASIZE is the
154 * minimum KVM memory reservation the kernel is willing to make.
155 * Filesystems can of course request smaller chunks. Actual
156 * backing memory uses a chunk size of a page (PAGE_SIZE).
157 *
158 * If you make BKVASIZE too small you risk seriously fragmenting
159 * the buffer KVM map which may slow things down a bit. If you
160 * make it too big the kernel will not be able to optimally use
161 * the KVM memory reserved for the buffer cache and will wind
162 * up with too-few buffers.
163 *
164 * The default is 16384, roughly 2x the block size used by a
165 * normal UFS filesystem.
166 */
167 #define MAXBSIZE 65536 /* must be power of 2 */
168 #define BKVASIZE 16384 /* must be power of 2 */
169 #define BKVAMASK (BKVASIZE-1)
170
171 /*
172 * Scale factor for scaled integers used to count %cpu time and load avgs.
173 *
174 * The number of CPU `tick's that map to a unique `%age' can be expressed
175 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
176 * can be calculated (assuming 32 bits) can be closely approximated using
177 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
178 *
179 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
180 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
181 */
182 #define FSHIFT 11 /* bits to right of fixed binary point */
183 #define FSCALE (1<<FSHIFT)
184
185 #define dbtoc(db) /* calculates devblks to pages */ \
186 ((db + (ctodb(1) - 1)) >> (PAGE_SHIFT - DEV_BSHIFT))
187
188 #define ctodb(db) /* calculates pages to devblks */ \
189 ((db) << (PAGE_SHIFT - DEV_BSHIFT))