io_u: 'is_random' can be a boolean
[fio.git] / debug.h
1 #ifndef FIO_DEBUG_H
2 #define FIO_DEBUG_H
3
4 #include <assert.h>
5 #include "lib/types.h"
6 #include "log.h"
7
8 enum {
9         FD_PROCESS      = 0,
10         FD_FILE,
11         FD_IO,
12         FD_MEM,
13         FD_BLKTRACE,
14         FD_VERIFY,
15         FD_RANDOM,
16         FD_PARSE,
17         FD_DISKUTIL,
18         FD_JOB,
19         FD_MUTEX,
20         FD_PROFILE,
21         FD_TIME,
22         FD_NET,
23         FD_RATE,
24         FD_COMPRESS,
25         FD_STEADYSTATE,
26         FD_HELPERTHREAD,
27         FD_DEBUG_MAX,
28 };
29
30 extern unsigned int fio_debug_jobno, *fio_debug_jobp, *fio_warned;
31
32 static inline bool fio_did_warn(unsigned int mask)
33 {
34         if (*fio_warned & mask)
35                 return true;
36
37         *fio_warned |= mask;
38         return false;
39 }
40
41 enum {
42         FIO_WARN_ROOT_FLUSH     = 1,
43         FIO_WARN_VERIFY_BUF     = 2,
44         FIO_WARN_ZONED_BUG      = 4,
45         FIO_WARN_IOLOG_DROP     = 8,
46         FIO_WARN_FADVISE        = 16,
47 };
48
49 #ifdef FIO_INC_DEBUG
50 struct debug_level {
51         const char *name;
52         const char *help;
53         unsigned long shift;
54         unsigned int jobno;
55 };
56 extern struct debug_level debug_levels[];
57
58 extern unsigned long fio_debug;
59
60 void __dprint(int type, const char *str, ...) __attribute__((format (printf, 2, 3)));
61
62 #define dprint(type, str, args...)                      \
63         do {                                            \
64                 if ((((1 << type)) & fio_debug) == 0)   \
65                         break;                          \
66                 __dprint((type), (str), ##args);        \
67         } while (0)                                     \
68
69 #else
70
71 static inline void dprint(int type, const char *str, ...)
72 {
73 }
74 #endif
75
76 #endif