bootloader_util.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #pragma once
  15. #include <stddef.h>
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19. /**
  20. * @brief Check if half-open intervals overlap
  21. *
  22. * @param start1 interval 1 start
  23. * @param end1 interval 1 end
  24. * @param start2 interval 2 start
  25. * @param end2 interval 2 end
  26. * @return true iff [start1; end1) overlaps [start2; end2)
  27. */
  28. static inline bool bootloader_util_regions_overlap(
  29. const intptr_t start1, const intptr_t end1,
  30. const intptr_t start2, const intptr_t end2)
  31. {
  32. assert(end1>start1);
  33. assert(end2>start2);
  34. return (end1 > start2 && end2 > start1);
  35. }
  36. #ifdef __cplusplus
  37. }
  38. #endif