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.

144 lines
2.9 KiB

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