Remove redundant ';' at the end of line.
[wine] / include / debugtools.h
1
2 #ifndef __WINE_DEBUGTOOLS_H
3 #define __WINE_DEBUGTOOLS_H
4
5 #ifdef __WINE__  /* Debugging interface is internal to Wine */
6
7 #include <stdarg.h>
8 #include "config.h"
9 #include "windef.h"
10
11 struct _GUID;
12
13 /* Internal definitions (do not use these directly) */
14
15 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
16
17 #ifndef NO_TRACE_MSGS
18 # define __GET_DEBUGGING_TRACE(dbch) ((dbch)[0] & (1 << __DBCL_TRACE))
19 #else
20 # define __GET_DEBUGGING_TRACE(dbch) 0
21 #endif
22
23 #ifndef NO_DEBUG_MSGS
24 # define __GET_DEBUGGING_WARN(dbch)  ((dbch)[0] & (1 << __DBCL_WARN))
25 # define __GET_DEBUGGING_FIXME(dbch) ((dbch)[0] & (1 << __DBCL_FIXME))
26 #else
27 # define __GET_DEBUGGING_WARN(dbch)  0
28 # define __GET_DEBUGGING_FIXME(dbch) 0
29 #endif
30
31 /* define error macro regardless of what is configured */
32 #define __GET_DEBUGGING_ERR(dbch)  ((dbch)[0] & (1 << __DBCL_ERR))
33
34 #define __GET_DEBUGGING(dbcl,dbch)  __GET_DEBUGGING##dbcl(dbch)
35 #define __SET_DEBUGGING(dbcl,dbch,on) \
36     ((on) ? ((dbch)[0] |= 1 << (dbcl)) : ((dbch)[0] &= ~(1 << (dbcl))))
37
38 #ifdef __GNUC__
39
40 #define __DPRINTF(dbcl,dbch) \
41   do { if(__GET_DEBUGGING(dbcl,(dbch))) { \
42        const char * const __dbch = (dbch); \
43        const enum __DEBUG_CLASS __dbcl = __DBCL##dbcl; \
44        __WINE_DBG_LOG
45
46 #define __WINE_DBG_LOG(args...) \
47     wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0)
48
49 #define __PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
50
51 #else  /* __GNUC__ */
52
53 #define __DPRINTF(dbcl,dbch) \
54     (!__GET_DEBUGGING(dbcl,(dbch)) || \
55      (wine_dbg_log(__DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__),0)) ? \
56      (void)0 : (void)wine_dbg_printf
57
58 #define __PRINTF_ATTR(fmt, args)
59
60 #endif  /* __GNUC__ */
61
62 /* Exported definitions and macros */
63
64 /* These function return a printable version of a string, including
65    quotes.  The string will be valid for some time, but not indefinitely
66    as strings are re-used.  */
67 extern const char *wine_dbgstr_an( const char * s, int n );
68 extern const char *wine_dbgstr_wn( const WCHAR *s, int n );
69 extern const char *wine_dbgstr_guid( const struct _GUID *id );
70
71 extern int wine_dbg_vprintf( const char *format, va_list args ) __PRINTF_ATTR(1,0);
72 extern int wine_dbg_printf( const char *format, ... ) __PRINTF_ATTR(1,2);
73 extern int wine_dbg_log( enum __DEBUG_CLASS cls, const char *ch,
74                          const char *func, const char *format, ... ) __PRINTF_ATTR(4,5);
75
76 inline static const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
77 inline static const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); }
78 inline static const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); }
79 inline static const char *debugstr_a( const char *s )  { return wine_dbgstr_an( s, 80 ); }
80 inline static const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, 80 ); }
81 inline static const char *debugres_a( const char *s )  { return wine_dbgstr_an( s, 80 ); }
82 inline static const char *debugres_w( const WCHAR *s ) { return wine_dbgstr_wn( s, 80 ); }
83
84 #define TRACE        __DPRINTF(_TRACE,__wine_dbch___default)
85 #define TRACE_(ch)   __DPRINTF(_TRACE,__wine_dbch_##ch)
86 #define TRACE_ON(ch) __GET_DEBUGGING(_TRACE,__wine_dbch_##ch)
87
88 #define WARN         __DPRINTF(_WARN,__wine_dbch___default)
89 #define WARN_(ch)    __DPRINTF(_WARN,__wine_dbch_##ch)
90 #define WARN_ON(ch)  __GET_DEBUGGING(_WARN,__wine_dbch_##ch)
91
92 #define FIXME        __DPRINTF(_FIXME,__wine_dbch___default)
93 #define FIXME_(ch)   __DPRINTF(_FIXME,__wine_dbch_##ch)
94 #define FIXME_ON(ch) __GET_DEBUGGING(_FIXME,__wine_dbch_##ch)
95
96 #undef ERR  /* Solaris got an 'ERR' define in <sys/reg.h> */
97 #define ERR          __DPRINTF(_ERR,__wine_dbch___default)
98 #define ERR_(ch)     __DPRINTF(_ERR,__wine_dbch_##ch)
99 #define ERR_ON(ch)   __GET_DEBUGGING(_ERR,__wine_dbch_##ch)
100
101 #define DECLARE_DEBUG_CHANNEL(ch) \
102     extern char __wine_dbch_##ch[]
103 #define DEFAULT_DEBUG_CHANNEL(ch) \
104     extern char __wine_dbch_##ch[]; static char * const __wine_dbch___default = __wine_dbch_##ch
105
106 #define DPRINTF wine_dbg_printf
107 #define MESSAGE wine_dbg_printf
108
109 #endif  /* __WINE__ */
110
111 #endif  /* __WINE_DEBUGTOOLS_H */