bootloader_util.h 735 B

1234567891011121314151617181920212223242526272829303132333435
  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 <stddef.h>
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. /**
  12. * @brief Check if half-open intervals overlap
  13. *
  14. * @param start1 interval 1 start
  15. * @param end1 interval 1 end
  16. * @param start2 interval 2 start
  17. * @param end2 interval 2 end
  18. * @return true iff [start1; end1) overlaps [start2; end2)
  19. */
  20. static inline bool bootloader_util_regions_overlap(
  21. const intptr_t start1, const intptr_t end1,
  22. const intptr_t start2, const intptr_t end2)
  23. {
  24. assert(end1>start1);
  25. assert(end2>start2);
  26. return (end1 > start2 && end2 > start1);
  27. }
  28. #ifdef __cplusplus
  29. }
  30. #endif