]> Git Repo - J-linux.git/blob - include/linux/range.h
Merge tag 'riscv-for-linus-6.13-mw1' of git://git.kernel.org/pub/scm/linux/kernel...
[J-linux.git] / include / linux / range.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_RANGE_H
3 #define _LINUX_RANGE_H
4 #include <linux/types.h>
5
6 struct range {
7         u64   start;
8         u64   end;
9 };
10
11 static inline u64 range_len(const struct range *range)
12 {
13         return range->end - range->start + 1;
14 }
15
16 /* True if r1 completely contains r2 */
17 static inline bool range_contains(const struct range *r1,
18                                   const struct range *r2)
19 {
20         return r1->start <= r2->start && r1->end >= r2->end;
21 }
22
23 /* True if any part of r1 overlaps r2 */
24 static inline bool range_overlaps(const struct range *r1,
25                                   const struct range *r2)
26 {
27         return r1->start <= r2->end && r1->end >= r2->start;
28 }
29
30 int add_range(struct range *range, int az, int nr_range,
31                 u64 start, u64 end);
32
33
34 int add_range_with_merge(struct range *range, int az, int nr_range,
35                                 u64 start, u64 end);
36
37 void subtract_range(struct range *range, int az, u64 start, u64 end);
38
39 int clean_sort_range(struct range *range, int az);
40
41 void sort_range(struct range *range, int nr_range);
42
43 #define DEFINE_RANGE(_start, _end)              \
44 (struct range) {                                \
45                 .start = (_start),              \
46                 .end = (_end),                  \
47         }
48
49 #endif
This page took 0.029834 seconds and 4 git commands to generate.