Use free Windows DDK and compile with latest MinGW releases.
[reactos.git] / reactos / ntoskrnl / include / internal / debug.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: include/internal/debug.h
5 * PURPOSE: Useful debugging macros
6 * PROGRAMMER: David Welch (welch@mcmail.com)
7 * UPDATE HISTORY:
8 * 28/05/98: Created
9 */
10
11 /*
12 * NOTES: Define DBG in configuration file for "checked" version
13 * Define NDEBUG before including this header to disable debugging
14 * macros
15 * Define NASSERT before including this header to disable assertions
16 */
17
18 #ifndef __INTERNAL_DEBUG
19 #define __INTERNAL_DEBUG
20
21 #undef assert
22
23 #include <internal/ntoskrnl.h>
24 #include <internal/dbg.h>
25 #include <roscfg.h>
26
27 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
28
29
30 #ifdef DBG
31
32 /* Assert only on "checked" version */
33 #ifndef NASSERT
34 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
35
36 #define assertmsg(_c_, _m_) \
37 if (!(_c_)) { \
38 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
39 DbgPrint _m_ ; \
40 KeBugCheck(0); \
41 }
42
43 #else
44
45 #define assert(x)
46 #define assertmsg(_c_, _m_)
47
48 #endif
49
50 /* Print if using a "checked" version */
51 #define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
52
53 #else /* DBG */
54
55 #define CPRINT(args...)
56 #define assert(x)
57 #define assertmsg(_c_, _m_)
58
59 #endif /* DBG */
60
61 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
62 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
63
64 #if defined(KDBG) && defined(NDEBUG) && defined(__NTOSKRNL__)
65
66 #define DPRINT(args...) do { \
67 if (DbgShouldPrint(__FILE__)) { \
68 DbgPrint("(%s:%d) ",__FILE__,__LINE__); \
69 DbgPrint(args); \
70 } \
71 } while(0);
72
73 #define CHECKPOINT
74
75 #else /* KDBG && NDEBUG && __NTOSKRNL__ */
76
77 #ifndef NDEBUG
78 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
79 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
80 #else /* NDEBUG */
81 #define DPRINT(args...)
82 #define CHECKPOINT
83 #endif /* NDEBUG */
84
85 #endif /* KDBG && NDEBUG */
86
87 /*
88 * FUNCTION: Assert a maximum value for the current irql
89 * ARGUMENTS:
90 * x = Maximum irql
91 */
92 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
93 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
94
95 #endif /* __INTERNAL_DEBUG */