clear out the lower 2 bits of a pid before using it to calculate the hash as they...
[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 //#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 /* TODO: Make the output of file/line and the debug message atomic */
52 #ifdef DBG
53 #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint
54 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
55 #else
56 #ifdef __GNUC__
57 #define DPRINT1(args...)
58 #define CHECKPOINT1
59 #else
60 #define DPRINT1
61 #define CHECKPOINT1
62 #endif /* __GNUC__ */
63 #endif
64
65 #ifndef NDEBUG
66 #define DPRINT(...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
67 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
68 #else
69 #ifdef __GNUC__
70 #define DPRINT(args...)
71 #else
72 #define DPRINT
73 #endif /* __GNUC__ */
74 #define CHECKPOINT
75 #endif /* NDEBUG */
76
77 /*
78 * FUNCTION: Assert a maximum value for the current irql
79 * ARGUMENTS:
80 * x = Maximum irql
81 */
82 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
83 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
84
85 /* Macros expanding to the appropriate inline assembly to raise a breakpoint */
86 #if defined(_M_IX86)
87 #define ASM_BREAKPOINT "\nint $3\n"
88 #elif defined(_M_ALPHA)
89 #define ASM_BREAKPOINT "\ncall_pal bpt\n"
90 #elif defined(_M_MIPS)
91 #define ASM_BREAKPOINT "\nbreak\n"
92 #else
93 #error Unsupported architecture.
94 #endif
95
96 #ifndef KEBUGCHECK
97 #define KEBUGCHECK(a) DbgPrint("KeBugCheck (0x%X) at %s:%i\n", a, __FILE__,__LINE__), KeBugCheck(a)
98 #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)
99 #endif
100
101 #endif /* __INTERNAL_DEBUG */