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