Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
4.3 KiB

  1. //=--------------------------------------------------------------------------=
  2. // Debug.H
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // contains the various macros and the like which are only useful in DEBUG
  13. // builds
  14. //
  15. #ifndef _DEBUG_H_
  16. //=---------------------------------------------------------------------------=
  17. // all the things required to handle our ASSERT mechanism
  18. //=---------------------------------------------------------------------------=
  19. //
  20. #ifdef _DEBUG
  21. // Function Prototypes
  22. //
  23. VOID DisplayAssert(LPSTR pszMsg, LPSTR pszAssert, LPSTR pszFile, UINT line);
  24. // Macros
  25. //
  26. // *** Include this macro at the top of any source file using *ASSERT*() macros ***
  27. //
  28. #define SZTHISFILE static char _szThisFile[] = __FILE__;
  29. // our versions of the ASSERT and FAIL macros.
  30. //
  31. #define ASSERT(fTest, szMsg) \
  32. if (!(fTest)) { \
  33. static char szMsgCode[] = szMsg; \
  34. static char szAssert[] = #fTest; \
  35. DisplayAssert(szMsgCode, szAssert, _szThisFile, __LINE__); \
  36. }
  37. #define ASSERT_(fTest) \
  38. if (!(fTest)) { \
  39. static char szMsgCode[] = "Assertion failure"; \
  40. static char szAssert[] = #fTest; \
  41. DisplayAssert(szMsgCode, szAssert, _szThisFile, __LINE__); \
  42. }
  43. #define FAIL(szMsg) \
  44. { static char szMsgCode[] = szMsg; \
  45. DisplayAssert(szMsgCode, "FAIL", _szThisFile, __LINE__); }
  46. #define ASSERT_POINTER(p, type) \
  47. ASSERT(((p) != NULL) && !IsBadReadPtr((p), sizeof(type)), "Null or bad Pointer")
  48. #define ASSERT_NULL_OR_POINTER(p, type) \
  49. ASSERT(((p) == NULL) || !IsBadReadPtr((p), sizeof(type)), "Bad Pointer")
  50. #define ASSERT_POINTER_LEN(p, len) \
  51. ASSERT(((p) != NULL) && !IsBadReadPtr((p), len), "Null or bad Pointer")
  52. #define ASSERT_POINTER_OCCURS(p, type, occurs) \
  53. ASSERT(((p) != NULL) && !IsBadReadPtr((p), sizeof(type) * occurs), "Null or bad Pointer")
  54. // macro that checks a pointer for validity on input
  55. //
  56. #define CHECK_POINTER(val) if (!(val) || IsBadWritePtr((void *)(val), sizeof(void *))) return E_POINTER
  57. // Viaduct 1
  58. #define VD_ASSERTMSG_SEMAPHORECOUNTTOOLOW "Semaphore count too low"
  59. #define VD_ASSERTMSG_SEMAPHOREWAITERROR "Semaphore wait failed"
  60. #define VD_ASSERTMSG_OUTOFMEMORY "Out of memory"
  61. #define VD_ASSERTMSG_BADSTATUS "Bad status"
  62. #define VD_ASSERTMSG_UNKNOWNDBTYPE "Unknown DBTYPE"
  63. #define VD_ASSERTMSG_BADCOLUMNINDEX "Bad column index"
  64. #define VD_ASSERTMSG_INVALIDROWSTATUS "Invalid row status"
  65. #define VD_ASSERTMSG_COLALREADYINITIALIZED "CVDColumn already initialized"
  66. #define VD_ASSERTMSG_COLCOUNTDOESNTMATCH "Column counts don't match"
  67. #define VD_ASSERTMSG_CANTDIVIDEBYZERO "Can't divide by zero"
  68. #define VD_ASSERTMSG_CANTFINDRESOURCEDLL "Can't find error string resource dll."
  69. // Viaduct 2
  70. #define VD_ASSERTMSG_ROWSRCALREADYINITIALIZED "CVDRowsetSource already initialized"
  71. #else // DEBUG
  72. #define SZTHISFILE
  73. #define ASSERT_POINTER(p, type)
  74. #define ASSERT_NULL_OR_POINTER(p, type)
  75. #define ASSERT_POINTER_LEN(p, len)
  76. #define ASSERT_POINTER_OCCURS(p, type, occurs)
  77. #define ASSERT(fTest, err)
  78. #define ASSERT_(fTest)
  79. #define FAIL(err)
  80. #define CHECK_POINTER(val)
  81. #define VD_ASSERTMSG_SEMAPHORECOUNTTOOLOW 0
  82. #define VD_ASSERTMSG_SEMAPHOREWAITERROR 0
  83. #define VD_ASSERTMSG_OUTOFMEMORY 0
  84. #define VD_ASSERTMSG_BADSTATUS 0
  85. #define VD_ASSERTMSG_UNKNOWNDBTYPE 0
  86. #define VD_ASSERTMSG_BADCOLUMNINDEX 0
  87. #define VD_ASSERTMSG_INVALIDROWSTATUS 0
  88. #define VD_ASSERTMSG_COLALREADYINITIALIZED 0
  89. #define VD_ASSERTMSG_COLCOUNTDOESNTMATCH 0
  90. #define VD_ASSERTMSG_CANTDIVIDEBYZERO 0
  91. #define VD_ASSERTMSG_CANTFINDRESOURCEDLL 0
  92. #endif // DEBUG
  93. #define _DEBUG_H_
  94. #endif // _DEBUG_H_