configure: Disable (clang) initializer-overrides warnings
[qemu/pbrook.git] / range.h
blob350237212b6b982d9032106bbad85495dc052745
1 #ifndef QEMU_RANGE_H
2 #define QEMU_RANGE_H
4 /* Get last byte of a range from offset + length.
5 * Undefined for ranges that wrap around 0. */
6 static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
8 return offset + len - 1;
11 /* Check whether a given range covers a given byte. */
12 static inline int range_covers_byte(uint64_t offset, uint64_t len,
13 uint64_t byte)
15 return offset <= byte && byte <= range_get_last(offset, len);
18 /* Check whether 2 given ranges overlap.
19 * Undefined if ranges that wrap around 0. */
20 static inline int ranges_overlap(uint64_t first1, uint64_t len1,
21 uint64_t first2, uint64_t len2)
23 uint64_t last1 = range_get_last(first1, len1);
24 uint64_t last2 = range_get_last(first2, len2);
26 return !(last2 < first1 || last1 < first2);
29 #endif