1 /*++ 2 3 Copyright (c) Microsoft Corporation. All rights reserved. 4 5 _WdfVersionBuild_ 6 7 Module Name: 8 9 WdfAssert.h 10 11 Abstract: 12 13 Contains prototypes for dealing with run time asserts 14 15 Author: 16 17 Environment: 18 19 kernel mode only 20 21 Revision History: 22 23 --*/ 24 25 // 26 // NOTE: This header is generated by stubwork. Please make any 27 // modifications to the corresponding template files 28 // (.x or .y) and use stubwork to regenerate the header 29 // 30 31 #ifndef _WDFASSERT_H_ 32 #define _WDFASSERT_H_ 33 34 #ifndef WDF_EXTERN_C 35 #ifdef __cplusplus 36 #define WDF_EXTERN_C extern "C" 37 #define WDF_EXTERN_C_START extern "C" { 38 #define WDF_EXTERN_C_END } 39 #else 40 #define WDF_EXTERN_C 41 #define WDF_EXTERN_C_START 42 #define WDF_EXTERN_C_END 43 #endif 44 #endif 45 46 WDF_EXTERN_C_START 47 48 49 50 51 #if (NTDDI_VERSION >= NTDDI_WIN2K) 52 53 // 54 // Including here because RtlAssert is not declared in XP and Win2K headers for 55 // free builds 56 // 57 NTSYSAPI 58 VOID 59 NTAPI 60 RtlAssert( 61 _In_ PVOID FailedAssertion, 62 _In_ PVOID FileName, 63 _In_ ULONG LineNumber, 64 _In_opt_ PSTR Message 65 ); 66 67 68 69 // 70 // WDFVERIFY is active both on checked and free build only if 71 // the wdf verifier is tuned on 72 // 73 #define WDFVERIFY(exp) { \ 74 if ((WdfDriverGlobals->DriverFlags & WdfVerifyOn) && !(exp)) { \ 75 RtlAssert( #exp, __FILE__, __LINE__, NULL ); \ 76 } \ 77 } 78 79 #define VERIFY_IS_IRQL_PASSIVE_LEVEL() WDFVERIFY(KeGetCurrentIrql() == PASSIVE_LEVEL) 80 81 // 82 // Following macro is obsolete and it will be phased out in due course 83 // 84 #define IS_AT_PASSIVE() WDFVERIFY(KeGetCurrentIrql() == PASSIVE_LEVEL) 85 86 // 87 // Compile time active "assert". File will not compile if this assert is FALSE. 88 // 89 // This compile time assert is designed to catch mismatch in the values of the 90 // declared constants. So suppress the OACR warning #6326 generated about the 91 // potential comparison of constants. 92 // 93 #define WDFCASSERT(c) { \ 94 __pragma(warning(suppress: 6326)) \ 95 switch(0) case (c): case 0: ; \ 96 } 97 98 99 100 101 102 #endif // (NTDDI_VERSION >= NTDDI_WIN2K) 103 104 WDF_EXTERN_C_END 105 106 #endif // _WDFASSERT_H_ 107 108