Added networking code from Casper Hornstrup
[reactos.git] / reactos / drivers / net / tcpip / include / debug.h
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS TCP/IP protocol driver
4 * FILE: include/debug.h
5 * PURPOSE: Debugging support macros
6 * DEFINES: DBG - Enable debug output
7 * NASSERT - Disable assertions
8 */
9 #ifndef __DEBUG_H
10 #define __DEBUG_H
11
12 #define NORMAL_MASK 0x000000FF
13 #define SPECIAL_MASK 0xFFFFFF00
14 #define MIN_TRACE 0x00000001
15 #define MID_TRACE 0x00000002
16 #define MAX_TRACE 0x00000003
17
18 #define DEBUG_MEMORY 0x00000100
19 #define DEBUG_BUFFER 0x00000200
20 #define DEBUG_IRP 0x00000400
21 #define DEBUG_REFCOUNT 0x00000800
22 #define DEBUG_ADDRFILE 0x00001000
23 #define DEBUG_IP 0x00002000
24 #define DEBUG_ROUTER 0x00004000
25 #define DEBUG_RCACHE 0x00008000
26 #define DEBUG_NCACHE 0x00010000
27 #define DEBUG_ULTRA 0xFFFFFFFF
28
29 #ifdef DBG
30
31 extern DWORD DebugTraceLevel;
32
33 #ifdef _MSC_VER
34
35 #define TI_DbgPrint(_t_, _x_) \
36 if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
37 ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
38 DbgPrint("(%s:%d) ", __FILE__, __LINE__); \
39 DbgPrint _x_ ; \
40 }
41
42 #else /* _MSC_VER */
43
44 #define TI_DbgPrint(_t_, _x_) \
45 if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
46 ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
47 DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \
48 DbgPrint _x_ ; \
49 }
50
51 #endif /* _MSC_VER */
52
53 #ifdef ASSERT
54 #undef ASSERT
55 #endif
56
57 #ifdef NASSERT
58 #define ASSERT(x)
59 #else /* NASSERT */
60 #define ASSERT(x) if (!(x)) { TI_DbgPrint(MIN_TRACE, ("Assertion "#x" failed at %s:%d\n", __FILE__, __LINE__)); KeBugCheck(0); }
61 #endif /* NASSERT */
62
63 #define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
64
65 #else /* DBG */
66
67 #define TI_DbgPrint(_t_, _x_)
68
69 #define ASSERT_IRQL(x)
70 #define ASSERT(x)
71
72 #endif /* DBG */
73
74
75 #define assert(x) ASSERT(x)
76 #define assert_irql(x) ASSERT_IRQL(x)
77
78
79 #ifdef _MSC_VER
80
81 #define UNIMPLEMENTED \
82 TI_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \
83 but come back another day.\n", __FILE__, __LINE__));
84
85 #else /* _MSC_VER */
86
87 #define UNIMPLEMENTED \
88 TI_DbgPrint(MIN_TRACE, ("(%s:%d)(%s) is unimplemented, \
89 but come back another day.\n", __FILE__, __LINE__, __FUNCTION__));
90
91 #endif /* _MSC_VER */
92
93
94 #define CHECKPOINT \
95 do { TI_DbgPrint(MIN_TRACE, ("(%s:%d)\n", __FILE__, __LINE__)); } while(0);
96
97 #endif /* __DEBUG_H */
98
99 /* EOF */