Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src convention about function names for predicate checking:



details:   https://anonhg.NetBSD.org/src/rev/eebb4bd92295
branches:  trunk
changeset: 819894:eebb4bd92295
user:      cherry <cherry%NetBSD.org@localhost>
date:      Thu Dec 22 08:15:20 2016 +0000

description:
convention about function names for predicate checking:
s/uvm_physseg_valid()/uvm_physseg_valid_p()/

per. matt@

diffstat:

 sys/uvm/uvm_physseg.c              |  34 ++++++++--------
 sys/uvm/uvm_physseg.h              |   8 ++--
 tests/sys/uvm/t_uvm_physseg.c      |  73 ++++++++++++++++++-------------------
 tests/sys/uvm/t_uvm_physseg_load.c |  51 +++++++++++++-------------
 4 files changed, 82 insertions(+), 84 deletions(-)

diffs (truncated from 443 to 300 lines):

diff -r f73286251395 -r eebb4bd92295 sys/uvm/uvm_physseg.c
--- a/sys/uvm/uvm_physseg.c     Thu Dec 22 07:56:38 2016 +0000
+++ b/sys/uvm/uvm_physseg.c     Thu Dec 22 08:15:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_physseg.c,v 1.1 2016/12/19 12:21:29 cherry Exp $ */
+/* $NetBSD: uvm_physseg.c,v 1.2 2016/12/22 08:15:20 cherry Exp $ */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -417,7 +417,7 @@
 uvm_physseg_get_next(uvm_physseg_t upm)
 {
        /* next of invalid is invalid, not fatal */
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return UVM_PHYSSEG_TYPE_INVALID;
 
        return (uvm_physseg_t) rb_tree_iterate(&(uvm_physseg_graph.rb_tree), upm,
@@ -428,7 +428,7 @@
 uvm_physseg_get_prev(uvm_physseg_t upm)
 {
        /* prev of invalid is invalid, not fatal */
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return UVM_PHYSSEG_TYPE_INVALID;
 
        return (uvm_physseg_t) rb_tree_iterate(&(uvm_physseg_graph.rb_tree), upm,
@@ -603,7 +603,7 @@
 uvm_physseg_get_next(uvm_physseg_t lcv)
 {
        /* next of invalid is invalid, not fatal */
-       if (uvm_physseg_valid(lcv) == false)
+       if (uvm_physseg_valid_p(lcv) == false)
                return UVM_PHYSSEG_TYPE_INVALID;
 
        return (lcv + 1);
@@ -613,7 +613,7 @@
 uvm_physseg_get_prev(uvm_physseg_t lcv)
 {
        /* prev of invalid is invalid, not fatal */
-       if (uvm_physseg_valid(lcv) == false)
+       if (uvm_physseg_valid_p(lcv) == false)
                return UVM_PHYSSEG_TYPE_INVALID;
 
        return (lcv - 1);
@@ -778,7 +778,7 @@
        uvm_physseg_t upm;
        upm = uvm_physseg_find(pfn, &off);
 
-       if (uvm_physseg_valid(upm)) /* XXX; do we allow "update" plugs ? */
+       if (uvm_physseg_valid_p(upm)) /* XXX; do we allow "update" plugs ? */
                return false;
 #endif
 
@@ -972,7 +972,7 @@
 #endif /* UVM_HOTPLUG */
 
 bool
-uvm_physseg_valid(uvm_physseg_t upm)
+uvm_physseg_valid_p(uvm_physseg_t upm)
 {
        struct uvm_physseg *ps;
 
@@ -1007,7 +1007,7 @@
 paddr_t
 uvm_physseg_get_start(uvm_physseg_t upm)
 {
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return (paddr_t) -1;
 
        return HANDLE_TO_PHYSSEG_NODE(upm)->start;
@@ -1016,7 +1016,7 @@
 paddr_t
 uvm_physseg_get_end(uvm_physseg_t upm)
 {
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return (paddr_t) -1;
 
        return HANDLE_TO_PHYSSEG_NODE(upm)->end;
@@ -1025,7 +1025,7 @@
 paddr_t
 uvm_physseg_get_avail_start(uvm_physseg_t upm)
 {
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return (paddr_t) -1;
 
        return HANDLE_TO_PHYSSEG_NODE(upm)->avail_start;
@@ -1034,7 +1034,7 @@
 paddr_t
 uvm_physseg_get_avail_end(uvm_physseg_t upm)
 {
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return (paddr_t) -1;
 
        return HANDLE_TO_PHYSSEG_NODE(upm)->avail_end;
@@ -1043,7 +1043,7 @@
 struct vm_page *
 uvm_physseg_get_pg(uvm_physseg_t upm, paddr_t idx)
 {
-       KASSERT(uvm_physseg_valid(upm));
+       KASSERT(uvm_physseg_valid_p(upm));
        return &HANDLE_TO_PHYSSEG_NODE(upm)->pgs[idx];
 }
 
@@ -1051,7 +1051,7 @@
 struct pmap_physseg *
 uvm_physseg_get_pmseg(uvm_physseg_t upm)
 {
-       KASSERT(uvm_physseg_valid(upm));
+       KASSERT(uvm_physseg_valid_p(upm));
        return &(HANDLE_TO_PHYSSEG_NODE(upm)->pmseg);
 }
 #endif
@@ -1059,21 +1059,21 @@
 int
 uvm_physseg_get_free_list(uvm_physseg_t upm)
 {
-       KASSERT(uvm_physseg_valid(upm));
+       KASSERT(uvm_physseg_valid_p(upm));
        return HANDLE_TO_PHYSSEG_NODE(upm)->free_list;
 }
 
 u_int
 uvm_physseg_get_start_hint(uvm_physseg_t upm)
 {
-       KASSERT(uvm_physseg_valid(upm));
+       KASSERT(uvm_physseg_valid_p(upm));
        return HANDLE_TO_PHYSSEG_NODE(upm)->start_hint;
 }
 
 bool
 uvm_physseg_set_start_hint(uvm_physseg_t upm, u_int start_hint)
 {
-       if (uvm_physseg_valid(upm) == false)
+       if (uvm_physseg_valid_p(upm) == false)
                return false;
 
        HANDLE_TO_PHYSSEG_NODE(upm)->start_hint = start_hint;
@@ -1227,7 +1227,7 @@
 
        upm = uvm_physseg_find(pfn, &off);
 
-       if (!uvm_physseg_valid(upm)) {
+       if (!uvm_physseg_valid_p(upm)) {
                printf("%s: Tried to unplug from unknown offset\n", __func__);
                return false;
        }
diff -r f73286251395 -r eebb4bd92295 sys/uvm/uvm_physseg.h
--- a/sys/uvm/uvm_physseg.h     Thu Dec 22 07:56:38 2016 +0000
+++ b/sys/uvm/uvm_physseg.h     Thu Dec 22 08:15:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uvm_physseg.h,v 1.1 2016/12/19 12:21:29 cherry Exp $ */
+/* $NetBSD: uvm_physseg.h,v 1.2 2016/12/22 08:15:20 cherry Exp $ */
 
 /*
  * Consolidated API from uvm_page.c and others.
@@ -25,7 +25,7 @@
 
 /*
  * These are specific values of invalid constants for uvm_physseg_t.
- * uvm_physseg_valid() == false on any of the below constants.
+ * uvm_physseg_valid_p() == false on any of the below constants.
  *
  * Specific invalid constants encapsulate specific explicit failure
  * scenarios (see the comments next to them)
@@ -43,7 +43,7 @@
 
 /*
  * These are specific values of invalid constants for uvm_physseg_t.
- * uvm_physseg_valid() == false on any of the below constants.
+ * uvm_physseg_valid_p() == false on any of the below constants.
  *
  * Specific invalid constants encapsulate specific explicit failure
  * scenarios (see the comments next to them)
@@ -58,7 +58,7 @@
 
 void uvm_physseg_init(void);
 
-bool uvm_physseg_valid(uvm_physseg_t);
+bool uvm_physseg_valid_p(uvm_physseg_t);
 
 /*
  * Return start/end pfn of given segment
diff -r f73286251395 -r eebb4bd92295 tests/sys/uvm/t_uvm_physseg.c
--- a/tests/sys/uvm/t_uvm_physseg.c     Thu Dec 22 07:56:38 2016 +0000
+++ b/tests/sys/uvm/t_uvm_physseg.c     Thu Dec 22 08:15:20 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_uvm_physseg.c,v 1.1 2016/12/19 12:21:29 cherry Exp $ */
+/* $NetBSD: t_uvm_physseg.c,v 1.2 2016/12/22 08:15:20 cherry Exp $ */
 
 /*-
  * Copyright (c) 2015, 2016 The NetBSD Foundation, Inc.
@@ -31,7 +31,28 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_uvm_physseg.c,v 1.1 2016/12/19 12:21:29 cherry Exp $");
+__RCSID("$NetBSD: t_uvm_physseg.c,v 1.2 2016/12/22 08:15:20 cherry Exp $");
+
+/*
+ * If this line is commented out tests related to uvm_physseg_get_pmseg()
+ * wont run.
+ *
+ * Have a look at machine/uvm_physseg.h for more details.
+ */
+#define __HAVE_PMAP_PHYSSEG
+
+/*
+ * This is a dummy struct used for testing purposes
+ *
+ * In reality this struct would exist in the MD part of the code residing in
+ * machines/vmparam.h
+ */
+
+#ifdef __HAVE_PMAP_PHYSSEG
+struct pmap_physseg {
+       int dummy_variable;             /* Dummy variable use for testing */
+};
+#endif
 
 /* Testing API - assumes userland */
 /* Provide Kernel API equivalents */
@@ -60,31 +81,9 @@
 typedef unsigned long psize_t;
 typedef unsigned long vsize_t;
 
+#include <uvm/uvm_physseg.h>
 #include <uvm/uvm_page.h>
 
-/*
- * If this line is commented out tests related to uvm_physseg_get_pmseg()
- * wont run.
- *
- * Have a look at machine/uvm_physseg.h for more details.
- */
-#define __HAVE_PMAP_PHYSSEG
-
-#include <uvm/uvm_physseg.h>
-
-/*
- * This is a dummy struct used for testing purposes
- *
- * In reality this struct would exist in the MD part of the code residing in
- * machines/vmparam.h
- */
-
-#ifdef __HAVE_PMAP_PHYSSEG
-struct pmap_physseg {
-       bool dummy_variable;            /* Dummy variable use for testing */
-};
-#endif
-
 #ifndef DIAGNOSTIC
 #define        KASSERTMSG(e, msg, ...) /* NOTHING */
 #define        KASSERT(e)              /* NOTHING */
@@ -434,7 +433,7 @@
 
        for (bank = uvm_physseg_get_first(),
                 uvm_physseg_seg_chomp_slab(bank, pagearray, pagecount);
-            uvm_physseg_valid(bank);
+            uvm_physseg_valid_p(bank);
             bank = uvm_physseg_get_next(bank)) {
 
                n = uvm_physseg_get_end(bank) - uvm_physseg_get_start(bank);
@@ -584,13 +583,13 @@
 
        upm = uvm_physseg_find(atop(TWOFIFTYSIX_KILO + FIVEONETWO_KILO), NULL);
 
-       ATF_REQUIRE(uvm_physseg_valid(upm));
+       ATF_REQUIRE(uvm_physseg_valid_p(upm));
 
        /* Now unplug the tail fragment - should swallow the complete entry */
        ATF_REQUIRE_EQ(true, uvm_physseg_unplug(atop(TWOFIFTYSIX_KILO + FIVEONETWO_KILO), atop(TWOFIFTYSIX_KILO)));
 
        /* The "swallow" above should have invalidated the handle */
-       ATF_REQUIRE_EQ(false, uvm_physseg_valid(upm));
+       ATF_REQUIRE_EQ(false, uvm_physseg_valid_p(upm));
 
        /* Only the first one is left now */
        ATF_REQUIRE_EQ(1, uvm_physseg_get_entries());
@@ -643,7 +642,7 @@
            VALID_AVAIL_START_PFN_1, VALID_AVAIL_END_PFN_1, VM_FREELIST_DEFAULT);
 
        /* Should return a valid handle */
-       ATF_REQUIRE(uvm_physseg_valid(upm));
+       ATF_REQUIRE(uvm_physseg_valid_p(upm));
 
        /* No pages should be allocated yet */
        ATF_REQUIRE_EQ(0, uvmexp.npages);
@@ -657,7 +656,7 @@
            VALID_AVAIL_START_PFN_2, VALID_AVAIL_END_PFN_2, VM_FREELIST_DEFAULT);
 
        /* Should return a valid handle */
-       ATF_REQUIRE(uvm_physseg_valid(upm));
+       ATF_REQUIRE(uvm_physseg_valid_p(upm));
 



Home | Main Index | Thread Index | Old Index