]> git.sesse.net Git - vlc/blob - loader/wine/debugtools.h
Mac OS X gui: Revert r19259. We are not ready to do proper locking.
[vlc] / loader / wine / 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)) || (dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
44      (void)0 : (void)dbg_printf
45
46 /* Exported definitions and macros */
47
48 /* These function return a printable version of a string, including
49    quotes.  The string will be valid for some time, but not indefinitely
50    as strings are re-used.  */
51 extern LPCSTR debugstr_an (LPCSTR s, int n);
52 extern LPCSTR debugstr_wn (LPCWSTR s, int n);
53 extern LPCSTR debugres_a (LPCSTR res);
54 extern LPCSTR debugres_w (LPCWSTR res);
55 extern LPCSTR debugstr_guid( const struct _GUID *id );
56 extern LPCSTR debugstr_hex_dump (const void *ptr, int len);
57 extern int dbg_header_err( const char *dbg_channel, const char *func );
58 extern int dbg_header_warn( const char *dbg_channel, const char *func );
59 extern int dbg_header_fixme( const char *dbg_channel, const char *func );
60 extern int dbg_header_trace( const char *dbg_channel, const char *func );
61 extern int dbg_vprintf( const char *format, va_list args );
62
63 static inline LPCSTR debugstr_a( LPCSTR s )  { return debugstr_an( s, 80 ); }
64 static inline LPCSTR debugstr_w( LPCWSTR s ) { return debugstr_wn( s, 80 ); }
65
66 #ifdef __GNUC__
67 extern int dbg_printf(const char *format, ...) __attribute__((format (printf,1,2)));
68 #else
69 extern int dbg_printf(const char *format, ...);
70 #endif
71
72 #define TRACE_(X) TRACE
73 #define WARN_(X) TRACE
74 #define WARN TRACE
75 #define ERR_(X) printf
76 #define ERR printf
77 #define FIXME_(X) TRACE
78 #define FIXME TRACE
79
80 #define TRACE_ON(X) 1
81 #define ERR_ON(X) 1
82
83 #define DECLARE_DEBUG_CHANNEL(ch) \
84     extern char dbch_##ch[];
85 #define DEFAULT_DEBUG_CHANNEL(ch) \
86     extern char dbch_##ch[]; static char * const __dbch_default = dbch_##ch;
87
88 #define DPRINTF dbg_printf
89 #define MESSAGE dbg_printf
90
91 #endif  /* __WINE__ */
92
93 #endif  /* __WINE_DEBUGTOOLS_H */