1 /* SPDX-License-Identifier: GPL-2.0 */
4 #include <linux/types.h>
11 static inline u64
range_len(const struct range
*range
)
13 return range
->end
- range
->start
+ 1;
16 /* True if r1 completely contains r2 */
17 static inline bool range_contains(const struct range
*r1
,
18 const struct range
*r2
)
20 return r1
->start
<= r2
->start
&& r1
->end
>= r2
->end
;
23 /* True if any part of r1 overlaps r2 */
24 static inline bool range_overlaps(const struct range
*r1
,
25 const struct range
*r2
)
27 return r1
->start
<= r2
->end
&& r1
->end
>= r2
->start
;
30 int add_range(struct range
*range
, int az
, int nr_range
,
34 int add_range_with_merge(struct range
*range
, int az
, int nr_range
,
37 void subtract_range(struct range
*range
, int az
, u64 start
, u64 end
);
39 int clean_sort_range(struct range
*range
, int az
);
41 void sort_range(struct range
*range
, int nr_range
);
43 #define DEFINE_RANGE(_start, _end) \