summaryrefslogtreecommitdiff
path: root/src/inc/winrt/ntassert.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/inc/winrt/ntassert.h')
-rw-r--r--src/inc/winrt/ntassert.h213
1 files changed, 213 insertions, 0 deletions
diff --git a/src/inc/winrt/ntassert.h b/src/inc/winrt/ntassert.h
new file mode 100644
index 0000000000..24d7cb2bde
--- /dev/null
+++ b/src/inc/winrt/ntassert.h
@@ -0,0 +1,213 @@
+//
+// Copyright (c) Microsoft. All rights reserved.
+// Licensed under the MIT license. See LICENSE file in the project root for full license information.
+//
+
+/*++
+
+Copyright (c) 2009 Microsoft Corporation. All rights reserved.
+
+Module Name:
+
+ ntassert.h
+
+Abstract:
+
+ Defines DbgRaiseAssertionFailure, and the NT_ASSERT and NT_VERIFY macros.
+
+ Note that normally platform-specific definitions like
+ DbgRaiseAssertionFailure would go to platform-specific subheaders (nti386_x,
+ etc.), they are placed here instead for convenience.
+
+--*/
+
+#pragma once
+
+// begin_wdm begin_winnt begin_ntminiport
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+//
+// Assert exception.
+//
+
+#if !defined(_DBGRAISEASSERTIONFAILURE_) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
+
+#define _DBGRAISEASSERTIONFAILURE_
+
+#if defined(_PREFAST_)
+
+__analysis_noreturn
+FORCEINLINE
+VOID
+DbgRaiseAssertionFailure (
+ VOID
+ );
+
+#endif
+
+#if defined(_AMD64_)
+
+#if defined(_M_AMD64)
+
+VOID
+__int2c (
+ VOID
+ );
+
+#pragma intrinsic(__int2c)
+
+#if !defined(_PREFAST_)
+
+#define DbgRaiseAssertionFailure() __int2c()
+
+#endif // !defined(_PREFAST_)
+
+#endif // defined(_M_AMD64)
+
+#elif defined(_X86_)
+
+#if defined(_M_IX86)
+
+#if _MSC_FULL_VER >= 140030222
+
+VOID
+__int2c (
+ VOID
+ );
+
+#pragma intrinsic(__int2c)
+
+#if !defined(_PREFAST_)
+
+#define DbgRaiseAssertionFailure() __int2c()
+
+#endif // !defined(_PREFAST_)
+
+#else // _MSC_FULL_VER >= 140030222
+
+#pragma warning( push )
+#pragma warning( disable : 4793 )
+
+#if !defined(_PREFAST_)
+
+__analysis_noreturn
+FORCEINLINE
+VOID
+DbgRaiseAssertionFailure (
+ VOID
+ )
+
+{
+ __asm int 0x2c
+}
+
+#endif // !defined(_PREFAST_)
+
+#pragma warning( pop )
+
+#endif // _MSC_FULL_VER >= 140030222
+
+#endif // defined(_M_IX86)
+
+#elif defined(_IA64_)
+
+#if defined(_M_IA64)
+
+void
+__break(
+ _In_ int StIIM
+ );
+
+#pragma intrinsic (__break)
+
+#define BREAK_DEBUG_BASE 0x080000
+#define ASSERT_BREAKPOINT (BREAK_DEBUG_BASE+3) // Cause a STATUS_ASSERTION_FAILURE exception to be raised.
+
+#if !defined(_PREFAST_)
+
+#define DbgRaiseAssertionFailure() __break(ASSERT_BREAKPOINT)
+
+#endif // !defined(_PREFAST_)
+
+#endif // defined(_M_IA64)
+
+#elif defined(_ARM_)
+
+#if defined(_M_ARM)
+
+VOID
+__emit(
+ const unsigned __int32 opcode
+ );
+
+#pragma intrinsic(__emit)
+
+#if !defined(_PREFAST_)
+
+#define DbgRaiseAssertionFailure() __emit(0xdefc) // THUMB_ASSERT
+
+#endif // !defined(_PREFAST_)
+
+#endif // defined(_M_ARM)
+
+#endif // _AMD64_, _X86_, _IA64_, _ARM_
+#endif // !defined(_DBGRAISEASSERTIONFAILURE_) && !defined(RC_INVOKED) && !defined(MIDL_PASS)
+
+#ifdef __cplusplus
+}
+#endif
+
+// end_wdm end_winnt end_ntminiport
+
+// begin_wdm begin_ntminiport
+
+#if _MSC_VER >= 1300
+#if DBG
+
+#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)
+
+#define NT_VERIFY NT_ASSERT
+#define NT_VERIFYMSG NT_ASSERTMSG
+#define NT_VERIFYMSGW NT_ASSERTMSGW
+
+#else // DBG
+
+#define NT_ASSERT(_exp) ((void) 0)
+#define NT_ASSERTMSG(_msg, _exp) ((void) 0)
+#define NT_ASSERTMSGW(_msg, _exp) ((void) 0)
+
+#define NT_VERIFY(_exp) ((_exp) ? TRUE : FALSE)
+#define NT_VERIFYMSG(_msg, _exp ) ((_exp) ? TRUE : FALSE)
+#define NT_VERIFYMSGW(_msg, _exp) ((_exp) ? TRUE : FALSE)
+
+#endif // DBG
+#endif // _MSC_VER >= 1300
+
+// end_wdm end_ntminiport
+
+#define WIN_ASSERT NT_ASSERT
+#define WIN_ASSERTMSG NT_ASSERTMSG
+#define WIN_ASSERTMSGW NT_ASSERTMSGW
+#define WIN_VERIFY NT_VERIFY
+#define WIN_VERIFYMSG NT_ASSERTMSG
+#define WIN_VERIFYMSGW NT_ASSERTMSGW
+