summaryrefslogtreecommitdiffstats
path: root/apps/osmocomBB/osmocomBB/include/debug.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/osmocomBB/osmocomBB/include/debug.h')
-rw-r--r--apps/osmocomBB/osmocomBB/include/debug.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/apps/osmocomBB/osmocomBB/include/debug.h b/apps/osmocomBB/osmocomBB/include/debug.h
new file mode 100644
index 0000000000..27c4185d79
--- /dev/null
+++ b/apps/osmocomBB/osmocomBB/include/debug.h
@@ -0,0 +1,31 @@
+#ifndef _DEBUG_H
+#define _DEBUG_H
+
+#ifndef ARRAY_SIZE
+#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
+#endif
+
+/*
+ * Check at compile time that something is of a particular type.
+ * Always evaluates to 1 so you may use it easily in comparisons.
+ */
+#define typecheck(type,x) \
+({ type __dummy; \
+ typeof(x) __dummy2; \
+ (void)(&__dummy == &__dummy2); \
+ 1; \
+})
+
+#ifdef DEBUG
+#define dputchar(x) putchar(x)
+#define dputs(x) puts(x)
+#define dphex(x,y) phex(x,y)
+#define printd(x, args ...) printf(x, ## args)
+#else
+#define dputchar(x)
+#define dputs(x)
+#define dphex(x,y)
+#define printd(x, args ...)
+#endif
+
+#endif /* _DEBUG_H */