|
|
9ae3a8 |
From 5b9d5a4f0e351dc73b31507b56334f7ef692f20c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <5b9d5a4f0e351dc73b31507b56334f7ef692f20c.1387298827.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
From: "Michael S. Tsirkin" <mst@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 17 Dec 2013 15:16:55 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 03/56] range: add min/max operations on ranges
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1387293161-4085-4-git-send-email-mst@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56308
|
|
|
9ae3a8 |
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 03/57] range: add min/max operations on ranges
|
|
|
9ae3a8 |
Bugzilla: 1034876
|
|
|
9ae3a8 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit c5a22c4344f17169bb20e122e9d935c62aedc063)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/qemu/range.h | 18 ++++++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 18 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/qemu/range.h | 18 ++++++++++++++++++
|
|
|
9ae3a8 |
1 file changed, 18 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/include/qemu/range.h b/include/qemu/range.h
|
|
|
9ae3a8 |
index 4a0780d..aae9720 100644
|
|
|
9ae3a8 |
--- a/include/qemu/range.h
|
|
|
9ae3a8 |
+++ b/include/qemu/range.h
|
|
|
9ae3a8 |
@@ -17,6 +17,24 @@ struct Range {
|
|
|
9ae3a8 |
uint64_t end; /* 1 + the last byte. 0 if range empty or ends at ~0x0LL. */
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+static inline void range_extend(Range *range, Range *extend_by)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ if (!extend_by->begin && !extend_by->end) {
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (!range->begin && !range->end) {
|
|
|
9ae3a8 |
+ *range = *extend_by;
|
|
|
9ae3a8 |
+ return;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ if (range->begin > extend_by->begin) {
|
|
|
9ae3a8 |
+ range->begin = extend_by->begin;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+ /* Compare last byte in case region ends at ~0x0LL */
|
|
|
9ae3a8 |
+ if (range->end - 1 < extend_by->end - 1) {
|
|
|
9ae3a8 |
+ range->end = extend_by->end;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
/* Get last byte of a range from offset + length.
|
|
|
9ae3a8 |
* Undefined for ranges that wrap around 0. */
|
|
|
9ae3a8 |
static inline uint64_t range_get_last(uint64_t offset, uint64_t len)
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.11.7
|
|
|
9ae3a8 |
|