more documentation
[c11tester.git] / common.h
1 #ifndef __COMMON_H__
2 #define __COMMON_H__
3
4 #include <stdio.h>
5
6 /*
7 #ifndef CONFIG_DEBUG
8 #define CONFIG_DEBUG
9 #endif
10 */
11
12 #ifdef CONFIG_DEBUG
13 #define DEBUG(fmt, ...) do { printf("*** %25s(): line %-4d *** " fmt, __func__, __LINE__, ##__VA_ARGS__); } while (0)
14 #define DBG() DEBUG("\n");
15 #define DBG_ENABLED() (1)
16 #else
17 #define DEBUG(fmt, ...)
18 #define DBG()
19 #define DBG_ENABLED() (0)
20 #endif
21
22 #define ASSERT(expr) \
23 do { \
24         if (!(expr)) { \
25                 fprintf(stderr, "Error: assertion failed in %s at line %d\n", __FILE__, __LINE__); \
26                 exit(EXIT_FAILURE); \
27         } \
28 } while (0);
29
30 #endif /* __COMMON_H__ */