From: "Jan Beulich" Subject: [PATCH] rangesets: add function to query for overlaps Date: Mon, 20 Sep 2010 14:07:55 +0100 Message-ID: <4C9778CB0200007800017B6A@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part547982BB.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part547982BB.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This will be used by a subsequent patch. Signed-off-by: Jan Beulich --- 2010-06-15.orig/xen/common/rangeset.c 2009-11-05 10:13:22.0000000= 00 +0100 +++ 2010-06-15/xen/common/rangeset.c 2010-07-12 12:08:16.000000000 = +0200 @@ -251,6 +251,22 @@ int rangeset_contains_range( return contains; } =20 +int rangeset_overlaps_range( + struct rangeset *r, unsigned long s, unsigned long e) +{ + struct range *x; + int overlaps; + + ASSERT(s <=3D e); + + spin_lock(&r->lock); + x =3D find_range(r, e); + overlaps =3D (x && (s <=3D x->e)); + spin_unlock(&r->lock); + + return overlaps; +} + int rangeset_report_ranges( struct rangeset *r, unsigned long s, unsigned long e, int (*cb)(unsigned long s, unsigned long e, void *), void *ctxt) --- 2010-06-15.orig/xen/include/xen/rangeset.h 2009-11-05 10:13:22.0000000= 00 +0100 +++ 2010-06-15/xen/include/xen/rangeset.h 2010-07-12 12:09:55.0000000= 00 +0200 @@ -53,6 +53,8 @@ int __must_check rangeset_remove_range( struct rangeset *r, unsigned long s, unsigned long e); int __must_check rangeset_contains_range( struct rangeset *r, unsigned long s, unsigned long e); +int __must_check rangeset_overlaps_range( + struct rangeset *r, unsigned long s, unsigned long e); int rangeset_report_ranges( struct rangeset *r, unsigned long s, unsigned long e, int (*cb)(unsigned long s, unsigned long e, void *), void *ctxt); --=__Part547982BB.0__= Content-Type: text/plain; name="rangeset-overlaps.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="rangeset-overlaps.patch" This will be used by a subsequent patch.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- 2010-06-15.orig/xen/common/rangeset.c = 2009-11-05 10:13:22.000000000 +0100=0A+++ 2010-06-15/xen/common/rangeset.c = 2010-07-12 12:08:16.000000000 +0200=0A@@ -251,6 +251,22 @@ int rangeset_con= tains_range(=0A return contains;=0A }=0A =0A+int rangeset_overlaps_rang= e(=0A+ struct rangeset *r, unsigned long s, unsigned long e)=0A+{=0A+ = struct range *x;=0A+ int overlaps;=0A+=0A+ ASSERT(s <=3D e);=0A+=0A+= spin_lock(&r->lock);=0A+ x =3D find_range(r, e);=0A+ overlaps = =3D (x && (s <=3D x->e));=0A+ spin_unlock(&r->lock);=0A+=0A+ return = overlaps;=0A+}=0A+=0A int rangeset_report_ranges(=0A struct rangeset = *r, unsigned long s, unsigned long e,=0A int (*cb)(unsigned long s, = unsigned long e, void *), void *ctxt)=0A--- 2010-06-15.orig/xen/include/xen= /rangeset.h 2009-11-05 10:13:22.000000000 +0100=0A+++ 2010-06-15/xen/in= clude/xen/rangeset.h 2010-07-12 12:09:55.000000000 +0200=0A@@ -53,6 = +53,8 @@ int __must_check rangeset_remove_range(=0A struct rangeset = *r, unsigned long s, unsigned long e);=0A int __must_check rangeset_contain= s_range(=0A struct rangeset *r, unsigned long s, unsigned long = e);=0A+int __must_check rangeset_overlaps_range(=0A+ struct rangeset = *r, unsigned long s, unsigned long e);=0A int rangeset_report_ranges(=0A = struct rangeset *r, unsigned long s, unsigned long e,=0A int = (*cb)(unsigned long s, unsigned long e, void *), void *ctxt);=0A --=__Part547982BB.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part547982BB.0__=--