aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/macros.h21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/common/macros.h b/src/common/macros.h
index 6daf08f..3735af6 100644
--- a/src/common/macros.h
+++ b/src/common/macros.h
@@ -9,19 +9,14 @@
#define streq(x, y) (!strcmp(x, y))
#define u8eq(x, y) (!u8cmp(x, y))
-#if DEBUG || !defined(unreachable)
-# if DEBUG
-# include "cerr.h"
-# ifdef unreachable
-# undef unreachable
-# endif
-# define unreachable() \
- diex("%s:%d: hit unreachable in %s()", __FILE__, __LINE__, __func__)
-# elifdef __clang__
-# define unreachable() __builtin_unreachable()
-# else
-# include <stddef.h>
-# endif
+#if DEBUG
+# include "cerr.h"
+# define assume(C) \
+ ((C) ? (void)0 \
+ : diex("%s:%d: %s(): assumption ā€˜%sā€™ failed", __FILE__, __LINE__, \
+ __func__, #C))
+#else
+# define assume(C) ((C) ? (void)0 : unreachable())
#endif
#endif /* !AHOY_COMMON_MACROS_H */