diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-03 15:28:22 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2012-10-05 18:39:24 +0200 |
commit | 60d2fe688ec1c466c32f7193c19258a521549366 (patch) | |
tree | 198f033c9dbeec15afc7c178f838b160feed5bad /include/common.h | |
parent | 1fcc223e9f844bc7606840effd1d5b7405785df5 (diff) | |
download | barebox-60d2fe688ec1c466c32f7193c19258a521549366.tar.gz barebox-60d2fe688ec1c466c32f7193c19258a521549366.tar.xz |
introduce region_overlap() function
To check if two regions overlap
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/common.h')
-rw-r--r-- | include/common.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h index c1f44b402c..e30774a43e 100644 --- a/include/common.h +++ b/include/common.h @@ -256,4 +256,17 @@ static inline void barebox_banner(void) {} (__x < 0) ? -__x : __x; \ }) +/* + * Check if two regions overlap. returns true if they do, false otherwise + */ +static inline bool region_overlap(unsigned long starta, unsigned long lena, + unsigned long startb, unsigned long lenb) +{ + if (starta + lena <= startb) + return 0; + if (startb + lenb <= starta) + return 0; + return 1; +} + #endif /* __COMMON_H_ */ |