blob: b1f49aa8b756d0518c978c4034ed6d3eb20d3378 [file] [log] [blame]
Timo Teräsdafa05e2017-01-19 17:27:01 +02001#include "log.h"
2
3#if defined(__GNUC__) && (__GNUC__ >= 3)
4#define likely(_x) __builtin_expect(!!(_x), 1)
5#define unlikely(_x) __builtin_expect(!!(_x), 0)
6#else
7#define likely(_x) !!(_x)
8#define unlikely(_x) !!(_x)
9#endif
10
11#define NHRP_DEBUG_COMMON (1 << 0)
12#define NHRP_DEBUG_KERNEL (1 << 1)
13#define NHRP_DEBUG_IF (1 << 2)
14#define NHRP_DEBUG_ROUTE (1 << 3)
15#define NHRP_DEBUG_VICI (1 << 4)
16#define NHRP_DEBUG_EVENT (1 << 5)
17#define NHRP_DEBUG_ALL (0xFFFF)
18
19extern unsigned int debug_flags;
20
21#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
22
23#define debugf(level, ...) \
24 do { \
25 if (unlikely(debug_flags & level)) \
26 zlog_debug(__VA_ARGS__); \
27 } while(0)
28
29#elif defined __GNUC__
30
31#define debugf(level, _args...) \
32 do { \
33 if (unlikely(debug_flags & level)) \
34 zlog_debug(_args); \
35 } while(0)
36
37#else
38
39static inline void debugf(int level, const char *format, ...) { }
40
41#endif
42