Thu Jun 25 16:36:43 2020 UTC ()
If ubc_winshift gets constified, the extern declaration must be too.


(mlelstv)
diff -r1.38 -r1.39 src/sys/uvm/uvm_param.h

cvs diff -r1.38 -r1.39 src/sys/uvm/uvm_param.h (switch to unified diff)

--- src/sys/uvm/uvm_param.h 2018/08/22 01:05:24 1.38
+++ src/sys/uvm/uvm_param.h 2020/06/25 16:36:43 1.39
@@ -1,239 +1,239 @@ @@ -1,239 +1,239 @@
1/* $NetBSD: uvm_param.h,v 1.38 2018/08/22 01:05:24 msaitoh Exp $ */ 1/* $NetBSD: uvm_param.h,v 1.39 2020/06/25 16:36:43 mlelstv Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1991, 1993 4 * Copyright (c) 1991, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * The Mach Operating System project at Carnegie-Mellon University. 8 * The Mach Operating System project at Carnegie-Mellon University.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors 18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software 19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission. 20 * without specific prior written permission.
21 * 21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)vm_param.h 8.2 (Berkeley) 1/9/95 34 * @(#)vm_param.h 8.2 (Berkeley) 1/9/95
35 * 35 *
36 * 36 *
37 * Copyright (c) 1987, 1990 Carnegie-Mellon University. 37 * Copyright (c) 1987, 1990 Carnegie-Mellon University.
38 * All rights reserved. 38 * All rights reserved.
39 * 39 *
40 * Authors: Avadis Tevanian, Jr., Michael Wayne Young 40 * Authors: Avadis Tevanian, Jr., Michael Wayne Young
41 * 41 *
42 * Permission to use, copy, modify and distribute this software and 42 * Permission to use, copy, modify and distribute this software and
43 * its documentation is hereby granted, provided that both the copyright 43 * its documentation is hereby granted, provided that both the copyright
44 * notice and this permission notice appear in all copies of the 44 * notice and this permission notice appear in all copies of the
45 * software, derivative works or modified versions, and any portions 45 * software, derivative works or modified versions, and any portions
46 * thereof, and that both notices appear in supporting documentation. 46 * thereof, and that both notices appear in supporting documentation.
47 * 47 *
48 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" 48 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
49 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND 49 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
50 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. 50 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
51 * 51 *
52 * Carnegie Mellon requests users of this software to return to 52 * Carnegie Mellon requests users of this software to return to
53 * 53 *
54 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 54 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
55 * School of Computer Science 55 * School of Computer Science
56 * Carnegie Mellon University 56 * Carnegie Mellon University
57 * Pittsburgh PA 15213-3890 57 * Pittsburgh PA 15213-3890
58 * 58 *
59 * any improvements or extensions that they make and grant Carnegie the 59 * any improvements or extensions that they make and grant Carnegie the
60 * rights to redistribute these changes. 60 * rights to redistribute these changes.
61 */ 61 */
62 62
63/* 63/*
64 * Machine independent virtual memory parameters. 64 * Machine independent virtual memory parameters.
65 */ 65 */
66 66
67#ifndef _VM_PARAM_ 67#ifndef _VM_PARAM_
68#define _VM_PARAM_ 68#define _VM_PARAM_
69 69
70#ifdef _KERNEL_OPT 70#ifdef _KERNEL_OPT
71#include "opt_modular.h" 71#include "opt_modular.h"
72#include "opt_uvm.h" 72#include "opt_uvm.h"
73#endif 73#endif
74#ifdef _KERNEL 74#ifdef _KERNEL
75#include <sys/types.h> 75#include <sys/types.h>
76#include <machine/vmparam.h> 76#include <machine/vmparam.h>
77#include <sys/resourcevar.h> 77#include <sys/resourcevar.h>
78#endif 78#endif
79 79
80#if defined(_KERNEL) 80#if defined(_KERNEL)
81 81
82#if defined(PAGE_SIZE) 82#if defined(PAGE_SIZE)
83 83
84/* 84/*
85 * If PAGE_SIZE is defined at this stage, it must be a constant. 85 * If PAGE_SIZE is defined at this stage, it must be a constant.
86 */ 86 */
87 87
88#if PAGE_SIZE == 0 88#if PAGE_SIZE == 0
89#error Invalid PAGE_SIZE definition 89#error Invalid PAGE_SIZE definition
90#endif 90#endif
91 91
92/* 92/*
93 * If the platform does not need to support a variable PAGE_SIZE, 93 * If the platform does not need to support a variable PAGE_SIZE,
94 * then provide default values for MIN_PAGE_SIZE and MAX_PAGE_SIZE. 94 * then provide default values for MIN_PAGE_SIZE and MAX_PAGE_SIZE.
95 */ 95 */
96 96
97#if !defined(MIN_PAGE_SIZE) 97#if !defined(MIN_PAGE_SIZE)
98#define MIN_PAGE_SIZE PAGE_SIZE 98#define MIN_PAGE_SIZE PAGE_SIZE
99#endif /* ! MIN_PAGE_SIZE */ 99#endif /* ! MIN_PAGE_SIZE */
100 100
101#if !defined(MAX_PAGE_SIZE) 101#if !defined(MAX_PAGE_SIZE)
102#define MAX_PAGE_SIZE PAGE_SIZE 102#define MAX_PAGE_SIZE PAGE_SIZE
103#endif /* ! MAX_PAGE_SIZE */ 103#endif /* ! MAX_PAGE_SIZE */
104 104
105#else /* ! PAGE_SIZE */ 105#else /* ! PAGE_SIZE */
106 106
107/* 107/*
108 * PAGE_SIZE is not a constant; MIN_PAGE_SIZE and MAX_PAGE_SIZE must 108 * PAGE_SIZE is not a constant; MIN_PAGE_SIZE and MAX_PAGE_SIZE must
109 * be defined. 109 * be defined.
110 */ 110 */
111 111
112#if !defined(MIN_PAGE_SIZE) 112#if !defined(MIN_PAGE_SIZE)
113#error MIN_PAGE_SIZE not defined 113#error MIN_PAGE_SIZE not defined
114#endif 114#endif
115 115
116#if !defined(MAX_PAGE_SIZE) 116#if !defined(MAX_PAGE_SIZE)
117#error MAX_PAGE_SIZE not defined 117#error MAX_PAGE_SIZE not defined
118#endif 118#endif
119 119
120#endif /* PAGE_SIZE */ 120#endif /* PAGE_SIZE */
121 121
122/* 122/*
123 * MIN_PAGE_SIZE and MAX_PAGE_SIZE must be constants. 123 * MIN_PAGE_SIZE and MAX_PAGE_SIZE must be constants.
124 */ 124 */
125 125
126#if MIN_PAGE_SIZE == 0 126#if MIN_PAGE_SIZE == 0
127#error Invalid MIN_PAGE_SIZE definition 127#error Invalid MIN_PAGE_SIZE definition
128#endif 128#endif
129 129
130#if MAX_PAGE_SIZE == 0 130#if MAX_PAGE_SIZE == 0
131#error Invalid MAX_PAGE_SIZE definition 131#error Invalid MAX_PAGE_SIZE definition
132#endif 132#endif
133 133
134/* 134/*
135 * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use 135 * If MIN_PAGE_SIZE and MAX_PAGE_SIZE are not equal, then we must use
136 * non-constant PAGE_SIZE, et al for LKMs. 136 * non-constant PAGE_SIZE, et al for LKMs.
137 */ 137 */
138#if (MIN_PAGE_SIZE != MAX_PAGE_SIZE) 138#if (MIN_PAGE_SIZE != MAX_PAGE_SIZE)
139#define __uvmexp_pagesize 139#define __uvmexp_pagesize
140#if defined(_LKM) || defined(_MODULE) 140#if defined(_LKM) || defined(_MODULE)
141#undef PAGE_SIZE 141#undef PAGE_SIZE
142#undef PAGE_MASK 142#undef PAGE_MASK
143#undef PAGE_SHIFT 143#undef PAGE_SHIFT
144#endif 144#endif
145#endif 145#endif
146 146
147/* 147/*
148 * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not 148 * Now provide PAGE_SIZE, PAGE_MASK, and PAGE_SHIFT if we do not
149 * have ones that are compile-time constants. 149 * have ones that are compile-time constants.
150 */ 150 */
151#if !defined(PAGE_SIZE) 151#if !defined(PAGE_SIZE)
152extern const int *const uvmexp_pagesize; 152extern const int *const uvmexp_pagesize;
153extern const int *const uvmexp_pagemask; 153extern const int *const uvmexp_pagemask;
154extern const int *const uvmexp_pageshift; 154extern const int *const uvmexp_pageshift;
155#define PAGE_SIZE (*uvmexp_pagesize) /* size of page */ 155#define PAGE_SIZE (*uvmexp_pagesize) /* size of page */
156#define PAGE_MASK (*uvmexp_pagemask) /* size of page - 1 */ 156#define PAGE_MASK (*uvmexp_pagemask) /* size of page - 1 */
157#define PAGE_SHIFT (*uvmexp_pageshift) /* bits to shift for pages */ 157#define PAGE_SHIFT (*uvmexp_pageshift) /* bits to shift for pages */
158#endif /* PAGE_SIZE */ 158#endif /* PAGE_SIZE */
159 159
160#endif /* _KERNEL */ 160#endif /* _KERNEL */
161 161
162/* 162/*
163 * CTL_VM identifiers 163 * CTL_VM identifiers
164 */ 164 */
165#define VM_METER 1 /* struct vmmeter */ 165#define VM_METER 1 /* struct vmmeter */
166#define VM_LOADAVG 2 /* struct loadavg */ 166#define VM_LOADAVG 2 /* struct loadavg */
167#define VM_UVMEXP 3 /* struct uvmexp */ 167#define VM_UVMEXP 3 /* struct uvmexp */
168#define VM_NKMEMPAGES 4 /* kmem_map pages */ 168#define VM_NKMEMPAGES 4 /* kmem_map pages */
169#define VM_UVMEXP2 5 /* struct uvmexp_sysctl */ 169#define VM_UVMEXP2 5 /* struct uvmexp_sysctl */
170#define VM_ANONMIN 6 170#define VM_ANONMIN 6
171#define VM_EXECMIN 7 171#define VM_EXECMIN 7
172#define VM_FILEMIN 8 172#define VM_FILEMIN 8
173#define VM_MAXSLP 9 173#define VM_MAXSLP 9
174#define VM_USPACE 10 174#define VM_USPACE 10
175#define VM_ANONMAX 11 175#define VM_ANONMAX 11
176#define VM_EXECMAX 12 176#define VM_EXECMAX 12
177#define VM_FILEMAX 13 177#define VM_FILEMAX 13
178#define VM_MINADDRESS 14 178#define VM_MINADDRESS 14
179#define VM_MAXADDRESS 15 179#define VM_MAXADDRESS 15
180#define VM_PROC 16 /* process information */ 180#define VM_PROC 16 /* process information */
181#define VM_GUARD_SIZE 17 /* guard size for main thread */ 181#define VM_GUARD_SIZE 17 /* guard size for main thread */
182#define VM_THREAD_GUARD_SIZE 18 /* default guard size for new threads */ 182#define VM_THREAD_GUARD_SIZE 18 /* default guard size for new threads */
183 183
184#define VM_PROC_MAP 1 /* struct kinfo_vmentry */ 184#define VM_PROC_MAP 1 /* struct kinfo_vmentry */
185 185
186#ifndef ASSEMBLER 186#ifndef ASSEMBLER
187/* 187/*
188 * Convert addresses to pages and vice versa. 188 * Convert addresses to pages and vice versa.
189 * No rounding is used. 189 * No rounding is used.
190 */ 190 */
191#ifdef _KERNEL 191#ifdef _KERNEL
192#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT) 192#define atop(x) (((paddr_t)(x)) >> PAGE_SHIFT)
193#define ptoa(x) (((paddr_t)(x)) << PAGE_SHIFT) 193#define ptoa(x) (((paddr_t)(x)) << PAGE_SHIFT)
194 194
195/* 195/*
196 * Round off or truncate to the nearest page. These will work 196 * Round off or truncate to the nearest page. These will work
197 * for either addresses or counts (i.e., 1 byte rounds to 1 page). 197 * for either addresses or counts (i.e., 1 byte rounds to 1 page).
198 */ 198 */
199#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK) 199#define round_page(x) (((x) + PAGE_MASK) & ~PAGE_MASK)
200#define trunc_page(x) ((x) & ~PAGE_MASK) 200#define trunc_page(x) ((x) & ~PAGE_MASK)
201 201
202#ifndef VM_DEFAULT_ADDRESS_BOTTOMUP 202#ifndef VM_DEFAULT_ADDRESS_BOTTOMUP
203#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \ 203#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
204 round_page((vaddr_t)(da) + (vsize_t)maxdmap) 204 round_page((vaddr_t)(da) + (vsize_t)maxdmap)
205#endif 205#endif
206 206
207extern unsigned int user_stack_guard_size; 207extern unsigned int user_stack_guard_size;
208extern unsigned int user_thread_stack_guard_size; 208extern unsigned int user_thread_stack_guard_size;
209#ifndef VM_DEFAULT_ADDRESS_TOPDOWN 209#ifndef VM_DEFAULT_ADDRESS_TOPDOWN
210#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \ 210#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \
211 trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz) - user_stack_guard_size) 211 trunc_page(VM_MAXUSER_ADDRESS - MAXSSIZ - (sz) - user_stack_guard_size)
212#endif 212#endif
213 213
214extern int ubc_nwins; /* number of UBC mapping windows */ 214extern int ubc_nwins; /* number of UBC mapping windows */
215extern int ubc_winshift; /* shift for a UBC mapping window */ 215extern const int ubc_winshift; /* shift for a UBC mapping window */
216extern u_int uvm_emap_size; /* size of emap */ 216extern u_int uvm_emap_size; /* size of emap */
217 217
218#else 218#else
219/* out-of-kernel versions of round_page and trunc_page */ 219/* out-of-kernel versions of round_page and trunc_page */
220#define round_page(x) \ 220#define round_page(x) \
221 ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \ 221 ((((vaddr_t)(x) + (vm_page_size - 1)) / vm_page_size) * \
222 vm_page_size) 222 vm_page_size)
223#define trunc_page(x) \ 223#define trunc_page(x) \
224 ((((vaddr_t)(x)) / vm_page_size) * vm_page_size) 224 ((((vaddr_t)(x)) / vm_page_size) * vm_page_size)
225 225
226#endif /* _KERNEL */ 226#endif /* _KERNEL */
227 227
228/* 228/*
229 * typedefs, necessary for standard UVM headers. 229 * typedefs, necessary for standard UVM headers.
230 */ 230 */
231 231
232typedef unsigned int uvm_flag_t; 232typedef unsigned int uvm_flag_t;
233 233
234typedef int vm_inherit_t; /* XXX: inheritance codes */ 234typedef int vm_inherit_t; /* XXX: inheritance codes */
235typedef off_t voff_t; /* XXX: offset within a uvm_object */ 235typedef off_t voff_t; /* XXX: offset within a uvm_object */
236typedef voff_t pgoff_t; /* XXX: number of pages within a uvm object */ 236typedef voff_t pgoff_t; /* XXX: number of pages within a uvm object */
237 237
238#endif /* ASSEMBLER */ 238#endif /* ASSEMBLER */
239#endif /* _VM_PARAM_ */ 239#endif /* _VM_PARAM_ */