1 // Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <stddef.h>
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 /**
24  * @brief Check if half-open intervals overlap
25  *
26  * @param start1  interval 1 start
27  * @param end1    interval 1 end
28  * @param start2  interval 2 start
29  * @param end2    interval 2 end
30  * @return true iff [start1; end1) overlaps [start2; end2)
31  */
bootloader_util_regions_overlap(const intptr_t start1,const intptr_t end1,const intptr_t start2,const intptr_t end2)32 static inline bool bootloader_util_regions_overlap(
33         const intptr_t start1, const intptr_t end1,
34         const intptr_t start2, const intptr_t end2)
35 {
36     assert(end1>start1);
37     assert(end2>start2);
38     return (end1 > start2 && end2 > start1);
39 }
40 
41 #ifdef __cplusplus
42 }
43 #endif
44