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.

151 lines
7.9 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. fwddecl.h
  5. Abstract:
  6. This file defines dummy structures to avoid the circular relationships in
  7. header files.
  8. Author:
  9. Jameel Hyder (microsoft!jameelh)
  10. Revision History:
  11. 2 Oct 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _FWDDECL_
  15. #define _FWDDECL_
  16. struct _SessDataArea;
  17. struct _ConnDesc;
  18. struct _VolDesc;
  19. struct _FileDirParms;
  20. struct _PathMapEntity;
  21. struct _DirFileEntry;
  22. struct _FileDirParms;
  23. struct _IoPoolHdr;
  24. struct _IoPool;
  25. //
  26. // enable asserts when running checked stack on free builds
  27. //
  28. #if DBG
  29. #ifdef ASSERT
  30. #undef ASSERT
  31. #endif
  32. #define ASSERT(exp) \
  33. { \
  34. if (!(exp)) \
  35. { \
  36. DbgPrint( "\n*** Assertion failed: %s (File %s, line %ld)\n", \
  37. (exp),__FILE__, __LINE__); \
  38. \
  39. DbgBreakPoint(); \
  40. } \
  41. }
  42. #endif
  43. // Spinlock macros
  44. #if DBG
  45. #define INITIALIZE_SPIN_LOCK(_pLock) \
  46. { \
  47. KeInitializeSpinLock(&(_pLock)->SpinLock); \
  48. (_pLock)->FileLineLock = 0; \
  49. }
  50. #else // DBG
  51. #define INITIALIZE_SPIN_LOCK(_pLock) \
  52. { \
  53. KeInitializeSpinLock(&(_pLock)->SpinLock); \
  54. }
  55. #endif
  56. #if DBG
  57. #define ACQUIRE_SPIN_LOCK(_pLock, _pOldIrql) \
  58. { \
  59. KeAcquireSpinLock(&(_pLock)->SpinLock, \
  60. _pOldIrql); \
  61. (_pLock)->FileLineLock = (FILENUM | __LINE__); \
  62. }
  63. #define ACQUIRE_SPIN_LOCK_AT_DPC(_pLock) \
  64. { \
  65. ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); \
  66. KeAcquireSpinLockAtDpcLevel(&(_pLock)->SpinLock); \
  67. (_pLock)->FileLineLock = (FILENUM | __LINE__ | 0x80000000); \
  68. }
  69. #define RELEASE_SPIN_LOCK(_pLock, _OldIrql) \
  70. { \
  71. ASSERT ((_pLock)->FileLineLock != 0); \
  72. ASSERT (((_pLock)->FileLineLock & 0x80000000) == 0); \
  73. (_pLock)->FileLineLock = 0; \
  74. (_pLock)->FileLineUnlock = (FILENUM | __LINE__); \
  75. KeReleaseSpinLock(&(_pLock)->SpinLock, \
  76. _OldIrql); \
  77. }
  78. #define RELEASE_SPIN_LOCK_FROM_DPC(_pLock) \
  79. { \
  80. ASSERT ((_pLock)->FileLineLock != 0); \
  81. ASSERT ((_pLock)->FileLineLock & 0x80000000); \
  82. (_pLock)->FileLineLock = 0; \
  83. (_pLock)->FileLineUnlock = (FILENUM | __LINE__ | 0x80000000); \
  84. KeReleaseSpinLockFromDpcLevel(&(_pLock)->SpinLock); \
  85. ASSERT(KeGetCurrentIrql() == DISPATCH_LEVEL); \
  86. }
  87. #else // DBG
  88. #define ACQUIRE_SPIN_LOCK(_pLock, _pOldIrql) \
  89. { \
  90. KeAcquireSpinLock(&(_pLock)->SpinLock, \
  91. _pOldIrql); \
  92. }
  93. #define ACQUIRE_SPIN_LOCK_AT_DPC(_pLock) \
  94. { \
  95. KeAcquireSpinLockAtDpcLevel(&(_pLock)->SpinLock); \
  96. }
  97. #define RELEASE_SPIN_LOCK(_pLock, _OldIrql) \
  98. { \
  99. KeReleaseSpinLock(&(_pLock)->SpinLock, \
  100. (_OldIrql)); \
  101. }
  102. #define RELEASE_SPIN_LOCK_FROM_DPC(_pLock) \
  103. { \
  104. KeReleaseSpinLockFromDpcLevel(&(_pLock)->SpinLock); \
  105. } \
  106. #endif // DBG
  107. typedef struct
  108. {
  109. KSPIN_LOCK SpinLock;
  110. #if DBG
  111. ULONG FileLineLock;
  112. ULONG FileLineUnlock;
  113. #endif
  114. } AFP_SPIN_LOCK, *PAFP_SPIN_LOCK;
  115. #endif // _FWDDECL_