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.

231 lines
4.1 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. serialst.h
  5. Abstract:
  6. Header file for serialst.c
  7. Author:
  8. Richard L Firth (rfirth) 16-Feb-1995
  9. Revision History:
  10. 16-Feb-1995 rfirth
  11. Created
  12. --*/
  13. //
  14. // types
  15. //
  16. typedef struct {
  17. #if INET_DEBUG
  18. //
  19. // Signature - must have this to ensure its really a serialized list. Also
  20. // makes finding start of this structure relatively easy when debugging
  21. //
  22. DWORD Signature;
  23. //
  24. // ResourceInfo - basically who owns this 'object', combined with yet more
  25. // debugging information
  26. //
  27. RESOURCE_INFO ResourceInfo;
  28. //
  29. // LockCount - number of re-entrant locks held
  30. //
  31. LONG LockCount;
  32. #endif // INET_DEBUG
  33. LIST_ENTRY List;
  34. //
  35. // ElementCount - number of items on list. Useful for consistency checking
  36. //
  37. LONG ElementCount;
  38. //
  39. // Lock - we must acquire this to update the list. Put this structure at
  40. // the end to make life easier when debugging
  41. //
  42. CCritSec Lock;
  43. } SERIALIZED_LIST, *LPSERIALIZED_LIST;
  44. //
  45. // SERIALIZED_LIST_ENTRY - we can use this in place of LIST_ENTRY so that in
  46. // the debug version we can check for cycles, etc.
  47. //
  48. typedef struct {
  49. LIST_ENTRY List;
  50. #if INET_DEBUG
  51. DWORD Signature;
  52. DWORD Flags;
  53. #endif
  54. } SERIALIZED_LIST_ENTRY, *LPSERIALIZED_LIST_ENTRY;
  55. //
  56. // prototypes
  57. //
  58. #if INET_DEBUG
  59. BOOL
  60. InitializeSerializedList(
  61. IN LPSERIALIZED_LIST SerializedList
  62. );
  63. VOID
  64. TerminateSerializedList(
  65. IN LPSERIALIZED_LIST SerializedList
  66. );
  67. BOOL
  68. LockSerializedList(
  69. IN LPSERIALIZED_LIST SerializedList
  70. );
  71. VOID
  72. UnlockSerializedList(
  73. IN LPSERIALIZED_LIST SerializedList
  74. );
  75. BOOL
  76. InsertAtHeadOfSerializedList(
  77. IN LPSERIALIZED_LIST SerializedList,
  78. IN PLIST_ENTRY Entry
  79. );
  80. BOOL
  81. InsertAtTailOfSerializedList(
  82. IN LPSERIALIZED_LIST SerializedList,
  83. IN PLIST_ENTRY Entry
  84. );
  85. BOOL
  86. RemoveFromSerializedList(
  87. IN LPSERIALIZED_LIST SerializedList,
  88. IN PLIST_ENTRY Entry
  89. );
  90. BOOL
  91. IsSerializedListEmpty(
  92. IN LPSERIALIZED_LIST SerializedList
  93. );
  94. PLIST_ENTRY
  95. HeadOfSerializedList(
  96. IN LPSERIALIZED_LIST SerializedList
  97. );
  98. PLIST_ENTRY
  99. TailOfSerializedList(
  100. IN LPSERIALIZED_LIST SerializedList
  101. );
  102. BOOL
  103. CheckEntryOnSerializedList(
  104. IN LPSERIALIZED_LIST SerializedList,
  105. IN PLIST_ENTRY Entry,
  106. IN BOOL ExpectedResult
  107. );
  108. #define IsLockHeld(list) \
  109. (((list)->ResourceInfo.Tid == GetCurrentThreadId()) \
  110. ? ((list)->LockCount != 0) \
  111. : FALSE)
  112. #else // INET_DEBUG
  113. BOOL
  114. InitializeSerializedList(LPSERIALIZED_LIST pList);
  115. #define TerminateSerializedList(list) \
  116. ((list)->Lock.FreeLock())
  117. #define LockSerializedList(list) \
  118. ((list)->Lock.Lock())
  119. #define UnlockSerializedList(list) \
  120. ((list)->Lock.Unlock())
  121. BOOL
  122. InsertAtHeadOfSerializedList(LPSERIALIZED_LIST list, PLIST_ENTRY entry);
  123. BOOL
  124. InsertAtTailOfSerializedList(LPSERIALIZED_LIST list, PLIST_ENTRY entry);
  125. BOOL
  126. RemoveFromSerializedList(LPSERIALIZED_LIST list, PLIST_ENTRY entry);
  127. #define IsSerializedListEmpty(list) \
  128. IsListEmpty(&(list)->List)
  129. #define HeadOfSerializedList(list) \
  130. (list)->List.Flink
  131. #define TailOfSerializedList(list) \
  132. (list)->List.Blink
  133. #define IsLockHeld(list) \
  134. /* NOTHING */
  135. #endif // INET_DEBUG
  136. //
  137. // functions that are always functions
  138. //
  139. LPVOID
  140. SlDequeueHead(
  141. IN LPSERIALIZED_LIST SerializedList
  142. );
  143. LPVOID
  144. SlDequeueTail(
  145. IN LPSERIALIZED_LIST SerializedList
  146. );
  147. BOOL
  148. IsOnSerializedList(
  149. IN LPSERIALIZED_LIST SerializedList,
  150. IN PLIST_ENTRY Entry
  151. );
  152. //
  153. // functions that are always macros
  154. //
  155. #define NextInSerializedList(list, entry)\
  156. (( ((entry)->List).Flink == &((list)->List))? NULL : ((entry)->List).Flink)
  157. #define ElementsOnSerializedList(list) \
  158. (list)->ElementCount
  159. #define SlSelf(SerializedList) \
  160. &(SerializedList)->List.Flink