diff options
author | Jakob Kaivo <jkk@ung.org> | 2024-01-31 12:23:45 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2024-01-31 12:23:45 -0500 |
commit | b65a54684571b5eaecc8ff8321171033ce937e0c (patch) | |
tree | ccf637128ec8ac13401891e24ba7c804fa639df9 /src/_safety.h | |
parent | 06c23d59875d0f7cd4b81ce6192c7fc9c4722231 (diff) |
implement ASSERT_NOOVERLAP()
Diffstat (limited to 'src/_safety.h')
-rw-r--r-- | src/_safety.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/_safety.h b/src/_safety.h index 1e11187a..3a1d8fd5 100644 --- a/src/_safety.h +++ b/src/_safety.h @@ -39,7 +39,14 @@ extern struct __checked_call { } while (0) #define ASSERT_NOOVERLAP(__p1, __l1, __p2, __l2) do { \ - /* TODO */ (void)(__p1); (void)(__l1); (void)(__p2); (void)(__l2); \ + char *__s1 = (char*)(__p1); \ + char *__s2 = (char*)(__p2); \ + if (((__s1 < __s2) && ((__s1 + (__l1)) >= __s2)) || ((__s1 > __s2) && ((__s2 + (__l2)) >= __s1))) { \ + struct __constraint_info _ci = {0}; \ + _ci.func = __func__; \ + __stdlib.constraint_handler("Undefined behavior: " \ + "Parameter " #__p1 " and " #__p2 " overlap", &_ci, 0); \ + } \ } while (0) #define ASSERT_REPRESENTABLE(_n, _min, _max, _type, _sentinel) do { \ |