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. // BOOL
  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. #define InsertHeadList(ListHead,Entry) {\
  77. PLIST_ENTRY _EX_Flink;\
  78. PLIST_ENTRY _EX_ListHead;\
  79. _EX_ListHead = (ListHead);\
  80. _EX_Flink = _EX_ListHead->Flink;\
  81. (Entry)->Flink = _EX_Flink;\
  82. (Entry)->Blink = _EX_ListHead;\
  83. _EX_Flink->Blink = (Entry);\
  84. _EX_ListHead->Flink = (Entry);\
  85. }
  86. //
  87. //
  88. // PSINGLE_LIST_ENTRY
  89. // PopEntryList(
  90. // PSINGLE_LIST_ENTRY ListHead
  91. // );
  92. //
  93. #define PopEntryList(ListHead) \
  94. (ListHead)->Next;\
  95. {\
  96. PSINGLE_LIST_ENTRY FirstEntry;\
  97. FirstEntry = (ListHead)->Next;\
  98. if (FirstEntry != NULL) { \
  99. (ListHead)->Next = FirstEntry->Next;\
  100. } \
  101. }
  102. //
  103. // VOID
  104. // PushEntryList(
  105. // PSINGLE_LIST_ENTRY ListHead,
  106. // PSINGLE_LIST_ENTRY Entry
  107. // );
  108. //
  109. #define PushEntryList(ListHead,Entry) \
  110. (Entry)->Next = (ListHead)->Next; \
  111. (ListHead)->Next = (Entry)