bootloader_util.h 772 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdbool.h>
  8. #include <stdint.h>
  9. #include <assert.h>
  10. #ifdef __cplusplus
  11. extern "C" {
  12. #endif
  13. /**
  14. * @brief Check if half-open intervals overlap
  15. *
  16. * @param start1 interval 1 start
  17. * @param end1 interval 1 end
  18. * @param start2 interval 2 start
  19. * @param end2 interval 2 end
  20. * @return true iff [start1; end1) overlaps [start2; end2)
  21. */
  22. static inline bool bootloader_util_regions_overlap(
  23. const intptr_t start1, const intptr_t end1,
  24. const intptr_t start2, const intptr_t end2)
  25. {
  26. assert(end1 > start1);
  27. assert(end2 > start2);
  28. return (end1 > start2 && end2 > start1);
  29. }
  30. #ifdef __cplusplus
  31. }
  32. #endif