range: Make range_compare() public

Let's expose range_compare() in the header so that it can be
reused outside of util/range.c

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
This commit is contained in:
Eric Auger 2023-10-19 15:45:11 +02:00 committed by Cédric Le Goater
parent 41cc70cdf5
commit 43f04cbeff
2 changed files with 7 additions and 5 deletions

View File

@ -217,6 +217,12 @@ static inline int ranges_overlap(uint64_t first1, uint64_t len1,
return !(last2 < first1 || last1 < first2); return !(last2 < first1 || last1 < first2);
} }
/*
* Return -1 if @a < @b, 1 @a > @b, and 0 if they touch or overlap.
* Both @a and @b must not be empty.
*/
int range_compare(Range *a, Range *b);
GList *range_list_insert(GList *list, Range *data); GList *range_list_insert(GList *list, Range *data);
#endif #endif

View File

@ -20,11 +20,7 @@
#include "qemu/osdep.h" #include "qemu/osdep.h"
#include "qemu/range.h" #include "qemu/range.h"
/* int range_compare(Range *a, Range *b)
* Return -1 if @a < @b, 1 @a > @b, and 0 if they touch or overlap.
* Both @a and @b must not be empty.
*/
static inline int range_compare(Range *a, Range *b)
{ {
assert(!range_is_empty(a) && !range_is_empty(b)); assert(!range_is_empty(a) && !range_is_empty(b));