diff options
author | Andreas Kling <kling@serenityos.org> | 2022-07-08 14:16:53 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-07-09 22:15:43 +0200 |
commit | 2217d91b8d7c5086fad76396d5b50e13d67aae65 (patch) | |
tree | 35c82fd2438a311a5e39272be80895b31f307006 | |
parent | dab814ea115e2de9eb9928c6e66416a796e2dd70 (diff) | |
download | serenity-2217d91b8d7c5086fad76396d5b50e13d67aae65.zip |
AK: Make VERIFY() work in MinSizeRel builds
-rw-r--r-- | AK/Assertions.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/AK/Assertions.h b/AK/Assertions.h index 55e7c989da..648d9b9d49 100644 --- a/AK/Assertions.h +++ b/AK/Assertions.h @@ -10,8 +10,15 @@ # include <Kernel/Assertions.h> #else # include <assert.h> -# define VERIFY assert -# define VERIFY_NOT_REACHED() assert(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */ +# ifndef NDEBUG +# define VERIFY assert +# else +# define VERIFY(expr) \ + (__builtin_expect(!(expr), 0) \ + ? __builtin_trap() \ + : (void)0) +# endif +# define VERIFY_NOT_REACHED() VERIFY(false) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */ static constexpr bool TODO = false; # define TODO() VERIFY(TODO) /* NOLINT(cert-dcl03-c,misc-static-assert) No, this can't be static_assert, it's a runtime check */ #endif |