- Fix problem with ASSERT & ASSERTMSG when compiled with g++
[reactos.git] / reactos / include / ddk / winddk.h
index 41a4dcc..620a8a1 100644 (file)
@@ -2433,6 +2433,34 @@ typedef struct _ARBITER_INTERFACE {
   ULONG  Flags;
 } ARBITER_INTERFACE, *PARBITER_INTERFACE;
 
+typedef enum _KPROFILE_SOURCE {
+  ProfileTime,
+  ProfileAlignmentFixup,
+  ProfileTotalIssues,
+  ProfilePipelineDry,
+  ProfileLoadInstructions,
+  ProfilePipelineFrozen,
+  ProfileBranchInstructions,
+  ProfileTotalNonissues,
+  ProfileDcacheMisses,
+  ProfileIcacheMisses,
+  ProfileCacheMisses,
+  ProfileBranchMispredictions,
+  ProfileStoreInstructions,
+  ProfileFpInstructions,
+  ProfileIntegerInstructions,
+  Profile2Issue,
+  Profile3Issue,
+  Profile4Issue,
+  ProfileSpecialInstructions,
+  ProfileTotalCycles,
+  ProfileIcacheIssues,
+  ProfileDcacheAccesses,
+  ProfileMemoryBarrierCycles,
+  ProfileLoadLinkedIssues,
+  ProfileMaximum
+} KPROFILE_SOURCE;
+
 typedef enum _HAL_QUERY_INFORMATION_CLASS {
   HalInstalledBusInformation,
   HalProfileSourceInformation,
@@ -2470,6 +2498,19 @@ typedef enum _HAL_SET_INFORMATION_CLASS {
   HalGenerateCmcInterrupt
 } HAL_SET_INFORMATION_CLASS, *PHAL_SET_INFORMATION_CLASS;
 
+typedef struct _HAL_PROFILE_SOURCE_INTERVAL
+{
+    KPROFILE_SOURCE Source;
+    ULONG_PTR Interval;
+} HAL_PROFILE_SOURCE_INTERVAL, *PHAL_PROFILE_SOURCE_INTERVAL;
+
+typedef struct _HAL_PROFILE_SOURCE_INFORMATION
+{
+    KPROFILE_SOURCE Source;
+    BOOLEAN Supported;
+    ULONG Interval;
+} HAL_PROFILE_SOURCE_INFORMATION, *PHAL_PROFILE_SOURCE_INFORMATION;
+
 typedef struct _MAP_REGISTER_ENTRY
 {
     PVOID MapRegister;
@@ -4269,34 +4310,6 @@ typedef VOID
 (DDKAPI *PKINTERRUPT_ROUTINE)(
   VOID);
 
-typedef enum _KPROFILE_SOURCE {
-  ProfileTime,
-  ProfileAlignmentFixup,
-  ProfileTotalIssues,
-  ProfilePipelineDry,
-  ProfileLoadInstructions,
-  ProfilePipelineFrozen,
-  ProfileBranchInstructions,
-  ProfileTotalNonissues,
-  ProfileDcacheMisses,
-  ProfileIcacheMisses,
-  ProfileCacheMisses,
-  ProfileBranchMispredictions,
-  ProfileStoreInstructions,
-  ProfileFpInstructions,
-  ProfileIntegerInstructions,
-  Profile2Issue,
-  Profile3Issue,
-  Profile4Issue,
-  ProfileSpecialInstructions,
-  ProfileTotalCycles,
-  ProfileIcacheIssues,
-  ProfileDcacheAccesses,
-  ProfileMemoryBarrierCycles,
-  ProfileLoadLinkedIssues,
-  ProfileMaximum
-} KPROFILE_SOURCE;
-
 typedef enum _CREATE_FILE_TYPE {
   CreateFileTypeNone,
   CreateFileTypeNamedPipe,
@@ -5674,6 +5687,14 @@ KefReleaseSpinLockFromDpcLevel(
     
 #elif defined(_M_ARM) // !defined (_X86_)
     
+    FORCEINLINE
+    VOID
+    KeInitializeSpinLock(IN PKSPIN_LOCK SpinLock)
+    {
+        /* Clear the lock */
+        *SpinLock = 0;
+    }
+    
     NTHALAPI
     KIRQL
     FASTCALL
@@ -5788,18 +5809,37 @@ KeAcquireSpinLockRaiseToDpc(
 #define ROUND_TO_PAGES(Size) \
   ((ULONG_PTR) (((ULONG_PTR) Size + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)))
 
+
+
+#if defined(_X86_) || defined(_AMD64_)
+
+//
+// x86 and x64 performs a 0x2C interrupt
+//
+#define DbgRaiseAssertionFailure __int2c
+
+#elif defined(_ARM_)
+
+//
+// TODO
+//
+
+#else
+#error Unsupported Architecture
+#endif
+
 #if DBG
 
 #define ASSERT(exp) \
   (VOID)((!(exp)) ? \
-    RtlAssert( #exp, __FILE__, __LINE__, NULL ), FALSE : TRUE)
+    RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, NULL ), FALSE : TRUE)
 
 #define ASSERTMSG(msg, exp) \
   (VOID)((!(exp)) ? \
-    RtlAssert( #exp, __FILE__, __LINE__, msg ), FALSE : TRUE)
+    RtlAssert( (PVOID)#exp, (PVOID)__FILE__, __LINE__, msg ), FALSE : TRUE)
 
 #define RTL_SOFT_ASSERT(exp) \
-  (VOID)((!(_exp)) ? \
+  (VOID)((!(exp)) ? \
     DbgPrint("%s(%d): Soft assertion failed\n   Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
 
 #define RTL_SOFT_ASSERTMSG(msg, exp) \
@@ -5812,6 +5852,36 @@ KeAcquireSpinLockRaiseToDpc(
 #define RTL_SOFT_VERIFY(exp) RTL_SOFT_ASSERT(exp)
 #define RTL_SOFT_VERIFYMSG(msg, exp) RTL_SOFT_ASSERTMSG(msg, exp)
 
+#if defined(_MSC_VER)
+
+#define NT_ASSERT(exp) \
+   ((!(exp)) ? \
+      (__annotation(L"Debug", L"AssertFail", L#exp), \
+       DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSG(msg, exp) \
+   ((!(exp)) ? \
+      (__annotation(L"Debug", L"AssertFail", L##msg), \
+      DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSGW(msg, exp) \
+    ((!(exp)) ? \
+        (__annotation(L"Debug", L"AssertFail", msg), \
+         DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#else
+
+//
+// GCC doesn't support __annotation (nor PDB)
+//
+#define NT_ASSERT(exp) \
+   (VOID)((!(exp)) ? (DbgRaiseAssertionFailure(), FALSE) : TRUE)
+
+#define NT_ASSERTMSG NT_ASSERT
+#define NT_ASSERTMSGW NT_ASSERT
+
+#endif
+
 #else /* !DBG */
 
 #define ASSERT(exp) ((VOID) 0)
@@ -5826,6 +5896,10 @@ KeAcquireSpinLockRaiseToDpc(
 #define RTL_SOFT_VERIFY(exp) ((exp) ? TRUE : FALSE)
 #define RTL_SOFT_VERIFYMSG(msg, exp) ((exp) ? TRUE : FALSE)
 
+#define NT_ASSERT(exp)     ((VOID)0)
+#define NT_ASSERTMSG(exp)  ((VOID)0)
+#define NT_ASSERTMSGW(exp) ((VOID)0)
+
 #endif /* DBG */
 
 /* HACK HACK HACK - GCC (or perhaps LD) is messing this up */
@@ -10254,6 +10328,13 @@ NTAPI
 KdEnableDebugger(
   VOID);
 
+NTKERNELAPI
+BOOLEAN
+NTAPI
+KdRefreshDebuggerNotPresent(
+    VOID
+);
+
 #if (NTDDI_VERSION >= NTDDI_WS03SP1)
 NTKERNELAPI
 NTSTATUS
@@ -10298,27 +10379,35 @@ NTAPI
 vDbgPrintEx(
   IN ULONG ComponentId,
   IN ULONG Level,
-  IN LPCSTR Format,
+  IN PCCH Format,
   IN va_list ap);
 
 ULONG
 NTAPI
 vDbgPrintExWithPrefix(
-  IN LPCSTR Prefix,
+  IN PCCH Prefix,
   IN ULONG ComponentId,
   IN ULONG Level,
-  IN LPCSTR Format,
+  IN PCCH Format,
   IN va_list ap);
 
 NTKERNELAPI
 ULONG
 DDKCDECLAPI
 DbgPrintReturnControlC(
-  IN PCH  Format,
+  IN PCCH  Format,
   IN ...);
 
+ULONG
+NTAPI
+DbgPrompt(
+    IN PCCH Prompt,
+    OUT PCH Response,
+    IN ULONG MaximumResponseLength
+);
+
 NTKERNELAPI
-BOOLEAN
+NTSTATUS
 NTAPI
 DbgQueryDebugFilterState(
   IN ULONG  ComponentId,
@@ -10348,7 +10437,14 @@ DbgSetDebugFilterState(
 
 #endif /* !DBG */
 
-#if defined(_NTDDK_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
+#if defined(__GNUC__)
+
+extern NTKERNELAPI BOOLEAN KdDebuggerNotPresent;
+extern NTKERNELAPI BOOLEAN KdDebuggerEnabled;
+#define KD_DEBUGGER_ENABLED     KdDebuggerEnabled
+#define KD_DEBUGGER_NOT_PRESENT KdDebuggerNotPresent
+
+#elif defined(_NTDDK_) || defined(_NTHAL_) || defined(_WDMDDK_) || defined(_NTOSP_)
 
 extern NTKERNELAPI PBOOLEAN KdDebuggerNotPresent;
 extern NTKERNELAPI PBOOLEAN KdDebuggerEnabled;