WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Extend the range abstraction by adding an internal

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Extend the range abstraction by adding an internal
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Dec 2005 19:42:07 +0000
Delivery-date: Thu, 29 Dec 2005 19:46:45 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 65430a8f80d74823be5b96e1383a4eb5e33c137b
# Parent  4937d9f496abc4962ac6597dc0bf48b2aef8a0f7
Extend the range abstraction by adding an internal
insert_range() helper function. Pretty printer uses
the internal abstractions rather than accessing the
linked list directly.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 4937d9f496ab -r 65430a8f80d7 xen/common/rangeset.c
--- a/xen/common/rangeset.c     Thu Dec 29 17:16:01 2005
+++ b/xen/common/rangeset.c     Thu Dec 29 17:39:50 2005
@@ -32,6 +32,10 @@
     unsigned int     flags;
 };
 
+/*****************************
+ * Private range functions hide the underlying linked-list implemnetation.
+ */
+
 /* Find highest range lower than or containing s. NULL if no such range. */
 static struct range *find_range(
     struct rangeset *r, unsigned long s)
@@ -66,6 +70,13 @@
     return list_entry(x->list.next, struct range, list);
 }
 
+/* Insert range y after range x in r. Insert as first range if x is NULL. */
+static void insert_range(
+    struct rangeset *r, struct range *x, struct range *y)
+{
+    list_add(&y->list, (x != NULL) ? &x->list : &r->range_list);
+}
+
 /* Remove a range from its list and free it. */
 static void destroy_range(
     struct range *x)
@@ -73,6 +84,10 @@
     list_del(&x->list);
     xfree(x);
 }
+
+/*****************************
+ * Core public functions
+ */
 
 int rangeset_add_range(
     struct rangeset *r, unsigned long s, unsigned long e)
@@ -99,10 +114,9 @@
             x->s = s;
             x->e = e;
 
-            list_add(&x->list, (y != NULL) ? &y->list : &r->range_list);
-        }
-        
-        if ( x->e < e )
+            insert_range(r, y, x);
+        }
+        else if ( x->e < e )
             x->e = e;
     }
     else
@@ -165,10 +179,12 @@
                 rc = -ENOMEM;
                 goto out;
             }
+
             y->s = e + 1;
             y->e = x->e;
             x->e = s - 1;
-            list_add(&y->list, &x->list);
+
+            insert_range(r, x, y);
         }
         else if ( (x->s == s) && (x->e <= e) )
             destroy_range(x);
@@ -317,6 +333,10 @@
     }
 }
 
+/*****************************
+ * Pretty-printing functions
+ */
+
 static void print_limit(struct rangeset *r, unsigned long s)
 {
     printk((r->flags & RANGESETF_prettyprint_hex) ? "%lx" : "%lu", s);
@@ -332,7 +352,7 @@
 
     printk("%10s {", r->name);
 
-    list_for_each_entry ( x, &r->range_list, list )
+    for ( x = first_range(r); x != NULL; x = next_range(r, x) )
     {
         if ( nr_printed++ )
             printk(",");

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Extend the range abstraction by adding an internal, Xen patchbot -unstable <=