From 192a12fb6ab0b4a2033f087cec8a232d42a4c000 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Wed, 6 May 2020 10:52:55 +0200 Subject: commonlib/region: Add region_overlap Add inline function to check if two regions overlap. Change-Id: I6f3dfaa9f0805893bd691ba64f112944d89a8e71 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/41083 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Angel Pons --- src/commonlib/include/commonlib/region.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/commonlib/include/commonlib/region.h b/src/commonlib/include/commonlib/region.h index 86b9ee39cc..08b9191a66 100644 --- a/src/commonlib/include/commonlib/region.h +++ b/src/commonlib/include/commonlib/region.h @@ -7,6 +7,7 @@ #include #include #include +#include #include /* @@ -117,6 +118,12 @@ static inline size_t region_end(const struct region *r) return region_offset(r) + region_sz(r); } +static inline bool region_overlap(const struct region *r1, const struct region *r2) +{ + return (region_end(r1) > region_offset(r2)) && + (region_offset(r1) < region_end(r2)); +} + static inline const struct region *region_device_region( const struct region_device *rdev) { -- cgit v1.2.3