Preparations for checked/free like builds (CPRINT == DbgPrint when DBG is defined).
[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 #include <internal/ntoskrnl.h>
22 #include <internal/config.h>
23
24 #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
25
26 /* FIXME: should probably remove this later */
27 #if !defined(CHECKED) && !defined(NDEBUG)
28 #define CHECKED
29 #endif
30
31 #ifdef DBG
32
33 /* Assert only on "checked" version */
34 #ifndef NASSERT
35 #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); }
36 #else
37 #define assert(x)
38 #endif
39
40 /* Print if using a "checked" version */
41 #define CPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
42
43 #else /* DBG */
44
45 #define CPRINT(args...)
46 #define assert(x)
47
48 #endif /* DBG */
49
50 #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0);
51 #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0);
52
53 extern unsigned int old_idt[256][2];
54 //extern unsigned int idt;
55 extern unsigned int old_idt_valid;
56
57 #ifdef __NTOSKRNL__
58 //#define DPRINT_CHECKS ExAllocatePool(NonPagedPool,0); assert(old_idt_valid || (!memcmp(old_idt,KiIdt,256*2)));
59 //#define DPRINT_CHECKS ExAllocatePool(NonPagedPool,0);
60 #define DPRINT_CHECKS
61 #else
62 #define DPRINT_CHECKS
63 #endif
64
65 #ifndef NDEBUG
66 #define OLD_DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
67 #define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); DPRINT_CHECKS } while(0);
68 #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
69 #else
70 //#define DPRINT(args...) do { DPRINT_CHECKS } while (0);
71 #define DPRINT(args...)
72 #define OLD_DPRINT(args...)
73 #define CHECKPOINT
74 #endif /* NDEBUG */
75
76 /*
77 * FUNCTION: Assert a maximum value for the current irql
78 * ARGUMENTS:
79 * x = Maximum irql
80 */
81 #define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x))
82 #define assert_irql(x) assert(KeGetCurrentIrql()<=(x))
83
84 #endif /* __INTERNAL_DEBUG */