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.

158 lines
3.0 KiB

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