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.

131 lines
2.5 KiB

  1. //
  2. // Doubly-linked list manipulation routines. Implemented as macros
  3. // but logically these are procedures.
  4. //
  5. //
  6. // VOID
  7. // InitializeListHead(
  8. // PLIST_ENTRY ListHead
  9. // );
  10. //
  11. #define InitializeListHead(ListHead) (\
  12. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  13. //
  14. // BOOLEAN
  15. // IsListEmpty(
  16. // PLIST_ENTRY ListHead
  17. // );
  18. //
  19. #define IsListEmpty(ListHead) \
  20. ((ListHead)->Flink == (ListHead))
  21. //
  22. // PLIST_ENTRY
  23. // RemoveHeadList(
  24. // PLIST_ENTRY ListHead
  25. // );
  26. //
  27. #define RemoveHeadList(ListHead) \
  28. (ListHead)->Flink;\
  29. {RemoveEntryList((ListHead)->Flink)}
  30. //
  31. // PLIST_ENTRY
  32. // RemoveTailList(
  33. // PLIST_ENTRY ListHead
  34. // );
  35. //
  36. #define RemoveTailList(ListHead) \
  37. (ListHead)->Blink;\
  38. {RemoveEntryList((ListHead)->Blink)}
  39. //
  40. // VOID
  41. // RemoveEntryList(
  42. // PLIST_ENTRY Entry
  43. // );
  44. //
  45. #define RemoveEntryList(Entry) {\
  46. PLIST_ENTRY _EX_Blink;\
  47. PLIST_ENTRY _EX_Flink;\
  48. _EX_Flink = (Entry)->Flink;\
  49. _EX_Blink = (Entry)->Blink;\
  50. _EX_Blink->Flink = _EX_Flink;\
  51. _EX_Flink->Blink = _EX_Blink;\
  52. }
  53. //
  54. // VOID
  55. // InsertTailList(
  56. // PLIST_ENTRY ListHead,
  57. // PLIST_ENTRY Entry
  58. // );
  59. //
  60. #define InsertTailList(ListHead,Entry) {\
  61. PLIST_ENTRY _EX_Blink;\
  62. PLIST_ENTRY _EX_ListHead;\
  63. _EX_ListHead = (ListHead);\
  64. _EX_Blink = _EX_ListHead->Blink;\
  65. (Entry)->Flink = _EX_ListHead;\
  66. (Entry)->Blink = _EX_Blink;\
  67. _EX_Blink->Flink = (Entry);\
  68. _EX_ListHead->Blink = (Entry);\
  69. }
  70. //
  71. // VOID
  72. // InsertHeadList(
  73. // PLIST_ENTRY ListHead,
  74. // PLIST_ENTRY Entry
  75. // );
  76. //
  77. #define InsertHeadList(ListHead,Entry) {\
  78. PLIST_ENTRY _EX_Flink;\
  79. PLIST_ENTRY _EX_ListHead;\
  80. _EX_ListHead = (ListHead);\
  81. _EX_Flink = _EX_ListHead->Flink;\
  82. (Entry)->Flink = _EX_Flink;\
  83. (Entry)->Blink = _EX_ListHead;\
  84. _EX_Flink->Blink = (Entry);\
  85. _EX_ListHead->Flink = (Entry);\
  86. }
  87. //
  88. //
  89. // PSINGLE_LIST_ENTRY
  90. // PopEntryList(
  91. // PSINGLE_LIST_ENTRY ListHead
  92. // );
  93. //
  94. #define PopEntryList(ListHead) \
  95. (ListHead)->Next;\
  96. {\
  97. PSINGLE_LIST_ENTRY FirstEntry;\
  98. FirstEntry = (ListHead)->Next;\
  99. if (FirstEntry != NULL) { \
  100. (ListHead)->Next = FirstEntry->Next;\
  101. } \
  102. }
  103. //
  104. // VOID
  105. // PushEntryList(
  106. // PSINGLE_LIST_ENTRY ListHead,
  107. // PSINGLE_LIST_ENTRY Entry
  108. // );
  109. //
  110. #define PushEntryList(ListHead,Entry) \
  111. (Entry)->Next = (ListHead)->Next; \
  112. (ListHead)->Next = (Entry)