summaryrefslogtreecommitdiff
path: root/p11-kit/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'p11-kit/debug.h')
-rw-r--r--p11-kit/debug.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/p11-kit/debug.h b/p11-kit/debug.h
index 7fa9854..c6e26f5 100644
--- a/p11-kit/debug.h
+++ b/p11-kit/debug.h
@@ -53,6 +53,36 @@ void _p11_debug_message (int flag,
const char *format,
...) GNUC_PRINTF (2, 3);
+void _p11_debug_precond (const char *format,
+ ...) GNUC_PRINTF (1, 2);
+
+#define assert_not_reached() \
+ (assert (0 && "this code should not be reached"))
+
+#define return_val_if_fail(x, v) \
+ do { if (!(x)) { \
+ _p11_debug_precond ("p11-kit: '%s' not true at %s\n", #x, __func__); \
+ return v; \
+ } } while (0)
+
+#define return_if_fail(x) \
+ do { if (!(x)) { \
+ _p11_debug_precond ("p11-kit: '%s' not true at %s\n", #x, __func__); \
+ return; \
+ } } while (0)
+
+#define return_if_reached() \
+ do { \
+ _p11_debug_precond ("p11-kit: shouldn't be reached at %s\n", __func__); \
+ return; \
+ } while (0)
+
+#define return_val_if_reached(v) \
+ do { \
+ _p11_debug_precond ("p11-kit: shouldn't be reached at %s\n", __func__); \
+ return v; \
+ } while (0)
+
#endif /* DEBUG_H */
/* -----------------------------------------------------------------------------