Relay code for Win16 register functions converts arguments.
[wine/wine64.git] / include / debugtools.h
blobbc0428b3a5dc0e7f0946e5867c835e96fc2f88c2
2 #ifndef __WINE_DEBUGTOOLS_H
3 #define __WINE_DEBUGTOOLS_H
5 #ifdef __WINE__ /* Debugging interface is internal to Wine */
7 #include <stdio.h>
8 #include "config.h"
9 #include "debugstr.h"
11 #define DEBUG_RUNTIME
13 /* Internal definitions (do not use these directly) */
15 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
17 extern char __debug_msg_enabled[][__DBCL_COUNT];
19 extern const char * const debug_cl_name[__DBCL_COUNT];
20 extern const char * const debug_ch_name[];
22 #define __GET_DEBUGGING(dbcl,dbch) (__debug_msg_enabled[(dbch)][(dbcl)])
23 #define __SET_DEBUGGING(dbcl,dbch,on) (__debug_msg_enabled[(dbch)][(dbcl)] = (on))
25 #ifndef __GNUC__
26 #define __FUNCTION__ ""
27 #endif
29 #define __DPRINTF(dbcl,dbch) \
30 (!__GET_DEBUGGING(dbcl,dbch) || \
31 (dbg_printf("%s:%s:%s ", debug_cl_name[(dbcl)], debug_ch_name[(dbch)], __FUNCTION__),0)) \
32 ? 0 : dbg_printf
34 #define __DUMMY_DPRINTF 1 ? 0 : ((int (*)(char *, ...)) NULL)
37 /* Exported definitions and macros */
40 #define dbg_str(name) debug_str_##name
41 #define dbg_buf(name) debug_buf_##name
43 #define dbg_decl_str(name, size) \
44 char dbg_str(name)[size], *dbg_buf(name)=dbg_str(name)
46 #define dbg_reset_str(name) \
47 dbg_buf(name)=dbg_str(name)
49 #define dsprintf(name, format, args...) \
50 dbg_buf(name)+=sprintf(dbg_buf(name), format, ## args)
52 /* use configure to allow user to compile out debugging messages */
54 #ifndef NO_TRACE_MSGS
55 #define TRACE __DPRINTF(__DBCL_TRACE,*DBCH_DEFAULT)
56 #define TRACE_(ch) __DPRINTF(__DBCL_TRACE,dbch_##ch)
57 #define TRACE_ON(ch) __GET_DEBUGGING(__DBCL_TRACE,dbch_##ch)
58 #else
59 #define TRACE __DUMMY_DPRINTF
60 #define TRACE_(ch) __DUMMY_DPRINTF
61 #define TRACE_ON(ch) 0
62 #endif /* NO_TRACE_MSGS */
64 #ifndef NO_DEBUG_MSGS
65 #define WARN __DPRINTF(__DBCL_WARN,*DBCH_DEFAULT)
66 #define WARN_(ch) __DPRINTF(__DBCL_WARN,dbch_##ch)
67 #define WARN_ON(ch) __GET_DEBUGGING(__DBCL_WARN,dbch_##ch)
68 #define FIXME __DPRINTF(__DBCL_FIXME,*DBCH_DEFAULT)
69 #define FIXME_(ch) __DPRINTF(__DBCL_FIXME,dbch_##ch)
70 #define FIXME_ON(ch) __GET_DEBUGGING(__DBCL_FIXME,dbch_##ch)
71 #else
72 #define WARN __DUMMY_DPRINTF
73 #define WARN_(ch) __DUMMY_DPRINTF
74 #define WARN_ON(ch) 0
75 #define FIXME __DUMMY_DPRINTF
76 #define FIXME_(ch) __DUMMY_DPRINTF
77 #define FIXME_ON(ch) 0
78 #endif /* NO_DEBUG_MSGS */
80 /* define error macro regardless of what is configured */
81 /* Solaris got an 'ERR' define in <sys/reg.h> */
82 #undef ERR
83 #define ERR __DPRINTF(__DBCL_ERR,*DBCH_DEFAULT)
84 #define ERR_(ch) __DPRINTF(__DBCL_ERR,dbch_##ch)
85 #define ERR_ON(ch) __GET_DEBUGGING(__DBCL_ERR,dbch_##ch)
87 #define DECLARE_DEBUG_CHANNEL(ch) \
88 extern const int dbch_##ch;
89 #define DEFAULT_DEBUG_CHANNEL(ch) \
90 extern const int dbch_##ch; static const int *const DBCH_DEFAULT = &dbch_##ch;
92 #define DPRINTF dbg_printf
93 #define MESSAGE dbg_printf
95 #ifdef OLD_DEBUG_MACROS
96 /* transition macros */
97 #undef TRACE
98 #undef WARN
99 #undef FIXME
100 #undef ERR
101 #define TRACE(ch, fmt, args...) TRACE_(ch)(fmt, ## args)
102 #define WARN(ch, fmt, args...) WARN_(ch)(fmt, ## args)
103 #define FIXME(ch, fmt, args...) FIXME_(ch)(fmt, ## args)
104 #define ERR(ch, fmt, args...) ERR_(ch)(fmt, ## args)
105 #define MSG(format, args...) fprintf(stderr, format, ## args)
106 #define DUMP dbg_printf
107 #endif
109 #endif /* __WINE__ */
111 #endif /* __WINE_DEBUGTOOLS_H */