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