fix a lot of compile problems with encode.c and cert.c (still not added to build)
[reactos.git] / reactos / include / reactos / 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 * NOTE: Define NDEBUG before including this header to disable debugging
13 * macros
14 */
15
16 #ifndef __INTERNAL_DEBUG
17 #define __INTERNAL_DEBUG
18
19 /* FIXME: should probably remove this later */
20 #if !defined(CHECKED) && !defined(NDEBUG)
21 #define CHECKED
22 #endif
23
24 #ifndef assert
25 #ifndef NASSERT
26 #define assert(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
27 #else
28 #define assert(x)
29 #endif
30 #endif
31
32 #ifndef ASSERT
33 #ifndef NASSERT
34 #define ASSERT(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
35 #else
36 #define ASSERT(x)
37 #endif
38 #endif
39
40 #ifndef ASSERTMSG
41 #ifndef NASSERT
42 #define ASSERTMSG(x,m) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, m); }
43 #else
44 #define ASSERTMSG(x)
45 #endif
46 #endif
47
48 /* Print stuff only on Debug Builds*/
49 #ifdef DBG
50
51 /* These are always printed */
52 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
53 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
54
55 /* These are printed only if NDEBUG is NOT defined */
56 #ifndef NDEBUG
57
58 #define DPRINT DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
59 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
60
61 #else
62 #ifdef __GNUC__
63 #define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
64 #endif
65 #define CHECKPOINT
66 #endif
67
68 #define UNIMPLEMENTED \
69 DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
70
71 #else
72
73 /* On non-debug builds, we never show these */
74 #define DPRINT1(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
75 #define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
76 #define CHECKPOINT1
77 #define CHECKPOINT
78 #define UNIMPLEMENTED
79 #endif
80
81 /*
82 * FUNCTION: Assert a maximum value for the current irql
83 * ARGUMENTS:
84 * x = Maximum irql
85 */
86 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
87 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
88
89 /* Macros expanding to the appropriate inline assembly to raise a breakpoint */
90 #if defined(_M_IX86)
91 #define ASM_BREAKPOINT "\nint $3\n"
92 #elif defined(_M_ALPHA)
93 #define ASM_BREAKPOINT "\ncall_pal bpt\n"
94 #elif defined(_M_MIPS)
95 #define ASM_BREAKPOINT "\nbreak\n"
96 #else
97 #error Unsupported architecture.
98 #endif
99
100 #ifndef KEBUGCHECK
101 #define KEBUGCHECK(a) DbgPrint("KeBugCheck (0x%X) at %s:%i\n", a, __FILE__,__LINE__), KeBugCheck(a)
102 #define KEBUGCHECKEX(a,b,c,d,e) DbgPrint("KeBugCheckEx (0x%X, 0x%X, 0x%X, 0x%X, 0x%X) at %s:%i\n", a, b, c, d, e, __FILE__,__LINE__), KeBugCheckEx(a,b,c,d,e)
103 #endif
104
105 #endif /* __INTERNAL_DEBUG */