summaryrefslogtreecommitdiffstats
path: root/worker/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'worker/util.h')
-rw-r--r--worker/util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/worker/util.h b/worker/util.h
new file mode 100644
index 0000000..503702a
--- /dev/null
+++ b/worker/util.h
@@ -0,0 +1,23 @@
+#ifndef __WORKER_UTIL_H__
+#define __WORKER_UTIL_H__
+
+extern int debug_level;
+void debug_fn(const char *format, ...);
+
+#define DEBUG(level, body) do { \
+ if (level <= debug_level) { \
+ debug_fn("DEBUG-%d (%s,%d): %s: ", level, __FILE__, __LINE__ , __FUNCTION__); \
+ debug_fn body; \
+ } \
+} while(0);
+
+
+#define CHECK_NULL_FATAL(pointer, message) do { \
+ if (pointer == NULL) { \
+ DEBUG(0, message) \
+ exit(1); \
+ } \
+} while(0);
+
+#endif /* __WORKER_UTIL_H__ */
+