From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=56921 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Okjo5-0003xf-0q for qemu-devel@nongnu.org; Sun, 15 Aug 2010 16:27:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Okiui-0005tU-Rw for qemu-devel@nongnu.org; Sun, 15 Aug 2010 15:30:38 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:60780) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Okiui-0005t6-Ma for qemu-devel@nongnu.org; Sun, 15 Aug 2010 15:30:36 -0400 Received: by mail-fx0-f45.google.com with SMTP id 7so2796452fxm.4 for ; Sun, 15 Aug 2010 12:30:36 -0700 (PDT) Sender: Eduard - Gabriel Munteanu From: Eduard - Gabriel Munteanu Date: Sun, 15 Aug 2010 22:27:16 +0300 Message-Id: <1281900442-29971-2-git-send-email-eduard.munteanu@linux360.ro> In-Reply-To: <1281900442-29971-1-git-send-email-eduard.munteanu@linux360.ro> References: <1281900442-29971-1-git-send-email-eduard.munteanu@linux360.ro> Subject: [Qemu-devel] [PATCH 1/7] pci: add range_covers_range() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: joro@8bytes.org Cc: kvm@vger.kernel.org, qemu-devel@nongnu.org, blauwirbel@gmail.com, paul@codesourcery.com, Eduard - Gabriel Munteanu , avi@redhat.com This helper function allows map invalidation code to determine which maps must be invalidated. Signed-off-by: Eduard - Gabriel Munteanu --- hw/pci.h | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-) diff --git a/hw/pci.h b/hw/pci.h index 4bd8a1a..5a6cdb5 100644 --- a/hw/pci.h +++ b/hw/pci.h @@ -419,6 +419,16 @@ static inline int range_covers_byte(uint64_t offset, uint64_t len, return offset <= byte && byte <= range_get_last(offset, len); } +/* Check whether a given range completely covers another. */ +static inline int range_covers_range(uint64_t first_big, uint64_t len_big, + uint64_t first_small, uint64_t len_small) +{ + uint64_t last_big = range_get_last(first_big, len_big); + uint64_t last_small = range_get_last(first_small, len_small); + + return first_big <= first_small && last_small <= last_big; +} + /* Check whether 2 given ranges overlap. * Undefined if ranges that wrap around 0. */ static inline int ranges_overlap(uint64_t first1, uint64_t len1, -- 1.7.1