Wed Jan 23 00:38:02 2013 UTC ()
tweak assertions


(yamt)
diff -r1.1.2.6 -r1.1.2.7 src/sys/uvm/uvm_page_array.c

cvs diff -r1.1.2.6 -r1.1.2.7 src/sys/uvm/uvm_page_array.c (expand / switch to unified diff)

--- src/sys/uvm/uvm_page_array.c 2012/08/01 22:34:14 1.1.2.6
+++ src/sys/uvm/uvm_page_array.c 2013/01/23 00:38:01 1.1.2.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvm_page_array.c,v 1.1.2.6 2012/08/01 22:34:14 yamt Exp $ */ 1/* $NetBSD: uvm_page_array.c,v 1.1.2.7 2013/01/23 00:38:01 yamt Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2011 YAMAMOTO Takashi, 4 * Copyright (c)2011 YAMAMOTO Takashi,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: uvm_page_array.c,v 1.1.2.6 2012/08/01 22:34:14 yamt Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: uvm_page_array.c,v 1.1.2.7 2013/01/23 00:38:01 yamt Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34 34
35#include <uvm/uvm_extern.h> 35#include <uvm/uvm_extern.h>
36#include <uvm/uvm_object.h> 36#include <uvm/uvm_object.h>
37#include <uvm/uvm_page.h> 37#include <uvm/uvm_page.h>
38#include <uvm/uvm_page_array.h> 38#include <uvm/uvm_page_array.h>
39 39
40/* 40/*
41 * uvm_page_array_init: initialize the array. 41 * uvm_page_array_init: initialize the array.
42 */ 42 */
43 43
@@ -161,35 +161,35 @@ uvm_page_array_fill(struct uvm_page_arra @@ -161,35 +161,35 @@ uvm_page_array_fill(struct uvm_page_arra
161 maxpages, dense); 161 maxpages, dense);
162 } 162 }
163 if (npages == 0) { 163 if (npages == 0) {
164 uvm_page_array_clear(ar); 164 uvm_page_array_clear(ar);
165 return ENOENT; 165 return ENOENT;
166 } 166 }
167 KASSERT(npages <= maxpages); 167 KASSERT(npages <= maxpages);
168 ar->ar_npages = npages; 168 ar->ar_npages = npages;
169 ar->ar_idx = 0; 169 ar->ar_idx = 0;
170#if defined(DEBUG) 170#if defined(DEBUG)
171 for (i = 0; i < ar->ar_npages; i++) { 171 for (i = 0; i < ar->ar_npages; i++) {
172 struct vm_page * const pg = ar->ar_pages[i]; 172 struct vm_page * const pg = ar->ar_pages[i];
173 173
174 KASSERT(pg != NULL); 174 KDASSERT(pg != NULL);
175 KASSERT(pg->uobject == uobj); 175 KDASSERT(pg->uobject == uobj);
176 if (backward) { 176 if (backward) {
177 KASSERT(pg->offset <= off); 177 KDASSERT(pg->offset <= off);
178 KASSERT(i == 0 || 178 KDASSERT(i == 0 ||
179 pg->offset < ar->ar_pages[i - 1]->offset); 179 pg->offset < ar->ar_pages[i - 1]->offset);
180 } else { 180 } else {
181 KASSERT(pg->offset >= off); 181 KDASSERT(pg->offset >= off);
182 KASSERT(i == 0 || 182 KDASSERT(i == 0 ||
183 pg->offset > ar->ar_pages[i - 1]->offset); 183 pg->offset > ar->ar_pages[i - 1]->offset);
184 } 184 }
185 } 185 }
186#endif /* defined(DEBUG) */ 186#endif /* defined(DEBUG) */
187 return 0; 187 return 0;
188} 188}
189 189
190/* 190/*
191 * uvm_page_array_fill_and_peek: 191 * uvm_page_array_fill_and_peek:
192 * same as uvm_page_array_peek except that, if the array is empty, try to fill 192 * same as uvm_page_array_peek except that, if the array is empty, try to fill
193 * it first. 193 * it first.
194 */ 194 */
195 195