From 72aae9d8ca8b4b7eabb4e18dfe05e9aa89516ba1 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Fri, 22 Oct 2004 20:02:32 +0000 Subject: [PATCH] Define ASSERT and ASSERTMSG macros. svn path=/trunk/; revision=11385 --- reactos/include/debug.h | 17 ++++++++++++++ reactos/ntoskrnl/include/internal/debug.h | 28 +++++++++++++++-------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/reactos/include/debug.h b/reactos/include/debug.h index 45f7fe9e382..47a1f1513e9 100644 --- a/reactos/include/debug.h +++ b/reactos/include/debug.h @@ -32,6 +32,23 @@ #endif #endif +#ifndef ASSERT +#ifndef NASSERT +#define ASSERT(x) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, ""); } +#else +#define ASSERT(x) +#endif +#endif + +#ifndef ASSERTMSG +#ifndef NASSERT +#define ASSERTMSG(x,m) if (!(x)) {RtlAssert("#x",__FILE__,__LINE__, m); } +#else +#define ASSERTMSG(x) +#endif +#endif + + /* TODO: Make the output of file/line and the debug message atomic */ #define DPRINT1 DbgPrint("(%s:%d) ",__FILE__,__LINE__), DbgPrint #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0); diff --git a/reactos/ntoskrnl/include/internal/debug.h b/reactos/ntoskrnl/include/internal/debug.h index 41df21f0b56..541169f0f66 100644 --- a/reactos/ntoskrnl/include/internal/debug.h +++ b/reactos/ntoskrnl/include/internal/debug.h @@ -28,14 +28,17 @@ #endif #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0) + +#ifdef assert +#undef assert +#endif + #ifdef DBG /* Assert only on "checked" version */ #ifndef NASSERT -#ifdef assert -#undef assert -#endif #define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); } +#define ASSERT(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); KeBugCheck(0); } #define assertmsg(_c_, _m_) \ if (!(_c_)) { \ @@ -44,13 +47,19 @@ KeBugCheck(0); \ } +#define ASSERTMSG(_c_, _m_) \ + if (!(_c_)) { \ + DbgPrint("(%s:%d)(%s) ", __FILE__, __LINE__, __FUNCTION__); \ + DbgPrint _m_ ; \ + KeBugCheck(0); \ + } + #else -#ifdef assert -#undef assert -#endif #define assert(x) +#define ASSERT(x) #define assertmsg(_c_, _m_) +#define ASSERTMSG(_c_, _m_) #endif @@ -64,11 +73,10 @@ #else /* DBG */ #define CPRINT(args...) -#ifdef assert -#undef assert -#endif #define assert(x) +#define ASSERT(x) #define assertmsg(_c_, _m_) +#define ASSERTMSG(_c_, _m_) #endif /* DBG */ @@ -116,7 +124,7 @@ * ARGUMENTS: * x = Maximum irql */ -#define ASSERT_IRQL(x) assert(KeGetCurrentIrql()<=(x)) +#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql()<=(x)) #define assert_irql(x) assert(KeGetCurrentIrql()<=(x)) #endif /* __INTERNAL_DEBUG */