summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/macros.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index 08e7aeb72..1a76ef60a 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -33,6 +33,14 @@
#define likely(x) (x)
#define unlikely(x) (x)
#endif
+
+// Asserts that the result of expr is true
+#define must_succeed(expr) ({ \
+ auto result = (expr); \
+ if (unlikely(not result)) \
+ fprintf(stderr, "%s:%d: %s: Assertion `%s` failed.\n", __FILE__, __LINE__, __FUNCTION__, #expr), abort(); \
+ result; \
+})
#endif
#if APT_GCC_VERSION >= 0x0300