summaryrefslogtreecommitdiffstats
path: root/macro.h
diff options
context:
space:
mode:
Diffstat (limited to 'macro.h')
-rw-r--r--macro.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/macro.h b/macro.h
index 847bf97..ed80654 100644
--- a/macro.h
+++ b/macro.h
@@ -26,10 +26,33 @@
} \
} while(0)
+#define sa_return_if_fail_mutex(m, expr) \
+ do { \
+ if (!(expr)) { \
+ fprintf(stderr, "%s: Assertion <%s> failed.\n", PRETTY_FUNCTION, #expr ); \
+ sa_mutex_unlock(m); \
+ return; \
+ } \
+ } while(0)
+
+#define sa_return_val_if_fail_mutex(m, expr, val) \
+ do { \
+ if (!(expr)) { \
+ fprintf(stderr, "%s: Assertion <%s> failed.\n", PRETTY_FUNCTION, #expr ); \
+ sa_mutex_unlock(m); \
+ return (val); \
+ } \
+ } while(0)
+
#define sa_assert assert
#define sa_assert_not_reached() sa_assert(!"Should not be reached.")
+#define sa_assert_success(x) do { \
+ int _r = (x); \
+ sa_assert(_r == 0); \
+ } while(0)
+
#define elementsof(x) (sizeof(x)/sizeof((x)[0]))
#ifndef MAX