forked from jonpovey/flashtool
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.h
More file actions
62 lines (52 loc) · 1.59 KB
/
debug.h
File metadata and controls
62 lines (52 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef __DEBUG_H__
#define __DEBUG_H__
/*
* Debug fprintf / printk
*/
#undef PDEBUG
#ifdef _DEBUG
# define PDEBUG_ENABLE // BVRDE integration
#else
# define NDEBUG // disable assert()
#endif
#ifndef __KERNEL__
# include <assert.h>
#endif
//#ifndef PDEBUG_IDENTIFIER
//# define PDEBUG_IDENTIFIER
//#endif
// Ideally there would be a better way than this of getting round
// the warning on redefinition of PDEBUG_IDENTIFIER:
#ifdef PDEBUG_IDENTIFIER
# ifdef PDEBUG_ENABLE
# ifdef __KERNEL__ // kernel space message
# define PDEBUG(fmt, args...) printk(KERN_DEBUG "%s" fmt, PDEBUG_IDENTIFIER, ## args)
# else // userland
# include <stdio.h> // if not already included..
# define PDEBUG(fmt, args...) fprintf(stderr, "%s" fmt, PDEBUG_IDENTIFIER, ##args)
# endif
# else
# define PDEBUG(fmt, args...) // do not compile
# endif // PDEBUG_ENABLE
#else
# ifdef PDEBUG_ENABLE
# ifdef __KERNEL__ // kernel space message
# define PDEBUG(fmt, args...) printk(KERN_DEBUG fmt, ## args)
# else // userland
# include <stdio.h> // if not already included..
# define PDEBUG(fmt, args...) fprintf(stderr, fmt, ##args)
# endif
# else
# define PDEBUG(fmt, args...) // do not compile
# endif // PDEBUG_ENABLE
#endif // PDEBUG_IDENTIFIER
#define DBG(fmt, args...) PDEBUG("%s: " fmt, __func__, ##args)
#ifdef __KERNEL__
# define ERR(fmt, args...) printk(KERN_ERR "%s: " fmt, __func__, ##args)
#else
# include <stdio.h>
# define ERR(fmt, args...) fprintf(stderr, "%s: " fmt, __func__, ##args)
#endif
#undef NOPDEBUG
#define NOPDEBUG(fmt, args...) // NOP placeholder
#endif // __DEBUG_H__