Tue Jan 28 20:35:04 2020 UTC ()
NetBSD 9.99.43 - struct lwp, pri_t changed


(ad)
diff -r1.645 -r1.646 src/sys/sys/param.h

cvs diff -r1.645 -r1.646 src/sys/sys/param.h (switch to unified diff)

--- src/sys/sys/param.h 2020/01/23 17:03:20 1.645
+++ src/sys/sys/param.h 2020/01/28 20:35:04 1.646
@@ -1,543 +1,543 @@ @@ -1,543 +1,543 @@
1/* $NetBSD: param.h,v 1.645 2020/01/23 17:03:20 ad Exp $ */ 1/* $NetBSD: param.h,v 1.646 2020/01/28 20:35:04 ad 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__ 999004200 /* NetBSD 9.99.42 */ 70#define __NetBSD_Version__ 999004300 /* NetBSD 9.99.43 */
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 * These macros determine if we are running in protected mode or not. 90 * These 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#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */ 176#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
177#define DEV_BSIZE (1 << DEV_BSHIFT) /* 512 */ 177#define DEV_BSIZE (1 << DEV_BSHIFT) /* 512 */
178 178
179#ifndef BLKDEV_IOSIZE 179#ifndef BLKDEV_IOSIZE
180#define BLKDEV_IOSIZE 2048 180#define BLKDEV_IOSIZE 2048
181#endif 181#endif
182 182
183#ifndef MAXPHYS 183#ifndef MAXPHYS
184#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */ 184#define MAXPHYS (64 * 1024) /* max raw I/O transfer size */
185#endif 185#endif
186 186
187/* pages ("clicks") to disk blocks */ 187/* pages ("clicks") to disk blocks */
188#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT)) 188#define ctod(x) ((x) << (PGSHIFT - DEV_BSHIFT))
189#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT)) 189#define dtoc(x) ((x) >> (PGSHIFT - DEV_BSHIFT))
190 190
191/* bytes to pages */ 191/* bytes to pages */
192#define ctob(x) ((x) << PGSHIFT) 192#define ctob(x) ((x) << PGSHIFT)
193#define btoc(x) (((x) + PGOFSET) >> PGSHIFT) 193#define btoc(x) (((x) + PGOFSET) >> PGSHIFT)
194 194
195/* bytes to disk blocks */ 195/* bytes to disk blocks */
196#define dbtob(x) ((x) << DEV_BSHIFT) 196#define dbtob(x) ((x) << DEV_BSHIFT)
197#define btodb(x) ((x) >> DEV_BSHIFT) 197#define btodb(x) ((x) >> DEV_BSHIFT)
198 198
199/* Coherency unit: assumed cache line size. See also MIN_LWP_ALIGNMENT. */ 199/* Coherency unit: assumed cache line size. See also MIN_LWP_ALIGNMENT. */
200#ifndef COHERENCY_UNIT 200#ifndef COHERENCY_UNIT
201#define COHERENCY_UNIT 64 201#define COHERENCY_UNIT 64
202#endif 202#endif
203#ifndef CACHE_LINE_SIZE 203#ifndef CACHE_LINE_SIZE
204#define CACHE_LINE_SIZE 64 204#define CACHE_LINE_SIZE 64
205#endif 205#endif
206#ifndef MAXCPUS 206#ifndef MAXCPUS
207#define MAXCPUS 32 207#define MAXCPUS 32
208#endif 208#endif
209#ifndef MAX_LWP_PER_PROC 209#ifndef MAX_LWP_PER_PROC
210#define MAX_LWP_PER_PROC 8000 210#define MAX_LWP_PER_PROC 8000
211#endif 211#endif
212 212
213/* 213/*
214 * Stack macros. On most architectures, the stack grows down, 214 * Stack macros. On most architectures, the stack grows down,
215 * towards lower addresses; it is the rare architecture where 215 * towards lower addresses; it is the rare architecture where
216 * it grows up, towards higher addresses. 216 * it grows up, towards higher addresses.
217 * 217 *
218 * STACK_GROW and STACK_SHRINK adjust a stack pointer by some 218 * STACK_GROW and STACK_SHRINK adjust a stack pointer by some
219 * size, no questions asked. STACK_ALIGN aligns a stack pointer. 219 * size, no questions asked. STACK_ALIGN aligns a stack pointer.
220 * 220 *
221 * STACK_ALLOC returns a pointer to allocated stack space of 221 * STACK_ALLOC returns a pointer to allocated stack space of
222 * some size; given such a pointer and a size, STACK_MAX gives 222 * some size; given such a pointer and a size, STACK_MAX gives
223 * the maximum (in the "maxsaddr" sense) stack address of the 223 * the maximum (in the "maxsaddr" sense) stack address of the
224 * allocated memory. 224 * allocated memory.
225 */ 225 */
226#if defined(_KERNEL) || defined(__EXPOSE_STACK) 226#if defined(_KERNEL) || defined(__EXPOSE_STACK)
227 227
228#ifndef STACK_ALIGNBYTES 228#ifndef STACK_ALIGNBYTES
229#define STACK_ALIGNBYTES __ALIGNBYTES 229#define STACK_ALIGNBYTES __ALIGNBYTES
230#endif 230#endif
231 231
232#ifdef __MACHINE_STACK_GROWS_UP 232#ifdef __MACHINE_STACK_GROWS_UP
233#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size)) 233#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) + (_size))
234#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size)) 234#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) - (_size))
235#define STACK_ALIGN(sp, bytes) \ 235#define STACK_ALIGN(sp, bytes) \
236 ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes))) 236 ((char *)((((unsigned long)(sp)) + (bytes)) & ~(bytes)))
237#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp)) 237#define STACK_ALLOC(sp, _size) ((char *)(void *)(sp))
238#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size)) 238#define STACK_MAX(p, _size) (((char *)(void *)(p)) + (_size))
239#else 239#else
240#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size)) 240#define STACK_GROW(sp, _size) (((char *)(void *)(sp)) - (_size))
241#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size)) 241#define STACK_SHRINK(sp, _size) (((char *)(void *)(sp)) + (_size))
242#define STACK_ALIGN(sp, bytes) \ 242#define STACK_ALIGN(sp, bytes) \
243 ((char *)(((unsigned long)(sp)) & ~(bytes))) 243 ((char *)(((unsigned long)(sp)) & ~(bytes)))
244#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size)) 244#define STACK_ALLOC(sp, _size) (((char *)(void *)(sp)) - (_size))
245#define STACK_MAX(p, _size) ((char *)(void *)(p)) 245#define STACK_MAX(p, _size) ((char *)(void *)(p))
246#endif 246#endif
247#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes)) 247#define STACK_LEN_ALIGN(len, bytes) (((len) + (bytes)) & ~(bytes))
248 248
249#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */ 249#endif /* defined(_KERNEL) || defined(__EXPOSE_STACK) */
250 250
251/* 251/*
252 * Round p (pointer or byte index) up to a correctly-aligned value for all 252 * Round p (pointer or byte index) up to a correctly-aligned value for all
253 * data types (int, long, ...). The result is u_int and must be cast to 253 * data types (int, long, ...). The result is u_int and must be cast to
254 * any desired pointer type. 254 * any desired pointer type.
255 * 255 *
256 * ALIGNED_POINTER is a boolean macro that checks whether an address 256 * ALIGNED_POINTER is a boolean macro that checks whether an address
257 * is valid to fetch data elements of type t from on this architecture 257 * is valid to fetch data elements of type t from on this architecture
258 * using ALIGNED_POINTER_LOAD. This does not reflect the optimal 258 * using ALIGNED_POINTER_LOAD. This does not reflect the optimal
259 * alignment, just the possibility (within reasonable limits). 259 * alignment, just the possibility (within reasonable limits).
260 * 260 *
261 * uint32_t x; 261 * uint32_t x;
262 * unsigned char *p = ...; 262 * unsigned char *p = ...;
263 * 263 *
264 * if (ALIGNED_POINTER(p, uint32_t)) { 264 * if (ALIGNED_POINTER(p, uint32_t)) {
265 * uint32_t t; 265 * uint32_t t;
266 * ALIGNED_POINTER_LOAD(&t, p, uint32_t); 266 * ALIGNED_POINTER_LOAD(&t, p, uint32_t);
267 * x = t; 267 * x = t;
268 * } else { 268 * } else {
269 * uint32_t t; 269 * uint32_t t;
270 * memcpy(&t, p, sizeof(t)); 270 * memcpy(&t, p, sizeof(t));
271 * x = t; 271 * x = t;
272 * } 272 * }
273 * 273 *
274 */ 274 */
275#define ALIGNBYTES __ALIGNBYTES 275#define ALIGNBYTES __ALIGNBYTES
276#ifndef ALIGN 276#ifndef ALIGN
277#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES) 277#define ALIGN(p) (((uintptr_t)(p) + ALIGNBYTES) & ~ALIGNBYTES)
278#endif 278#endif
279#ifndef ALIGNED_POINTER 279#ifndef ALIGNED_POINTER
280#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t) - 1)) == 0) 280#define ALIGNED_POINTER(p,t) ((((uintptr_t)(p)) & (sizeof(t) - 1)) == 0)
281#endif 281#endif
282#ifndef ALIGNED_POINTER_LOAD 282#ifndef ALIGNED_POINTER_LOAD
283#define ALIGNED_POINTER_LOAD(q,p,t) (*(q) = *((const t *)(p))) 283#define ALIGNED_POINTER_LOAD(q,p,t) (*(q) = *((const t *)(p)))
284#endif 284#endif
285 285
286/* 286/*
287 * Historic priority levels. These are meaningless and remain only 287 * Historic priority levels. These are meaningless and remain only
288 * for source compatibility. Do not use in new code. 288 * for source compatibility. Do not use in new code.
289 */ 289 */
290#define PSWP 0 290#define PSWP 0
291#define PVM 4 291#define PVM 4
292#define PINOD 8 292#define PINOD 8
293#define PRIBIO 16 293#define PRIBIO 16
294#define PVFS 20 294#define PVFS 20
295#define PZERO 22 295#define PZERO 22
296#define PSOCK 24 296#define PSOCK 24
297#define PWAIT 32 297#define PWAIT 32
298#define PLOCK 36 298#define PLOCK 36
299#define PPAUSE 40 299#define PPAUSE 40
300#define PUSER 50 300#define PUSER 50
301#define MAXPRI 127 301#define MAXPRI 127
302 302
303#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */ 303#define PCATCH 0x100 /* OR'd with pri for tsleep to check signals */
304#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */ 304#define PNORELOCK 0x200 /* OR'd with pri for tsleep to not relock */
305 305
306/* 306/*
307 * New priority levels. 307 * New priority levels.
308 */ 308 */
309#define PRI_COUNT 224 309#define PRI_COUNT 224
310#define PRI_NONE (-1) 310#define PRI_NONE (-1)
311 311
312#define PRI_KERNEL_RT 192 312#define PRI_KERNEL_RT 192
313#define NPRI_KERNEL_RT 32 313#define NPRI_KERNEL_RT 32
314#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1) 314#define MAXPRI_KERNEL_RT (PRI_KERNEL_RT + NPRI_KERNEL_RT - 1)
315 315
316#define PRI_USER_RT 128 316#define PRI_USER_RT 128
317#define NPRI_USER_RT 64 317#define NPRI_USER_RT 64
318#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1) 318#define MAXPRI_USER_RT (PRI_USER_RT + NPRI_USER_RT - 1)
319 319
320#define PRI_KTHREAD 96 320#define PRI_KTHREAD 96
321#define NPRI_KTHREAD 32 321#define NPRI_KTHREAD 32
322#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1) 322#define MAXPRI_KTHREAD (PRI_KTHREAD + NPRI_KTHREAD - 1)
323 323
324#define PRI_KERNEL 64 324#define PRI_KERNEL 64
325#define NPRI_KERNEL 32 325#define NPRI_KERNEL 32
326#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1) 326#define MAXPRI_KERNEL (PRI_KERNEL + NPRI_KERNEL - 1)
327 327
328#define PRI_USER 0 328#define PRI_USER 0
329#define NPRI_USER 64 329#define NPRI_USER 64
330#define MAXPRI_USER (PRI_USER + NPRI_USER - 1) 330#define MAXPRI_USER (PRI_USER + NPRI_USER - 1)
331 331
332/* Priority range used by POSIX real-time features */ 332/* Priority range used by POSIX real-time features */
333#define SCHED_PRI_MIN 0 333#define SCHED_PRI_MIN 0
334#define SCHED_PRI_MAX 63 334#define SCHED_PRI_MAX 63
335 335
336/* 336/*
337 * Kernel thread priorities. 337 * Kernel thread priorities.
338 */ 338 */
339#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT 339#define PRI_SOFTSERIAL MAXPRI_KERNEL_RT
340#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1) 340#define PRI_SOFTNET (MAXPRI_KERNEL_RT - schedppq * 1)
341#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2) 341#define PRI_SOFTBIO (MAXPRI_KERNEL_RT - schedppq * 2)
342#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3) 342#define PRI_SOFTCLOCK (MAXPRI_KERNEL_RT - schedppq * 3)
343 343
344#define PRI_XCALL MAXPRI_KTHREAD 344#define PRI_XCALL MAXPRI_KTHREAD
345#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1) 345#define PRI_PGDAEMON (MAXPRI_KTHREAD - schedppq * 1)
346#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2) 346#define PRI_VM (MAXPRI_KTHREAD - schedppq * 2)
347#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3) 347#define PRI_IOFLUSH (MAXPRI_KTHREAD - schedppq * 3)
348#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4) 348#define PRI_BIO (MAXPRI_KTHREAD - schedppq * 4)
349 349
350#define PRI_IDLE PRI_USER 350#define PRI_IDLE PRI_USER
351 351
352/* 352/*
353 * Miscellaneous. 353 * Miscellaneous.
354 */ 354 */
355#define NBPW sizeof(int) /* number of bytes per word (integer) */ 355#define NBPW sizeof(int) /* number of bytes per word (integer) */
356 356
357#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */ 357#define CMASK 022 /* default file mask: S_IWGRP|S_IWOTH */
358#define NODEV (dev_t)(-1) /* non-existent device */ 358#define NODEV (dev_t)(-1) /* non-existent device */
359 359
360/* 360/*
361 * File system parameters and macros. 361 * File system parameters and macros.
362 * 362 *
363 * The file system is made out of blocks of at most MAXBSIZE units, with 363 * The file system is made out of blocks of at most MAXBSIZE units, with
364 * smaller units (fragments) only in the last direct block. MAXBSIZE 364 * smaller units (fragments) only in the last direct block. MAXBSIZE
365 * primarily determines the size of buffers in the buffer pool. It may be 365 * primarily determines the size of buffers in the buffer pool. It may be
366 * made larger without any effect on existing file systems; however making 366 * made larger without any effect on existing file systems; however making
367 * it smaller may make some file systems unmountable. 367 * it smaller may make some file systems unmountable.
368 */ 368 */
369#ifndef MAXBSIZE /* XXX */ 369#ifndef MAXBSIZE /* XXX */
370#define MAXBSIZE MAXPHYS 370#define MAXBSIZE MAXPHYS
371#endif 371#endif
372#define MAXFRAG 8 372#define MAXFRAG 8
373 373
374/* 374/*
375 * MAXPATHLEN defines the longest permissible path length after expanding 375 * MAXPATHLEN defines the longest permissible path length after expanding
376 * symbolic links. It is used to allocate a temporary buffer from the buffer 376 * symbolic links. It is used to allocate a temporary buffer from the buffer
377 * pool in which to do the name expansion, hence should be a power of two, 377 * pool in which to do the name expansion, hence should be a power of two,
378 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the 378 * and must be less than or equal to MAXBSIZE. MAXSYMLINKS defines the
379 * maximum number of symbolic links that may be expanded in a path name. 379 * maximum number of symbolic links that may be expanded in a path name.
380 * It should be set high enough to allow all legitimate uses, but halt 380 * It should be set high enough to allow all legitimate uses, but halt
381 * infinite loops reasonably quickly. 381 * infinite loops reasonably quickly.
382 * 382 *
383 * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>) 383 * MAXSYMLINKS should be >= _POSIX_SYMLOOP_MAX (see <limits.h>)
384 */ 384 */
385#define MAXPATHLEN PATH_MAX 385#define MAXPATHLEN PATH_MAX
386#define MAXSYMLINKS 32 386#define MAXSYMLINKS 32
387 387
388/* 388/*
389 * This is the maximum individual filename component length enforced by 389 * This is the maximum individual filename component length enforced by
390 * namei. Filesystems cannot exceed this limit. The upper bound for that 390 * namei. Filesystems cannot exceed this limit. The upper bound for that
391 * limit is NAME_MAX. We don't bump it for now, for compatibility with 391 * limit is NAME_MAX. We don't bump it for now, for compatibility with
392 * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was 392 * old binaries during the time where MAXNAMLEN was 511 and NAME_MAX was
393 * 255 393 * 255
394 */ 394 */
395#define KERNEL_NAME_MAX 255 395#define KERNEL_NAME_MAX 255
396 396
397/* Bit map related macros. */ 397/* Bit map related macros. */
398#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 398#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
399#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 399#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
400#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 400#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
401#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 401#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
402 402
403/* Macros for counting and rounding. */ 403/* Macros for counting and rounding. */
404#ifndef howmany 404#ifndef howmany
405#define howmany(x, y) (((x)+((y)-1))/(y)) 405#define howmany(x, y) (((x)+((y)-1))/(y))
406#endif 406#endif
407#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) 407#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
408#define rounddown(x,y) (((x)/(y))*(y)) 408#define rounddown(x,y) (((x)/(y))*(y))
409 409
410/* 410/*
411 * Rounding to powers of two. The naive definitions of roundup2 and 411 * Rounding to powers of two. The naive definitions of roundup2 and
412 * rounddown2, 412 * rounddown2,
413 * 413 *
414 * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1)) 414 * #define roundup2(x,m) (((x) + ((m) - 1)) & ~((m) - 1))
415 * #define rounddown2(x,m) ((x) & ~((m) - 1)), 415 * #define rounddown2(x,m) ((x) & ~((m) - 1)),
416 * 416 *
417 * exhibit a quirk of integer arithmetic in C because the complement 417 * exhibit a quirk of integer arithmetic in C because the complement
418 * happens in the type of m, not in the type of x. So if unsigned int 418 * happens in the type of m, not in the type of x. So if unsigned int
419 * is 32-bit, and m is an unsigned int while x is a uint64_t, then 419 * is 32-bit, and m is an unsigned int while x is a uint64_t, then
420 * roundup2 and rounddown2 would have the unintended effect of clearing 420 * roundup2 and rounddown2 would have the unintended effect of clearing
421 * the upper 32 bits of the result(!). These definitions avoid the 421 * the upper 32 bits of the result(!). These definitions avoid the
422 * pitfalls of C arithmetic depending on the types of x and m, and 422 * pitfalls of C arithmetic depending on the types of x and m, and
423 * additionally avoid multiply evaluating their arguments. 423 * additionally avoid multiply evaluating their arguments.
424 */ 424 */
425#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1) 425#define roundup2(x,m) ((((x) - 1) | ((m) - 1)) + 1)
426#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1))) 426#define rounddown2(x,m) ((x) & ~((__typeof__(x))((m) - 1)))
427 427
428#define powerof2(x) ((((x)-1)&(x))==0) 428#define powerof2(x) ((((x)-1)&(x))==0)
429 429
430/* 430/*
431 * Constants for setting the parameters of the kernel memory allocator. 431 * Constants for setting the parameters of the kernel memory allocator.
432 * 432 *
433 * 2 ** MINBUCKET is the smallest unit of memory that will be 433 * 2 ** MINBUCKET is the smallest unit of memory that will be
434 * allocated. It must be at least large enough to hold a pointer. 434 * allocated. It must be at least large enough to hold a pointer.
435 * 435 *
436 * Units of memory less or equal to MAXALLOCSAVE will permanently 436 * Units of memory less or equal to MAXALLOCSAVE will permanently
437 * allocate physical memory; requests for these size pieces of 437 * allocate physical memory; requests for these size pieces of
438 * memory are quite fast. Allocations greater than MAXALLOCSAVE must 438 * memory are quite fast. Allocations greater than MAXALLOCSAVE must
439 * always allocate and free physical memory; requests for these 439 * always allocate and free physical memory; requests for these
440 * size allocations should be done infrequently as they will be slow. 440 * size allocations should be done infrequently as they will be slow.
441 * 441 *
442 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and 442 * Constraints: NBPG <= MAXALLOCSAVE <= 2 ** (MINBUCKET + 14), and
443 * MAXALLOCSAVE must be a power of two. 443 * MAXALLOCSAVE must be a power of two.
444 */ 444 */
445#ifdef _LP64 445#ifdef _LP64
446#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */ 446#define MINBUCKET 5 /* 5 => min allocation of 32 bytes */
447#else 447#else
448#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */ 448#define MINBUCKET 4 /* 4 => min allocation of 16 bytes */
449#endif 449#endif
450#define MAXALLOCSAVE (2 * NBPG) 450#define MAXALLOCSAVE (2 * NBPG)
451 451
452/* 452/*
453 * Scale factor for scaled integers used to count %cpu time and load avgs. 453 * Scale factor for scaled integers used to count %cpu time and load avgs.
454 * 454 *
455 * The number of CPU `tick's that map to a unique `%age' can be expressed 455 * The number of CPU `tick's that map to a unique `%age' can be expressed
456 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that 456 * by the formula (1 / (2 ^ (FSHIFT - 11))). The maximum load average that
457 * can be calculated (assuming 32 bits) can be closely approximated using 457 * can be calculated (assuming 32 bits) can be closely approximated using
458 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15). 458 * the formula (2 ^ (2 * (16 - FSHIFT))) for (FSHIFT < 15).
459 * 459 *
460 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age', 460 * For the scheduler to maintain a 1:1 mapping of CPU `tick' to `%age',
461 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024. 461 * FSHIFT must be at least 11; this gives us a maximum load avg of ~1024.
462 */ 462 */
463#define FSHIFT 11 /* bits to right of fixed binary point */ 463#define FSHIFT 11 /* bits to right of fixed binary point */
464#define FSCALE (1<<FSHIFT) 464#define FSCALE (1<<FSHIFT)
465 465
466/* 466/*
467 * The time for a process to be blocked before being very swappable. 467 * The time for a process to be blocked before being very swappable.
468 * This is a number of seconds which the system takes as being a non-trivial 468 * This is a number of seconds which the system takes as being a non-trivial
469 * amount of real time. You probably shouldn't change this; 469 * amount of real time. You probably shouldn't change this;
470 * it is used in subtle ways (fractions and multiples of it are, that is, like 470 * it is used in subtle ways (fractions and multiples of it are, that is, like
471 * half of a ``long time'', almost a long time, etc.) 471 * half of a ``long time'', almost a long time, etc.)
472 * It is related to human patience and other factors which don't really 472 * It is related to human patience and other factors which don't really
473 * change over time. 473 * change over time.
474 */ 474 */
475#define MAXSLP 20 475#define MAXSLP 20
476 476
477/* 477/*
478 * Defaults for Unified Buffer Cache parameters. 478 * Defaults for Unified Buffer Cache parameters.
479 * These may be overridden in <machine/param.h>. 479 * These may be overridden in <machine/param.h>.
480 */ 480 */
481 481
482#ifndef UBC_WINSHIFT 482#ifndef UBC_WINSHIFT
483#define UBC_WINSHIFT 13 483#define UBC_WINSHIFT 13
484#endif 484#endif
485#ifndef UBC_NWINS 485#ifndef UBC_NWINS
486#define UBC_NWINS 1024 486#define UBC_NWINS 1024
487#endif 487#endif
488 488
489#ifdef _KERNEL 489#ifdef _KERNEL
490extern int hz; 490extern int hz;
491/* 491/*
492 * macro to convert from milliseconds to hz without integer overflow 492 * macro to convert from milliseconds to hz without integer overflow
493 * The 32 bit version uses only 32bit arithmetic; 0x20000 is safe for hz < 20000 493 * The 32 bit version uses only 32bit arithmetic; 0x20000 is safe for hz < 20000
494 * the 64 bit version does the computation directly. 494 * the 64 bit version does the computation directly.
495 */ 495 */
496#ifndef mstohz 496#ifndef mstohz
497# ifdef _LP64 497# ifdef _LP64
498# define mstohz(ms) ((unsigned int)((ms + 0ul) * hz / 1000ul)) 498# define mstohz(ms) ((unsigned int)((ms + 0ul) * hz / 1000ul))
499# else 499# else
500static __inline unsigned int 500static __inline unsigned int
501mstohz(unsigned int ms) 501mstohz(unsigned int ms)
502{ 502{
503 return __predict_false(ms >= 0x20000u) ? 503 return __predict_false(ms >= 0x20000u) ?
504 (ms / 1000u) * hz : (ms * hz) / 1000u; 504 (ms / 1000u) * hz : (ms * hz) / 1000u;
505} 505}
506# endif 506# endif
507#endif 507#endif
508 508
509#ifndef hztoms 509#ifndef hztoms
510# ifdef _LP64 510# ifdef _LP64
511# define hztoms(t) ((unsigned int)(((t) + 0ul) * 1000ul / hz)) 511# define hztoms(t) ((unsigned int)(((t) + 0ul) * 1000ul / hz))
512# else 512# else
513static __inline unsigned int 513static __inline unsigned int
514hztoms(unsigned int t) 514hztoms(unsigned int t)
515{ 515{
516 return __predict_false(t >= 0x20000u) ? 516 return __predict_false(t >= 0x20000u) ?
517 (t / hz) * 1000u : (t * 1000u) / hz; 517 (t / hz) * 1000u : (t * 1000u) / hz;
518} 518}
519# endif 519# endif
520#endif 520#endif
521 521
522#define hz2bintime(t) (ms2bintime(hztoms(t))) 522#define hz2bintime(t) (ms2bintime(hztoms(t)))
523 523
524extern const int schedppq; 524extern const int schedppq;
525extern size_t coherency_unit; 525extern size_t coherency_unit;
526 526
527#endif /* _KERNEL */ 527#endif /* _KERNEL */
528 528
529/* 529/*
530 * Minimum alignment of "struct lwp" needed by the architecture. This 530 * Minimum alignment of "struct lwp" needed by the architecture. This
531 * counts when packing a lock byte into a word alongside a pointer to an 531 * counts when packing a lock byte into a word alongside a pointer to an
532 * LWP. We need a minimum of 32, but go with the cache line size. 532 * LWP. We need a minimum of 32, but go with the cache line size.
533 */ 533 */
534#ifndef MIN_LWP_ALIGNMENT 534#ifndef MIN_LWP_ALIGNMENT
535# if COHERENCY_UNIT > 32 535# if COHERENCY_UNIT > 32
536# define MIN_LWP_ALIGNMENT COHERENCY_UNIT 536# define MIN_LWP_ALIGNMENT COHERENCY_UNIT
537# else 537# else
538# define MIN_LWP_ALIGNMENT 32 538# define MIN_LWP_ALIGNMENT 32
539# endif 539# endif
540#endif 540#endif
541#endif /* !__ASSEMBLER__ */ 541#endif /* !__ASSEMBLER__ */
542 542
543#endif /* !_SYS_PARAM_H_ */ 543#endif /* !_SYS_PARAM_H_ */