Annotation of qemu/range.h, revision 1.1.1.1

1.1       root        1: #ifndef QEMU_RANGE_H
                      2: #define QEMU_RANGE_H
                      3: 
                      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)
                      7: {
                      8:     return offset + len - 1;
                      9: }
                     10: 
                     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)
                     14: {
                     15:     return offset <= byte && byte <= range_get_last(offset, len);
                     16: }
                     17: 
                     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)
                     22: {
                     23:     uint64_t last1 = range_get_last(first1, len1);
                     24:     uint64_t last2 = range_get_last(first2, len2);
                     25: 
                     26:     return !(last2 < first1 || last1 < first2);
                     27: }
                     28: 
                     29: #endif

unix.superglobalmegacorp.com