Source code of Windows XP (NT5)
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.

160 lines
3.1 KiB

  1. // copied from winnt.h and wdm.h in winnt platform sdk
  2. #ifndef _SSDPLIST_
  3. #define _SSDPLIST_
  4. //
  5. // Doubly linked list structure. Can be used as either a list head, or
  6. // as link words.
  7. //
  8. // LIST_ENTRY and SINGLE_LIST_ENTRY are defined in winnt.h
  9. /*
  10. typedef struct _LIST_ENTRY {
  11. struct _LIST_ENTRY *Flink;
  12. struct _LIST_ENTRY *Blink;
  13. } LIST_ENTRY, *PLIST_ENTRY, *RESTRICTED_POINTER PRLIST_ENTRY;
  14. */
  15. //
  16. // Singly linked list structure. Can be used as either a list head, or
  17. // as link words.
  18. //
  19. /*
  20. typedef struct _SINGLE_LIST_ENTRY {
  21. struct _SINGLE_LIST_ENTRY *Next;
  22. } SINGLE_LIST_ENTRY, *PSINGLE_LIST_ENTRY;
  23. */
  24. //
  25. // Doubly-linked list manipulation routines. Implemented as macros
  26. // but logically these are procedures.
  27. //
  28. //
  29. // VOID
  30. // InitializeListHead(
  31. // PLIST_ENTRY ListHead
  32. // );
  33. //
  34. #define InitializeListHead(ListHead) (\
  35. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  36. //
  37. // BOOLEAN
  38. // IsListEmpty(
  39. // PLIST_ENTRY ListHead
  40. // );
  41. //
  42. #define IsListEmpty(ListHead) \
  43. ((ListHead)->Flink == (ListHead))
  44. //
  45. // PLIST_ENTRY
  46. // RemoveHeadList(
  47. // PLIST_ENTRY ListHead
  48. // );
  49. //
  50. #define RemoveHeadList(ListHead) \
  51. (ListHead)->Flink;\
  52. {RemoveEntryList((ListHead)->Flink)}
  53. //
  54. // PLIST_ENTRY
  55. // RemoveTailList(
  56. // PLIST_ENTRY ListHead
  57. // );
  58. //
  59. #define RemoveTailList(ListHead) \
  60. (ListHead)->Blink;\
  61. {RemoveEntryList((ListHead)->Blink)}
  62. //
  63. // VOID
  64. // RemoveEntryList(
  65. // PLIST_ENTRY Entry
  66. // );
  67. //
  68. #define RemoveEntryList(Entry) {\
  69. PLIST_ENTRY _EX_Blink;\
  70. PLIST_ENTRY _EX_Flink;\
  71. _EX_Flink = (Entry)->Flink;\
  72. _EX_Blink = (Entry)->Blink;\
  73. _EX_Blink->Flink = _EX_Flink;\
  74. _EX_Flink->Blink = _EX_Blink;\
  75. }
  76. //
  77. // VOID
  78. // InsertTailList(
  79. // PLIST_ENTRY ListHead,
  80. // PLIST_ENTRY Entry
  81. // );
  82. //
  83. #define InsertTailList(ListHead,Entry) {\
  84. PLIST_ENTRY _EX_Blink;\
  85. PLIST_ENTRY _EX_ListHead;\
  86. _EX_ListHead = (ListHead);\
  87. _EX_Blink = _EX_ListHead->Blink;\
  88. (Entry)->Flink = _EX_ListHead;\
  89. (Entry)->Blink = _EX_Blink;\
  90. _EX_Blink->Flink = (Entry);\
  91. _EX_ListHead->Blink = (Entry);\
  92. }
  93. //
  94. // VOID
  95. // InsertHeadList(
  96. // PLIST_ENTRY ListHead,
  97. // PLIST_ENTRY Entry
  98. // );
  99. //
  100. #define InsertHeadList(ListHead,Entry) {\
  101. PLIST_ENTRY _EX_Flink;\
  102. PLIST_ENTRY _EX_ListHead;\
  103. _EX_ListHead = (ListHead);\
  104. _EX_Flink = _EX_ListHead->Flink;\
  105. (Entry)->Flink = _EX_Flink;\
  106. (Entry)->Blink = _EX_ListHead;\
  107. _EX_Flink->Blink = (Entry);\
  108. _EX_ListHead->Flink = (Entry);\
  109. }
  110. //
  111. //
  112. // PSINGLE_LIST_ENTRY
  113. // PopEntryList(
  114. // PSINGLE_LIST_ENTRY ListHead
  115. // );
  116. //
  117. #define PopEntryList(ListHead) \
  118. (ListHead)->Next;\
  119. {\
  120. PSINGLE_LIST_ENTRY FirstEntry;\
  121. FirstEntry = (ListHead)->Next;\
  122. if (FirstEntry != NULL) { \
  123. (ListHead)->Next = FirstEntry->Next;\
  124. } \
  125. }
  126. //
  127. // VOID
  128. // PushEntryList(
  129. // PSINGLE_LIST_ENTRY ListHead,
  130. // PSINGLE_LIST_ENTRY Entry
  131. // );
  132. //
  133. #define PushEntryList(ListHead,Entry) \
  134. (Entry)->Next = (ListHead)->Next; \
  135. (ListHead)->Next = (Entry)
  136. #endif // _SSDPLIST_