SM & SMDLL definitions
[reactos.git] / reactos / include / 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 //#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
20 #define UNIMPLEMENTED DbgPrint("WARNING: %s at %s:%d is UNIMPLEMENTED!\n",__FUNCTION__,__FILE__,__LINE__);
21
22 /* FIXME: should probably remove this later */
23 #if !defined(CHECKED) && !defined(NDEBUG)
24 #define CHECKED
25 #endif
26
27 #ifndef assert
28 #ifndef NASSERT
29 #define assert(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
30 #else
31 #define assert(x)
32 #endif
33 #endif
34
35 #ifndef ASSERT
36 #ifndef NASSERT
37 #define ASSERT(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); }
38 #else
39 #define ASSERT(x)
40 #endif
41 #endif
42
43 #ifndef ASSERTMSG
44 #ifndef NASSERT
45 #define ASSERTMSG(x,m) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, m); }
46 #else
47 #define ASSERTMSG(x)
48 #endif
49 #endif
50
51
52 /* TODO: Make the output of file/line and the debug message atomic */
53 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
54 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
55
56
57 #ifndef NDEBUG
58 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
59 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
60 #else
61 #ifdef __GNUC__
62 #define DPRINT(args...)
63 #else
64 #define DPRINT
65 #endif /* __GNUC__ */
66 #define CHECKPOINT
67 #endif /* NDEBUG */
68
69 /*
70 * FUNCTION: Assert a maximum value for the current irql
71 * ARGUMENTS:
72 * x = Maximum irql
73 */
74 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
75 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
76
77 /* Macros expanding to the appropriate inline assembly to raise a breakpoint */
78 #if defined(_M_IX86)
79 #define ASM_BREAKPOINT "\nint $3\n"
80 #elif defined(_M_ALPHA)
81 #define ASM_BREAKPOINT "\ncall_pal bpt\n"
82 #elif defined(_M_MIPS)
83 #define ASM_BREAKPOINT "\nbreak\n"
84 #else
85 #error Unsupported architecture.
86 #endif
87
88 #endif /* __INTERNAL_DEBUG */