- reorganized DInput DLL
[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 #ifndef __GNUC__
39 #define __FUNCTION__ ""
40 #endif
41
42 #define __DPRINTF(dbcl,dbch) \
43   (!__GET_DEBUGGING(dbcl,(dbch)) || (__wine_dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
44      (void)0 : (void)wine_dbg_printf
45
46 extern int __wine_dbg_header_err( const char *dbg_channel, const char *func );
47 extern int __wine_dbg_header_warn( const char *dbg_channel, const char *func );
48 extern int __wine_dbg_header_fixme( const char *dbg_channel, const char *func );
49 extern int __wine_dbg_header_trace( const char *dbg_channel, const char *func );
50
51 /* Exported definitions and macros */
52
53 /* These function return a printable version of a string, including
54    quotes.  The string will be valid for some time, but not indefinitely
55    as strings are re-used.  */
56 extern const char *debugstr_an (const char * s, int n);
57 extern const char *debugstr_wn (const WCHAR *s, int n);
58 extern const char *debugstr_guid( const struct _GUID *id );
59
60 extern int wine_dbg_vprintf( const char *format, va_list args );
61
62 inline static const char *debugstr_a( const char *s )  { return debugstr_an( s, 80 ); }
63 inline static const char *debugstr_w( const WCHAR *s ) { return debugstr_wn( s, 80 ); }
64 inline static const char *debugres_a( const char *s )  { return debugstr_an( s, 80 ); }
65 inline static const char *debugres_w( const WCHAR *s ) { return debugstr_wn( s, 80 ); }
66
67 #ifdef __GNUC__
68 extern int wine_dbg_printf(const char *format, ...) __attribute__((format (printf,1,2)));
69 #else
70 extern int wine_dbg_printf(const char *format, ...);
71 #endif
72
73 #define TRACE        __DPRINTF(trace,__wine_dbch___default)
74 #define TRACE_(ch)   __DPRINTF(trace,__wine_dbch_##ch)
75 #define TRACE_ON(ch) __GET_DEBUGGING(trace,__wine_dbch_##ch)
76
77 #define WARN         __DPRINTF(warn,__wine_dbch___default)
78 #define WARN_(ch)    __DPRINTF(warn,__wine_dbch_##ch)
79 #define WARN_ON(ch)  __GET_DEBUGGING(warn,__wine_dbch_##ch)
80
81 #define FIXME        __DPRINTF(fixme,__wine_dbch___default)
82 #define FIXME_(ch)   __DPRINTF(fixme,__wine_dbch_##ch)
83 #define FIXME_ON(ch) __GET_DEBUGGING(fixme,__wine_dbch_##ch)
84
85 #undef ERR  /* Solaris got an 'ERR' define in <sys/reg.h> */
86 #define ERR          __DPRINTF(err,__wine_dbch___default)
87 #define ERR_(ch)     __DPRINTF(err,__wine_dbch_##ch)
88 #define ERR_ON(ch)   __GET_DEBUGGING(err,__wine_dbch_##ch)
89
90 #define DECLARE_DEBUG_CHANNEL(ch) \
91     extern char __wine_dbch_##ch[];
92 #define DEFAULT_DEBUG_CHANNEL(ch) \
93     extern char __wine_dbch_##ch[]; static char * const __wine_dbch___default = __wine_dbch_##ch;
94
95 #define DPRINTF wine_dbg_printf
96 #define MESSAGE wine_dbg_printf
97
98 #endif  /* __WINE__ */
99
100 #endif  /* __WINE_DEBUGTOOLS_H */