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.

120 lines
2.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. SrvList.h
  5. Abstract:
  6. List package for SrvList.c
  7. Environment:
  8. Console App. User mode.
  9. Revision History:
  10. --*/
  11. //
  12. // Doubly-linked list manipulation routines. Implemented as macros
  13. // but logically these are procedures.
  14. //
  15. //
  16. // VOID
  17. // InitializeListHead(
  18. // PLIST_ENTRY ListHead
  19. // );
  20. //
  21. #define InitializeListHead(ListHead) (\
  22. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  23. //
  24. // BOOLEAN
  25. // IsListEmpty(
  26. // PLIST_ENTRY ListHead
  27. // );
  28. //
  29. #define IsListEmpty(ListHead) \
  30. ((ListHead)->Flink == (ListHead))
  31. //
  32. // PLIST_ENTRY
  33. // RemoveHeadList(
  34. // PLIST_ENTRY ListHead
  35. // );
  36. //
  37. #define RemoveHeadList(ListHead) \
  38. (ListHead)->Flink;\
  39. {RemoveEntryList((ListHead)->Flink)}
  40. //
  41. // PLIST_ENTRY
  42. // RemoveTailList(
  43. // PLIST_ENTRY ListHead
  44. // );
  45. //
  46. #define RemoveTailList(ListHead) \
  47. (ListHead)->Blink;\
  48. {RemoveEntryList((ListHead)->Blink)}
  49. //
  50. // VOID
  51. // RemoveEntryList(
  52. // PLIST_ENTRY Entry
  53. // );
  54. //
  55. #define RemoveEntryList(Entry) {\
  56. PLIST_ENTRY _EX_Blink;\
  57. PLIST_ENTRY _EX_Flink;\
  58. _EX_Flink = (Entry)->Flink;\
  59. _EX_Blink = (Entry)->Blink;\
  60. _EX_Blink->Flink = _EX_Flink;\
  61. _EX_Flink->Blink = _EX_Blink;\
  62. }
  63. //
  64. // VOID
  65. // InsertTailList(
  66. // PLIST_ENTRY ListHead,
  67. // PLIST_ENTRY Entry
  68. // );
  69. //
  70. #define InsertTailList(ListHead,Entry) {\
  71. PLIST_ENTRY _EX_Blink;\
  72. PLIST_ENTRY _EX_ListHead;\
  73. _EX_ListHead = (ListHead);\
  74. _EX_Blink = _EX_ListHead->Blink;\
  75. (Entry)->Flink = _EX_ListHead;\
  76. (Entry)->Blink = _EX_Blink;\
  77. _EX_Blink->Flink = (Entry);\
  78. _EX_ListHead->Blink = (Entry);\
  79. }
  80. //
  81. // VOID
  82. // InsertHeadList(
  83. // PLIST_ENTRY ListHead,
  84. // PLIST_ENTRY Entry
  85. // );
  86. //
  87. #define InsertHeadList(ListHead,Entry) {\
  88. PLIST_ENTRY _EX_Flink;\
  89. PLIST_ENTRY _EX_ListHead;\
  90. _EX_ListHead = (ListHead);\
  91. _EX_Flink = _EX_ListHead->Flink;\
  92. (Entry)->Flink = _EX_Flink;\
  93. (Entry)->Blink = _EX_ListHead;\
  94. _EX_Flink->Blink = (Entry);\
  95. _EX_ListHead->Flink = (Entry);\
  96. }