Merge 15268:15329 from trunk
[reactos.git] / rosapps / mc / pc / trace_nt.h
1 /* trace_nt.h - Debugging routines
2
3 Written by Juan Grigera<grigera@isis.unlp.edu.ar>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 /* ------------------------------------------------------------------------------------------ *
21 TRACER FUNCTIONS
22 * ------------------------------------------------------------------------------------------ */
23
24 #ifdef HAVE_TRACE
25 /************************/
26 /* Debug version */
27 /************************/
28
29 /* Macros
30 ------
31 win32Trace(x) - Trace macro. Use double in parenthesis for x. Same args as printf.
32 win32ASSERT(x) - assert macro, but will not abort program and output sent to trace routine.
33 win32APICALL(x) - Use to enclose a Win32 system call that should return TRUE.
34 win32APICALL_HANDLE(h,api) - Use to enclose a Win32 system call that should return a handle.
35 */
36 #define win32Trace(x) if (__win32_tracing_enabled) _win32Trace x
37 #define win32ASSERT(x) if (!(x)) _win32DebugAssertionFailed (#x, __LINE__, __FILE__)
38 #define win32APICALL(x) if (!(x)) _win32DebugFailedWin32APICall (#x, __LINE__, __FILE__)
39 #define win32APICALL_HANDLE(h,api) h=api; if (h==INVALID_HANDLE_VALUE) _win32DebugFailedWin32APICall (#h" = "#api, __LINE__, __FILE__)
40
41 /* Prototypes */
42 void _win32Trace (const char *, ...);
43 void _win32DebugFailedWin32APICall (const char *name, int line, const char *file);
44 void _win32DebugAssertionFailed (const char *name, int line, const char *file);
45
46 void _win32SetTrace (int trace);
47 void _win32TraceOn (void);
48 void _win32TraceOff (void);
49
50 #define SetTrace _win32SetTrace
51 #define TraceOn _win32TraceOn
52 #define TraceOff _win32TraceOff
53
54 /* Global variables */
55 extern int __win32_tracing_enabled;
56
57 #else
58 /************************/
59 /* Non-debug version */
60 /************************/
61
62 /* Wipe-out these macros */
63 #define win32Trace(x)
64 #define win32ASSERT(x)
65 #define win32APICALL(x) x
66 #define win32APICALL_HANDLE(h,api) h=api;
67
68 /* Wipe-out these funcs */
69 #define SetTrace(x)
70 #define TraceOn()
71 #define TraceOff()
72 #endif