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