BSD 4_3_Reno release
[unix-history] / usr / src / sys / sys / param.h
CommitLineData
da7c5cc6 1/*
deac8f74 2 * Copyright (c) 1982, 1986, 1989 Regents of the University of California.
da7c5cc6
KM
3 * All rights reserved. The Berkeley software License Agreement
4 * specifies the terms and conditions for redistribution.
5 *
1c15e888 6 * @(#)param.h 7.17 (Berkeley) 6/28/90
da7c5cc6 7 */
eb401bce 8
b9fcec08 9#define BSD 199006 /* June, 1990 system version (year & month) */
c698cc52 10#define BSD4_3 1
f91ca507 11#define BSD4_4 0.5
7ca6930d 12
d2389d89
KB
13#include <sys/syslimits.h>
14
557ae0ad
BJ
15/*
16 * Machine-independent constants
17 */
f91ca507
MK
18#define MAXUPRC CHILD_MAX /* max processes per user */
19#define NOFILE OPEN_MAX /* max open files per process */
f91ca507
MK
20#define NCARGS ARG_MAX /* # characters in exec arglist */
21#define MAXINTERP 32 /* max interpreter file name length */
22#define NGROUPS NGROUPS_MAX /* max number groups */
ee84f4fa
MK
23#define MAXHOSTNAMELEN 256 /* maximum hostname size */
24#define MAXCOMLEN 16 /* maximum command name remembered */
25 /* MAXCOMLEN should be >= sizeof(ac_comm) (acct.h) */
26#define MAXLOGNAME 12 /* maximum login name length */
27 /* MAXLOGNAME must be >= UT_NAMESIZE (<utmp.h>) */
62d0f535 28
f91ca507 29#define NOGROUP 65535 /* marker for empty group set member */
72ed8ae9 30
eb401bce 31/*
557ae0ad 32 * Priorities
eb401bce 33 */
eb401bce
BJ
34#define PSWP 0
35#define PINOD 10
36#define PRIBIO 20
6d0f0ece 37#define PVFS 22
eb401bce 38#define PZERO 25
f91ca507 39#define PSOCK 26
eb401bce 40#define PWAIT 30
85e197bd 41#define PLOCK 35
f91ca507 42#define PPAUSE 40
eb401bce 43#define PUSER 50
f91ca507
MK
44#define PRIMASK 0x0ff
45#define PCATCH 0x100 /* or'd with pri for tsleep to check signals */
eb401bce 46
3a1d681e 47#define NZERO 0
eb401bce 48
5e09dfcf 49#ifndef KERNEL
b28b3a13 50#include <sys/types.h>
5e09dfcf
MK
51#else
52#ifndef LOCORE
53#include "types.h"
54#endif
55#endif
56
eb401bce 57/*
557ae0ad 58 * Signals
eb401bce 59 */
40dc6933 60#ifdef KERNEL
88fc1c0a 61#include "signal.h"
40dc6933 62#else
deac8f74 63#include <sys/signal.h>
92808ee4 64#endif
02dd5a44 65
5e09dfcf
MK
66/*
67 * Machine type dependent parameters.
68 */
69#ifdef KERNEL
1c15e888 70#include "machine/machparam.h"
5e09dfcf
MK
71#else
72#include <machine/machparam.h>
73#endif
74
40dc6933 75#define NBPW sizeof(int) /* number of bytes in an integer */
eb401bce 76
deac8f74 77#ifndef NULL
eb401bce 78#define NULL 0
deac8f74 79#endif
6691aca1 80#define CMASK 022 /* default mask for file creation */
eb401bce 81#define NODEV (dev_t)(-1)
eb401bce
BJ
82
83/*
84 * Clustering of hardware pages on machines with ridiculously small
85 * page sizes is done here. The paging subsystem deals with units of
5e09dfcf 86 * CLSIZE pte's describing NBPG (from machine/machparam.h) pages each.
eb401bce
BJ
87 *
88 * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
eb401bce 89 */
114cd253 90#define CLBYTES (CLSIZE*NBPG)
7070df31 91#define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
114cd253
BJ
92#define claligned(x) ((((int)(x))&CLOFSET)==0)
93#define CLOFF CLOFSET
557ae0ad 94#define CLSHIFT (PGSHIFT+CLSIZELOG2)
eb401bce 95
557ae0ad
BJ
96#if CLSIZE==1
97#define clbase(i) (i)
98#define clrnd(i) (i)
99#else
eb401bce
BJ
100/* give the base virtual address (first of CLSIZE) */
101#define clbase(i) ((i) &~ (CLSIZE-1))
eb401bce
BJ
102/* round a number of clicks up to a whole cluster */
103#define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
557ae0ad 104#endif
eb401bce 105
8981cbeb
MK
106/* CBLOCK is the size of a clist block, must be power of 2 */
107#define CBLOCK 64
e84b8d0c
MT
108#define CBQSIZE (CBLOCK/NBBY) /* quote bytes/cblock - can do better */
109#define CBSIZE (CBLOCK - sizeof(struct cblock *) - CBQSIZE) /* data chars/clist */
8981cbeb 110#define CROUND (CBLOCK - 1) /* clist rounding */
eb401bce 111
d5d4a859 112/*
ad30fb67
KM
113 * File system parameters and macros.
114 *
115 * The file system is made out of blocks of at most MAXBSIZE units,
116 * with smaller units (fragments) only in the last direct block.
117 * MAXBSIZE primarily determines the size of buffers in the buffer
118 * pool. It may be made larger without any effect on existing
119 * file systems; however making it smaller make make some file
120 * systems unmountable.
ad30fb67
KM
121 */
122#define MAXBSIZE 8192
ad30fb67
KM
123#define MAXFRAG 8
124
125/*
126 * MAXPATHLEN defines the longest permissable path length
127 * after expanding symbolic links. It is used to allocate
128 * a temporary buffer from the buffer pool in which to do the
129 * name expansion, hence should be a power of two, and must
130 * be less than or equal to MAXBSIZE.
131 * MAXSYMLINKS defines the maximum number of symbolic links
132 * that may be expanded in a path name. It should be set high
133 * enough to allow all legitimate uses, but halt infinite loops
134 * reasonably quickly.
135 */
d2389d89 136#define MAXPATHLEN PATH_MAX
ad30fb67
KM
137#define MAXSYMLINKS 8
138
139/*
140 * bit map related macros
141 */
142#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
143#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
144#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
145#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
146
ad30fb67
KM
147/*
148 * Macros for counting and rounding.
149 */
9477baeb 150#ifndef howmany
ad30fb67 151#define howmany(x, y) (((x)+((y)-1))/(y))
9477baeb 152#endif
ad30fb67 153#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
56ebebfd 154#define powerof2(x) ((((x)-1)&(x))==0)
80b6b780 155
820d38ad
MK
156/*
157 * Macros for fast min/max:
158 * with inline expansion, the "function" is faster.
159 */
160#ifdef KERNEL
161#define MIN(a,b) min((a), (b))
162#define MAX(a,b) max((a), (b))
163#else
164#define MIN(a,b) (((a)<(b))?(a):(b))
165#define MAX(a,b) (((a)>(b))?(a):(b))
166#endif
167
168/*
169 * Constants for setting the parameters of the kernel memory allocator.
170 *
171 * 2 ** MINBUCKET is the smallest unit of memory that will be
172 * allocated. It must be at least large enough to hold a pointer.
173 *
174 * Units of memory less or equal to MAXALLOCSAVE will permanently
175 * allocate physical memory; requests for these size pieces of
176 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
177 * always allocate and free physical memory; requests for these
178 * size allocations should be done infrequently as they will be slow.
179 * Constraints: CLBYTES <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14)
180 * and MAXALLOCSIZE must be a power of two.
181 */
182#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
183#define MAXALLOCSAVE (2 * CLBYTES)
184
80b6b780
KM
185/*
186 * Scale factor for scaled integers used to count %cpu time and load avgs.
187 *
188 * The number of CPU `tick's that map to a unique `%age' can be expressed
189 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
190 * can be calculated (assuming 32 bits) can be closely approximated using
191 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
192 *
193 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
194 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
195 */
196#define FSHIFT 11 /* bits to right of fixed binary point */
197#define FSCALE (1<<FSHIFT)