Initial import of OsmocomBB into git repository
[osmocom-bb.git] / src / target / firmware / include / debug.h
1 #ifndef _DEBUG_H
2 #define _DEBUG_H
3
4 #ifndef ARRAY_SIZE
5 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
6 #endif
7
8 /*
9  * Check at compile time that something is of a particular type.
10  * Always evaluates to 1 so you may use it easily in comparisons.
11  */
12 #define typecheck(type,x) \
13 ({      type __dummy; \
14         typeof(x) __dummy2; \
15         (void)(&__dummy == &__dummy2); \
16         1; \
17 })
18
19 #ifdef DEBUG
20 #define dputchar(x) putchar(x)
21 #define dputs(x) puts(x)
22 #define dphex(x,y) phex(x,y)
23 #define printd(x, args ...) printf(x, ## args)
24 #else
25 #define dputchar(x)
26 #define dputs(x)
27 #define dphex(x,y)
28 #define printd(x, args ...)
29 #endif
30
31 #endif /* _DEBUG_H */