Fri Dec 1 19:04:19 2017 UTC ()
belated bump for fileops struct size change.


(christos)
diff -r1.552 -r1.553 src/sys/sys/param.h

cvs diff -r1.552 -r1.553 src/sys/sys/param.h (switch to unified diff)

--- src/sys/sys/param.h 2017/11/16 10:40:29 1.552
+++ src/sys/sys/param.h 2017/12/01 19:04:19 1.553
@@ -1,498 +1,498 @@ @@ -1,498 +1,498 @@
1/* $NetBSD: param.h,v 1.552 2017/11/16 10:40:29 ozaki-r Exp $ */ 1/* $NetBSD: param.h,v 1.553 2017/12/01 19:04:19 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1982, 1986, 1989, 1993 4 * Copyright (c) 1982, 1986, 1989, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * (c) UNIX System Laboratories, Inc. 6 * (c) UNIX System Laboratories, Inc.
7 * All or some portions of this file are derived from material licensed 7 * All or some portions of this file are derived from material licensed
8 * to the University of California by American Telephone and Telegraph 8 * to the University of California by American Telephone and Telegraph
9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 9 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10 * the permission of UNIX System Laboratories, Inc. 10 * the permission of UNIX System Laboratories, Inc.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
15 * 1. Redistributions of source code must retain the above copyright 15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer. 16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright 17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the 18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution. 19 * documentation and/or other materials provided with the distribution.
20 * 3. Neither the name of the University nor the names of its contributors 20 * 3. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software 21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission. 22 * without specific prior written permission.
23 * 23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE. 34 * SUCH DAMAGE.
35 * 35 *
36 * @(#)param.h 8.3 (Berkeley) 4/4/95 36 * @(#)param.h 8.3 (Berkeley) 4/4/95
37 */ 37 */
38 38
39#ifndef _SYS_PARAM_H_ 39#ifndef _SYS_PARAM_H_
40#define _SYS_PARAM_H_ 40#define _SYS_PARAM_H_
41 41
42#ifdef _KERNEL_OPT 42#ifdef _KERNEL_OPT
43#include "opt_param.h" 43#include "opt_param.h"
44#endif 44#endif
45 45
46/* 46/*
47 * Historic BSD #defines -- probably will remain untouched for all time. 47 * Historic BSD #defines -- probably will remain untouched for all time.
48 */ 48 */
49#define BSD 199506 /* System version (year & month). */ 49#define BSD 199506 /* System version (year & month). */
50#define BSD4_3 1 50#define BSD4_3 1
51#define BSD4_4 1 51#define BSD4_4 1
52 52
53/* 53/*
54 * #define __NetBSD_Version__ MMmmrrpp00 54 * #define __NetBSD_Version__ MMmmrrpp00
55 * 55 *
56 * M = major version 56 * M = major version
57 * m = minor version; a minor number of 99 indicates current. 57 * m = minor version; a minor number of 99 indicates current.
58 * r = 0 (*) 58 * r = 0 (*)
59 * p = patchlevel 59 * p = patchlevel
60 * 60 *
61 * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local 61 * When new releases are made, src/gnu/usr.bin/groff/tmac/mdoc.local
62 * needs to be updated and the changes sent back to the groff maintainers. 62 * needs to be updated and the changes sent back to the groff maintainers.
63 * 63 *
64 * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric 64 * (*) Up to 2.0I "release" used to be "",A-Z,Z[A-Z] but numeric
65 * e.g. NetBSD-1.2D = 102040000 ('D' == 4) 65 * e.g. NetBSD-1.2D = 102040000 ('D' == 4)
66 * NetBSD-2.0H (200080000) was changed on 20041001 to: 66 * NetBSD-2.0H (200080000) was changed on 20041001 to:
67 * 2.99.9 (299000900) 67 * 2.99.9 (299000900)
68 */ 68 */
69 69
70#define __NetBSD_Version__ 899000700 /* NetBSD 8.99.7 */ 70#define __NetBSD_Version__ 899000800 /* NetBSD 8.99.8 */
71 71
72#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ 72#define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
73 (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) 73 (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)
74 74
75/* 75/*
76 * Historical NetBSD #define 76 * Historical NetBSD #define
77 * 77 *
78 * NetBSD 1.4 was the last release for which this value was incremented. 78 * NetBSD 1.4 was the last release for which this value was incremented.
79 * The value is now permanently fixed at 199905. It will never be 79 * The value is now permanently fixed at 199905. It will never be
80 * changed again. 80 * changed again.
81 * 81 *
82 * New code must use __NetBSD_Version__ instead, and should not even 82 * New code must use __NetBSD_Version__ instead, and should not even
83 * count on NetBSD being defined. 83 * count on NetBSD being defined.
84 * 84 *
85 */ 85 */
86 86
87#define NetBSD 199905 /* NetBSD version (year & month). */ 87#define NetBSD 199905 /* NetBSD version (year & month). */
88 88
89/* 89/*
90 * There macros determine if we are running in protected mode or not. 90 * There macros determine if we are running in protected mode or not.
91 * _HARDKERNEL: code uses kernel namespace and runs in hw priviledged mode 91 * _HARDKERNEL: code uses kernel namespace and runs in hw priviledged mode
92 * _SOFTKERNEL: code uses kernel namespace but runs without hw priviledges 92 * _SOFTKERNEL: code uses kernel namespace but runs without hw priviledges
93 */ 93 */
94#if defined(_KERNEL) && !defined(_RUMPKERNEL) 94#if defined(_KERNEL) && !defined(_RUMPKERNEL)
95#define _HARDKERNEL 95#define _HARDKERNEL
96#endif 96#endif
97#if defined(_KERNEL) && defined(_RUMPKERNEL) 97#if defined(_KERNEL) && defined(_RUMPKERNEL)
98#define _SOFTKERNEL 98#define _SOFTKERNEL
99#endif 99#endif
100 100
101#include <sys/null.h> 101#include <sys/null.h>
102 102
103#ifndef __ASSEMBLER__ 103#ifndef __ASSEMBLER__
104#include <sys/inttypes.h> 104#include <sys/inttypes.h>
105#include <sys/types.h> 105#include <sys/types.h>
106 106
107/* 107/*
108 * Machine-independent constants (some used in following include files). 108 * Machine-independent constants (some used in following include files).
109 * Redefined constants are from POSIX 1003.1 limits file. 109 * Redefined constants are from POSIX 1003.1 limits file.
110 * 110 *
111 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>) 111 * MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
112 * MAXHOSTNAMELEN should be >= (_POSIX_HOST_NAME_MAX + 1) (see <limits.h>) 112 * MAXHOSTNAMELEN should be >= (_POSIX_HOST_NAME_MAX + 1) (see <limits.h>)
113 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>) 113 * MAXLOGNAME should be >= UT_NAMESIZE (see <utmp.h>)
114 */ 114 */
115#include <sys/syslimits.h> 115#include <sys/syslimits.h>
116 116
117#define MAXCOMLEN 16 /* max command name remembered */ 117#define MAXCOMLEN 16 /* max command name remembered */
118#define MAXINTERP PATH_MAX /* max interpreter file name length */ 118#define MAXINTERP PATH_MAX /* max interpreter file name length */
119/* DEPRECATED: use LOGIN_NAME_MAX instead. */ 119/* DEPRECATED: use LOGIN_NAME_MAX instead. */
120#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */ 120#define MAXLOGNAME (LOGIN_NAME_MAX - 1) /* max login name length */
121#define NCARGS ARG_MAX /* max bytes for an exec function */ 121#define NCARGS ARG_MAX /* max bytes for an exec function */
122#define NGROUPS NGROUPS_MAX /* max number groups */ 122#define NGROUPS NGROUPS_MAX /* max number groups */
123#define NOGROUP 65535 /* marker for empty group set member */ 123#define NOGROUP 65535 /* marker for empty group set member */
124#define MAXHOSTNAMELEN 256 /* max hostname size */ 124#define MAXHOSTNAMELEN 256 /* max hostname size */
125 125
126#ifndef NOFILE 126#ifndef NOFILE
127#define NOFILE OPEN_MAX /* max open files per process */ 127#define NOFILE OPEN_MAX /* max open files per process */
128#endif 128#endif
129#ifndef MAXUPRC /* max simultaneous processes */ 129#ifndef MAXUPRC /* max simultaneous processes */
130#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */ 130#define MAXUPRC CHILD_MAX /* POSIX 1003.1-compliant default */
131#else 131#else
132#if (MAXUPRC - 0) < CHILD_MAX 132#if (MAXUPRC - 0) < CHILD_MAX
133#error MAXUPRC less than CHILD_MAX. See options(4) for details. 133#error MAXUPRC less than CHILD_MAX. See options(4) for details.
134#endif /* (MAXUPRC - 0) < CHILD_MAX */ 134#endif /* (MAXUPRC - 0) < CHILD_MAX */
135#endif /* !defined(MAXUPRC) */ 135#endif /* !defined(MAXUPRC) */
136 136
137/* Macros for min/max. */ 137/* Macros for min/max. */
138#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b)) 138#define MIN(a,b) ((/*CONSTCOND*/(a)<(b))?(a):(b))
139#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b)) 139#define MAX(a,b) ((/*CONSTCOND*/(a)>(b))?(a):(b))
140 140
141/* More types and definitions used throughout the kernel. */ 141/* More types and definitions used throughout the kernel. */
142#ifdef _KERNEL 142#ifdef _KERNEL
143#include <sys/cdefs.h> 143#include <sys/cdefs.h>
144#include <sys/errno.h> 144#include <sys/errno.h>
145#include <sys/time.h> 145#include <sys/time.h>
146#include <sys/resource.h> 146#include <sys/resource.h>
147#include <sys/ucred.h> 147#include <sys/ucred.h>
148#include <sys/uio.h> 148#include <sys/uio.h>
149#include <uvm/uvm_param.h> 149#include <uvm/uvm_param.h>
150#ifndef NPROC 150#ifndef NPROC
151#define NPROC (20 + 16 * MAXUSERS) 151#define NPROC (20 + 16 * MAXUSERS)
152#endif 152#endif
153#ifndef NTEXT 153#ifndef NTEXT
154#define NTEXT (80 + NPROC / 8) /* actually the object cache */ 154#define NTEXT (80 + NPROC / 8) /* actually the object cache */
155#endif 155#endif
156#ifndef NVNODE 156#ifndef NVNODE
157#define NVNODE (NPROC + NTEXT + 100) 157#define NVNODE (NPROC + NTEXT + 100)
158#define NVNODE_IMPLICIT 158#define NVNODE_IMPLICIT
159#endif 159#endif
160#ifndef VNODE_KMEM_MAXPCT 160#ifndef VNODE_KMEM_MAXPCT
161#define VNODE_KMEM_MAXPCT 60 161#define VNODE_KMEM_MAXPCT 60
162#endif 162#endif
163#ifndef BUFCACHE_VA_MAXPCT 163#ifndef BUFCACHE_VA_MAXPCT
164#define BUFCACHE_VA_MAXPCT 20 164#define BUFCACHE_VA_MAXPCT 20
165#endif 165#endif
166#define VNODE_COST 2048 /* assumed space in bytes */ 166#define VNODE_COST 2048 /* assumed space in bytes */
167#endif /* _KERNEL */ 167#endif /* _KERNEL */
168 168
169/* Signals. */ 169/* Signals. */
170#include <sys/signal.h> 170#include <sys/signal.h>
171 171
172/* Machine type dependent parameters. */ 172/* Machine type dependent parameters. */
173#include <machine/param.h> 173#include <machine/param.h>
174#include <machine/limits.h> 174#include <machine/limits.h>
175 175
176/* pages ("clicks") to disk blocks */ 176/* pages ("clicks") to disk blocks */
177#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 177#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
178#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 178#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
179 179
180/* bytes to pages */ 180/* bytes to pages */
181#define ctob(x) ((x) << PGSHIFT) 181#define ctob(x) ((x) << PGSHIFT)
182#define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 182#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
183 183
184/* bytes to disk blocks */ 184/* bytes to disk blocks */
185#define dbtob(x) ((x) << DEV_BSHIFT) 185#define dbtob(x) ((x) << DEV_BSHIFT)
186#define btodb(x) ((x) >> DEV_BSHIFT) 186#define btodb(x) ((x) >> DEV_BSHIFT)
187 187
188#ifndef COHERENCY_UNIT 188#ifndef COHERENCY_UNIT
189#define COHERENCY_UNIT 64 189#define COHERENCY_UNIT 64
190#endif 190#endif
191#ifndef CACHE_LINE_SIZE 191#ifndef CACHE_LINE_SIZE
192#define CACHE_LINE_SIZE 64 192#define CACHE_LINE_SIZE 64
193#endif 193#endif
194#ifndef MAXCPUS 194#ifndef MAXCPUS
195#define MAXCPUS 32 195#define MAXCPUS 32
196#endif 196#endif
197#ifndef MAX_LWP_PER_PROC 197#ifndef MAX_LWP_PER_PROC
198#define MAX_LWP_PER_PROC 8000 198#define MAX_LWP_PER_PROC 8000
199#endif 199#endif
200 200
201/* 201/*
202 * Stack macros. On most architectures, the stack grows down, 202 * Stack macros. On most architectures, the stack grows down,
203 * towards lower addresses; it is the rare architecture where 203 * towards lower addresses; it is the rare architecture where
204 * it grows up, towards higher addresses. 204 * it grows up, towards higher addresses.
205 * 205 *
206 * STACK_GROW and STACK_SHRINK adjust a stack pointer by some 206 * STACK_GROW and STACK_SHRINK adjust a stack pointer by some
207 * size, no questions asked. STACK_ALIGN aligns a stack pointer. 207 * size, no questions asked. STACK_ALIGN aligns a stack pointer.
208 * 208 *
209 * STACK_ALLOC returns a pointer to allocated stack space of 209 * STACK_ALLOC returns a pointer to allocated stack space of
210 * some size; given such a pointer and a size, STACK_MAX gives 210 * some size; given such a pointer and a size, STACK_MAX gives
211 * the maximum (in the "maxsaddr" sense) stack address of the 211 * the maximum (in the "maxsaddr" sense) stack address of the
212 * allocated memory. 212 * allocated memory.
213 */ 213 */
214#if defined(_KERNEL) || defined(__EXPOSE_STACK) 214#if defined(_KERNEL) || defined(__EXPOSE_STACK)
215 215
216#ifndef STACK_ALIGNBYTES 216#ifndef STACK_ALIGNBYTES
217#define STACK_ALIGNBYTES __ALIGNBYTES 217#define STACK_ALIGNBYTES __ALIGNBYTES
218#endif 218#endif
219 219
220#ifdef __MACHINE_STACK_GROWS_UP 220#ifdef __MACHINE_STACK_GROWS_UP
221#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size)) 221#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size))
222#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size)) 222#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size))
223#define STACK_ALIGN(sp, bytes) \ 223#define STACK_ALIGN(sp, bytes) \
224 ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes))) 224 ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes)))
225#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp)) 225#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp))
226#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size)) 226#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size))
227#else 227#else
228#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size)) 228#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size))
229#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size)) 229#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size))
230#define STACK_ALIGN(sp, bytes) \ 230#define STACK_ALIGN(sp, bytes) \
231 ((char *)(((unsigned long)(sp)) & ~(bytes))) 231 ((char *)(((unsigned long)(sp)) & ~(bytes)))
232#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size)) 232#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size))
233#define STACK_MAX(p, _size) ((char *)(void *)(p)) 233#define STACK_MAX(p, _size) ((char *)(void *)(p))
234#endif 234#endif
235#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes)) 235#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes))
236 236
237#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */ 237#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */
238 238
239/* 239/*
240 * Round p (pointer or byte index) up to a correctly-aligned value for all 240 * Round p (pointer or byte index) up to a correctly-aligned value for all
241 * data types (int, long, ...). The result is u_int and must be cast to 241 * data types (int, long, ...). The result is u_int and must be cast to
242 * any desired pointer type. 242 * any desired pointer type.
243 * 243 *
244 * ALIGNED_POINTER is a boolean macro that checks whether an address 244 * ALIGNED_POINTER is a boolean macro that checks whether an address
245 * is valid to fetch data elements of type t from on this architecture. 245 * is valid to fetch data elements of type t from on this architecture.
246 * This does not reflect the optimal alignment, just the possibility 246 * This does not reflect the optimal alignment, just the possibility
247 * (within reasonable limits). 247 * (within reasonable limits).
248 * 248 *
249 */ 249 */
250#define ALIGNBYTES __ALIGNBYTES 250#define ALIGNBYTES __ALIGNBYTES
251#ifndef ALIGN 251#ifndef ALIGN
252#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) 252#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
253#endif 253#endif
254#ifndef ALIGNED_POINTER 254#ifndef ALIGNED_POINTER
255#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t) - 1)) == 0) 255#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t) - 1)) == 0)
256#endif 256#endif
257 257
258/* 258/*
259 * Historic priority levels. These are meaningless and remain only 259 * Historic priority levels. These are meaningless and remain only
260 * for source compatibility. Do not use in new code. 260 * for source compatibility. Do not use in new code.
261 */ 261 */
262#define PSWP 0 262#define PSWP 0
263#define PVM 4 263#define PVM 4
264#define PINOD 8 264#define PINOD 8
265#define PRIBIO 16 265#define PRIBIO 16
266#define PVFS 20 266#define PVFS 20
267#define PZERO 22 267#define PZERO 22
268#define PSOCK 24 268#define PSOCK 24
269#define PWAIT 32 269#define PWAIT 32
270#define PLOCK 36 270#define PLOCK 36
271#define PPAUSE 40 271#define PPAUSE 40
272#define PUSER 50 272#define PUSER 50
273#define MAXPRI 127 273#define MAXPRI 127
274 274
275#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 275#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
276#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */ 276#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */
277 277
278/* 278/*
279 * New priority levels. 279 * New priority levels.
280 */ 280 */
281#define PRI_COUNT 224 281#define PRI_COUNT 224
282#define PRI_NONE (-1) 282#define PRI_NONE (-1)
283 283
284#define PRI_KERNEL_RT 192 284#define PRI_KERNEL_RT 192
285#define NPRI_KERNEL_RT 32 285#define NPRI_KERNEL_RT 32
286#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1) 286#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1)
287 287
288#define PRI_USER_RT 128 288#define PRI_USER_RT 128
289#define NPRI_USER_RT 64 289#define NPRI_USER_RT 64
290#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1) 290#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1)
291 291
292#define PRI_KTHREAD 96 292#define PRI_KTHREAD 96
293#define NPRI_KTHREAD 32 293#define NPRI_KTHREAD 32
294#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1) 294#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1)
295 295
296#define PRI_KERNEL 64 296#define PRI_KERNEL 64
297#define NPRI_KERNEL 32 297#define NPRI_KERNEL 32
298#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1) 298#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1)
299 299
300#define PRI_USER 0 300#define PRI_USER 0
301#define NPRI_USER 64 301#define NPRI_USER 64
302#define MAXPRI_USER (PRI_USER + NPRI_USER - 1) 302#define MAXPRI_USER (PRI_USER + NPRI_USER - 1)
303 303
304/* Priority range used by POSIX real-time features */ 304/* Priority range used by POSIX real-time features */
305#define SCHED_PRI_MIN 0 305#define SCHED_PRI_MIN 0
306#define SCHED_PRI_MAX 63 306#define SCHED_PRI_MAX 63
307 307
308/* 308/*
309 * Kernel thread priorities. 309 * Kernel thread priorities.
310 */ 310 */
311#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT 311#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT
312#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1) 312#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1)
313#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2) 313#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2)
314#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3) 314#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3)
315 315
316#define PRI_XCALL MAXPRI_KTHREAD 316#define PRI_XCALL MAXPRI_KTHREAD
317#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1) 317#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1)
318#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2) 318#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2)
319#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3) 319#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3)
320#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4) 320#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4)
321 321
322#define PRI_IDLE PRI_USER 322#define PRI_IDLE PRI_USER
323 323
324/* 324/*
325 * Miscellaneous. 325 * Miscellaneous.
326 */ 326 */
327#define NBPW sizeof(int) /* number of bytes per word (integer) */ 327#define NBPW sizeof(int) /* number of bytes per word (integer) */
328 328
329#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 329#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
330#define NODEV (dev_t)(-1) /* non-existent device */ 330#define NODEV (dev_t)(-1) /* non-existent device */
331 331
332/* 332/*
333 * File system parameters and macros. 333 * File system parameters and macros.
334 * 334 *
335 * The file system is made out of blocks of at most MAXBSIZE units, with 335 * The file system is made out of blocks of at most MAXBSIZE units, with
336 * smaller units (fragments) only in the last direct block. MAXBSIZE 336 * smaller units (fragments) only in the last direct block. MAXBSIZE
337 * primarily determines the size of buffers in the buffer pool. It may be 337 * primarily determines the size of buffers in the buffer pool. It may be
338 * made larger without any effect on existing file systems; however making 338 * made larger without any effect on existing file systems; however making
339 * it smaller may make some file systems unmountable. 339 * it smaller may make some file systems unmountable.
340 */ 340 */
341#ifndef MAXBSIZE /* XXX */ 341#ifndef MAXBSIZE /* XXX */
342#define MAXBSIZE MAXPHYS 342#define MAXBSIZE MAXPHYS
343#endif 343#endif
344#define MAXFRAG 8 344#define MAXFRAG 8
345 345
346/* 346/*
347 * MAXPATHLEN defines the longest permissible path length after expanding 347 * MAXPATHLEN defines the longest permissible path length after expanding
348 * symbolic links. It is used to allocate a temporary buffer from the buffer 348 * symbolic links. It is used to allocate a temporary buffer from the buffer
349 * pool in which to do the name expansion, hence should be a power of two, 349 * pool in which to do the name expansion, hence should be a power of two,
350 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 350 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
351 * maximum number of symbolic links that may be expanded in a path name. 351 * maximum number of symbolic links that may be expanded in a path name.
352 * It should be set high enough to allow all legitimate uses, but halt 352 * It should be set high enough to allow all legitimate uses, but halt
353 * infinite loops reasonably quickly. 353 * infinite loops reasonably quickly.
354 * 354 *
355 * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>) 355 * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>)
356 */ 356 */
357#define MAXPATHLEN PATH_MAX 357#define MAXPATHLEN PATH_MAX
358#define MAXSYMLINKS 32 358#define MAXSYMLINKS 32
359 359
360/* 360/*
361 * This is the maximum individual filename component length enforced by 361 * This is the maximum individual filename component length enforced by
362 * namei. Filesystems cannot exceed this limit. The upper bound for that 362 * namei. Filesystems cannot exceed this limit. The upper bound for that
363 * limit is NAME_MAX. We don't bump it for now, for compatibility with 363 * limit is NAME_MAX. We don't bump it for now, for compatibility with
364 * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was 364 * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was
365 * 255 365 * 255
366 */ 366 */
367#define KERNEL_NAME_MAX 255 367#define KERNEL_NAME_MAX 255
368 368
369/* Bit map related macros. */ 369/* Bit map related macros. */
370#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 370#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
371#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 371#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
372#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 372#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
373#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 373#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
374 374
375/* Macros for counting and rounding. */ 375/* Macros for counting and rounding. */
376#ifndef howmany 376#ifndef howmany
377#define howmany(x, y) (((x)+((y)-1))/(y)) 377#define howmany(x, y) (((x)+((y)-1))/(y))
378#endif 378#endif
379#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 379#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
380#define rounddown(x,y) (((x)/(y))*(y)) 380#define rounddown(x,y) (((x)/(y))*(y))
381 381
382/* 382/*
383 * Rounding to powers of two. The naive definitions of roundup2 and 383 * Rounding to powers of two. The naive definitions of roundup2 and
384 * rounddown2, 384 * rounddown2,
385 * 385 *
386 * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1)) 386 * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1))
387 * #define rounddown2(x,m) ((x) & ~((m) - 1)), 387 * #define rounddown2(x,m) ((x) & ~((m) - 1)),
388 * 388 *
389 * exhibit a quirk of integer arithmetic in C because the complement 389 * exhibit a quirk of integer arithmetic in C because the complement
390 * happens in the type of m, not in the type of x. So if unsigned int 390 * happens in the type of m, not in the type of x. So if unsigned int
391 * is 32-bit, and m is an unsigned int while x is a uint64_t, then 391 * is 32-bit, and m is an unsigned int while x is a uint64_t, then
392 * roundup2 and rounddown2 would have the unintended effect of clearing 392 * roundup2 and rounddown2 would have the unintended effect of clearing
393 * the upper 32 bits of the result(!). These definitions avoid the 393 * the upper 32 bits of the result(!). These definitions avoid the
394 * pitfalls of C arithmetic depending on the types of x and m, and 394 * pitfalls of C arithmetic depending on the types of x and m, and
395 * additionally avoid multiply evaluating their arguments. 395 * additionally avoid multiply evaluating their arguments.
396 */ 396 */
397#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1) 397#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1)
398#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1))) 398#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1)))
399 399
400#define powerof2(x) ((((x)-1)&(x))==0) 400#define powerof2(x) ((((x)-1)&(x))==0)
401 401
402/* 402/*
403 * Constants for setting the parameters of the kernel memory allocator. 403 * Constants for setting the parameters of the kernel memory allocator.
404 * 404 *
405 * 2 ** MINBUCKET is the smallest unit of memory that will be 405 * 2 ** MINBUCKET is the smallest unit of memory that will be
406 * allocated. It must be at least large enough to hold a pointer. 406 * allocated. It must be at least large enough to hold a pointer.
407 * 407 *
408 * Units of memory less or equal to MAXALLOCSAVE will permanently 408 * Units of memory less or equal to MAXALLOCSAVE will permanently
409 * allocate physical memory; requests for these size pieces of 409 * allocate physical memory; requests for these size pieces of
410 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 410 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
411 * always allocate and free physical memory; requests for these 411 * always allocate and free physical memory; requests for these
412 * size allocations should be done infrequently as they will be slow. 412 * size allocations should be done infrequently as they will be slow.
413 * 413 *
414 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 414 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
415 * MAXALLOCSAVE must be a power of two. 415 * MAXALLOCSAVE must be a power of two.
416 */ 416 */
417#ifdef _LP64 417#ifdef _LP64
418#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ 418#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */
419#else 419#else
420#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 420#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
421#endif 421#endif
422#define MAXALLOCSAVE (2 * NBPG) 422#define MAXALLOCSAVE (2 * NBPG)
423 423
424/* 424/*
425 * Scale factor for scaled integers used to count %cpu time and load avgs. 425 * Scale factor for scaled integers used to count %cpu time and load avgs.
426 * 426 *
427 * The number of CPU `tick's that map to a unique `%age' can be expressed 427 * The number of CPU `tick's that map to a unique `%age' can be expressed
428 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 428 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
429 * can be calculated (assuming 32 bits) can be closely approximated using 429 * can be calculated (assuming 32 bits) can be closely approximated using
430 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 430 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
431 * 431 *
432 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 432 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
433 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 433 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
434 */ 434 */
435#define FSHIFT 11 /* bits to right of fixed binary point */ 435#define FSHIFT 11 /* bits to right of fixed binary point */
436#define FSCALE (1<<FSHIFT) 436#define FSCALE (1<<FSHIFT)
437 437
438/* 438/*
439 * The time for a process to be blocked before being very swappable. 439 * The time for a process to be blocked before being very swappable.
440 * This is a number of seconds which the system takes as being a non-trivial 440 * This is a number of seconds which the system takes as being a non-trivial
441 * amount of real time. You probably shouldn't change this; 441 * amount of real time. You probably shouldn't change this;
442 * it is used in subtle ways (fractions and multiples of it are, that is, like 442 * it is used in subtle ways (fractions and multiples of it are, that is, like
443 * half of a ``long time'', almost a long time, etc.) 443 * half of a ``long time'', almost a long time, etc.)
444 * It is related to human patience and other factors which don't really 444 * It is related to human patience and other factors which don't really
445 * change over time. 445 * change over time.
446 */ 446 */
447#define MAXSLP 20 447#define MAXSLP 20
448 448
449/* 449/*
450 * Defaults for Unified Buffer Cache parameters. 450 * Defaults for Unified Buffer Cache parameters.
451 * These may be overridden in <machine/param.h>. 451 * These may be overridden in <machine/param.h>.
452 */ 452 */
453 453
454#ifndef UBC_WINSHIFT 454#ifndef UBC_WINSHIFT
455#define UBC_WINSHIFT 13 455#define UBC_WINSHIFT 13
456#endif 456#endif
457#ifndef UBC_NWINS 457#ifndef UBC_NWINS
458#define UBC_NWINS 1024 458#define UBC_NWINS 1024
459#endif 459#endif
460 460
461#ifdef _KERNEL 461#ifdef _KERNEL
462/* 462/*
463 * macro to convert from milliseconds to hz without integer overflow 463 * macro to convert from milliseconds to hz without integer overflow
464 * Default version using only 32bits arithmetics. 464 * Default version using only 32bits arithmetics.
465 * 64bit port can define 64bit version in their <machine/param.h> 465 * 64bit port can define 64bit version in their <machine/param.h>
466 * 0x20000 is safe for hz < 20000 466 * 0x20000 is safe for hz < 20000
467 */ 467 */
468#ifndef mstohz 468#ifndef mstohz
469#define mstohz(ms) \ 469#define mstohz(ms) \
470 (__predict_false((ms) >= 0x20000) ? \ 470 (__predict_false((ms) >= 0x20000) ? \
471 ((ms +0u) / 1000u) * hz : \ 471 ((ms +0u) / 1000u) * hz : \
472 ((ms +0u) * hz) / 1000u) 472 ((ms +0u) * hz) / 1000u)
473#endif 473#endif
474#ifndef hztoms 474#ifndef hztoms
475#define hztoms(t) \ 475#define hztoms(t) \
476 (__predict_false((t) >= 0x20000) ? \ 476 (__predict_false((t) >= 0x20000) ? \
477 ((t +0u) / hz) * 1000u : \ 477 ((t +0u) / hz) * 1000u : \
478 ((t +0u) * 1000u) / hz) 478 ((t +0u) * 1000u) / hz)
479#endif 479#endif
480 480
481#define hz2bintime(t) (ms2bintime(hztoms(t))) 481#define hz2bintime(t) (ms2bintime(hztoms(t)))
482 482
483extern const int schedppq; 483extern const int schedppq;
484extern size_t coherency_unit; 484extern size_t coherency_unit;
485 485
486#endif /* _KERNEL */ 486#endif /* _KERNEL */
487 487
488/* 488/*
489 * Minimum alignment of "struct lwp" needed by the architecture. 489 * Minimum alignment of "struct lwp" needed by the architecture.
490 * This counts when packing a lock byte into a word alongside a 490 * This counts when packing a lock byte into a word alongside a
491 * pointer to an LWP. 491 * pointer to an LWP.
492 */ 492 */
493#ifndef MIN_LWP_ALIGNMENT 493#ifndef MIN_LWP_ALIGNMENT
494#define MIN_LWP_ALIGNMENT 32 494#define MIN_LWP_ALIGNMENT 32
495#endif 495#endif
496#endif /* !__ASSEMBLER__ */ 496#endif /* !__ASSEMBLER__ */
497 497
498#endif /* !_SYS_PARAM_H_ */ 498#endif /* !_SYS_PARAM_H_ */