]> git.saurik.com Git - apple/xnu.git/blob - bsd/sys/param.h
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / sys / param.h
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1995, 1997 Apple Computer, Inc. All Rights Reserved */
31 /*-
32 * Copyright (c) 1982, 1986, 1989, 1993
33 * The Regents of the University of California. All rights reserved.
34 * (c) UNIX System Laboratories, Inc.
35 * All or some portions of this file are derived from material licensed
36 * to the University of California by American Telephone and Telegraph
37 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
38 * the permission of UNIX System Laboratories, Inc.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the University of
51 * California, Berkeley and its contributors.
52 * 4. Neither the name of the University nor the names of its contributors
53 * may be used to endorse or promote products derived from this software
54 * without specific prior written permission.
55 *
56 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
66 * SUCH DAMAGE.
67 *
68 * @(#)param.h 8.3 (Berkeley) 4/4/95
69 */
70
71 #ifndef _SYS_PARAM_H_
72 #define _SYS_PARAM_H_
73
74 #define BSD 199506 /* System version (year & month). */
75 #define BSD4_3 1
76 #define BSD4_4 1
77
78 #define NeXTBSD 1995064 /* NeXTBSD version (year, month, release) */
79 #define NeXTBSD4_0 0 /* NeXTBSD 4.0 */
80
81 #include <sys/_types.h>
82
83 #ifndef NULL
84 #define NULL __DARWIN_NULL
85 #endif /* ! NULL */
86
87 #ifndef LOCORE
88 #include <sys/types.h>
89 #endif
90
91 /*
92 * Machine-independent constants (some used in following include files).
93 * Redefined constants are from POSIX 1003.1 limits file.
94 *
95 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
96 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
97 */
98 #include <sys/syslimits.h>
99
100 #define MAXCOMLEN 16 /* max command name remembered */
101 #define MAXINTERP 64 /* max interpreter file name length */
102 #define MAXLOGNAME 255 /* max login name length */
103 #define MAXUPRC CHILD_MAX /* max simultaneous processes */
104 #define NCARGS ARG_MAX /* max bytes for an exec function */
105 #define NGROUPS NGROUPS_MAX /* max number groups */
106 #define NOFILE 256 /* default max open files per process */
107 #define NOGROUP 65535 /* marker for empty group set member */
108 #define MAXHOSTNAMELEN 256 /* max hostname size */
109 #define MAXDOMNAMELEN 256 /* maximum domain name length */
110
111 /* Machine type dependent parameters. */
112 #include <machine/param.h>
113
114 /* More types and definitions used throughout the kernel. */
115 #ifdef KERNEL
116 #include <machine/limits.h>
117 #include <sys/cdefs.h>
118 #include <sys/errno.h>
119 #include <sys/time.h>
120 #include <sys/resource.h>
121 #include <sys/ucred.h>
122 #include <sys/uio.h>
123 #else
124 #include <limits.h>
125 #endif
126
127 /* Signals. */
128 #include <sys/signal.h>
129
130 /*
131 * Priorities. Note that with 32 run queues, differences less than 4 are
132 * insignificant.
133 */
134 #define PSWP 0
135 #define PVM 4
136 #define PINOD 8
137 #define PRIBIO 16
138 #define PVFS 20
139 #define PZERO 22 /* No longer magic, shouldn't be here. XXX */
140 #define PSOCK 24
141 #define PWAIT 32
142 #define PLOCK 36
143 #define PPAUSE 40
144 #define PUSER 50
145 #define MAXPRI 127 /* Priorities range from 0 through MAXPRI. */
146
147 #define PRIMASK 0x0ff
148 #define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
149 #define PTTYBLOCK 0x200 /* for tty SIGTTOU and SIGTTIN blocking */
150 #define PDROP 0x400 /* OR'd with pri to stop re-entry of interlock mutex */
151
152 #define NZERO 0 /* default "nice" */
153
154 #define NBPW sizeof(int) /* number of bytes per word (integer) */
155
156 #define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
157 #define NODEV (dev_t)(-1) /* non-existent device */
158
159 /*
160 * Clustering of hardware pages on machines with ridiculously small
161 * page sizes is done here. The paging subsystem deals with units of
162 * CLSIZE pte's describing NBPG (from machine/param.h) pages each.
163 */
164 #define CLBYTES (CLSIZE*NBPG)
165 #define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
166 #define claligned(x) ((((int)(x))&CLOFSET)==0)
167 #define CLOFF CLOFSET
168 #define CLSHIFT (PGSHIFT+CLSIZELOG2)
169
170 #if CLSIZE==1
171 #define clbase(i) (i)
172 #define clrnd(i) (i)
173 #else
174 /* Give the base virtual address (first of CLSIZE). */
175 #define clbase(i) ((i) &~ (CLSIZE-1))
176 /* Round a number of clicks up to a whole cluster. */
177 #define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
178 #endif
179
180 #define CBLOCK 64 /* Clist block size, must be a power of 2. */
181 #define CBQSIZE (CBLOCK/NBBY) /* Quote bytes/cblock - can do better. */
182 /* Data chars/clist. */
183 #define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE)
184 #define CROUND (CBLOCK - 1) /* Clist rounding. */
185
186 /*
187 * File system parameters and macros.
188 *
189 * The file system is made out of blocks of at most MAXPHYS units, with
190 * smaller units (fragments) only in the last direct block. MAXBSIZE
191 * primarily determines the size of buffers in the buffer pool. It may be
192 * made larger than MAXPHYS without any effect on existing file systems;
193 * however making it smaller may make some file systems unmountable.
194 * We set this to track the value of (MAX_UPL_TRANSFER*PAGE_SIZE) from
195 * osfmk/mach/memory_object_types.h to bound it at the maximum UPL size.
196 */
197 #define MAXBSIZE (256 * 4096)
198 #define MAXPHYSIO MAXPHYS
199 #define MAXFRAG 8
200
201 #define MAXPHYSIO_WIRED (16 * 1024 * 1024)
202
203 /*
204 * MAXPATHLEN defines the longest permissable path length after expanding
205 * symbolic links. It is used to allocate a temporary buffer from the buffer
206 * pool in which to do the name expansion, hence should be a power of two,
207 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
208 * maximum number of symbolic links that may be expanded in a path name.
209 * It should be set high enough to allow all legitimate uses, but halt
210 * infinite loops reasonably quickly.
211 */
212 #define MAXPATHLEN PATH_MAX
213 #define MAXSYMLINKS 32
214
215 /* Bit map related macros. */
216 #define setbit(a,i) (((char *)(a))[(i)/NBBY] |= 1<<((i)%NBBY))
217 #define clrbit(a,i) (((char *)(a))[(i)/NBBY] &= ~(1<<((i)%NBBY)))
218 #define isset(a,i) (((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY)))
219 #define isclr(a,i) ((((char *)(a))[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
220
221 /* Macros for counting and rounding. */
222 #ifndef howmany
223 #define howmany(x, y) (((x)+((y)-1))/(y))
224 #endif
225 #define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
226 #define powerof2(x) ((((x)-1)&(x))==0)
227
228 /* Macros for min/max. */
229 #ifndef MIN
230 #define MIN(a,b) (((a)<(b))?(a):(b))
231 #endif /* MIN */
232 #ifndef MAX
233 #define MAX(a,b) (((a)>(b))?(a):(b))
234 #endif /* MAX */
235
236 /*
237 * Constants for setting the parameters of the kernel memory allocator.
238 *
239 * 2 ** MINBUCKET is the smallest unit of memory that will be
240 * allocated. It must be at least large enough to hold a pointer.
241 *
242 * Units of memory less or equal to MAXALLOCSAVE will permanently
243 * allocate physical memory; requests for these size pieces of
244 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
245 * always allocate and free physical memory; requests for these
246 * size allocations should be done infrequently as they will be slow.
247 *
248 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
249 * MAXALLOCSIZE must be a power of two.
250 */
251 #define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
252 #define MAXALLOCSAVE (2 * CLBYTES)
253
254 /*
255 * Scale factor for scaled integers used to count %cpu time and load avgs.
256 *
257 * The number of CPU `tick's that map to a unique `%age' can be expressed
258 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
259 * can be calculated (assuming 32 bits) can be closely approximated using
260 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
261 *
262 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
263 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
264 */
265 #define FSHIFT 11 /* bits to right of fixed binary point */
266 #define FSCALE (1<<FSHIFT)
267
268 #endif /* _SYS_PARAM_H_ */