Jan Beulich
2010-Sep-20 13:07 UTC
[Xen-devel] [PATCH] rangesets: add function to query for overlaps
This will be used by a subsequent patch. Signed-off-by: Jan Beulich <jbeulich@novell.com> --- 2010-06-15.orig/xen/common/rangeset.c 2009-11-05 10:13:22.000000000 +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; } +int rangeset_overlaps_range( + struct rangeset *r, unsigned long s, unsigned long e) +{ + struct range *x; + int overlaps; + + ASSERT(s <= e); + + spin_lock(&r->lock); + x = find_range(r, e); + overlaps = (x && (s <= 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.000000000 +0100 +++ 2010-06-15/xen/include/xen/rangeset.h 2010-07-12 12:09:55.000000000 +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); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel