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.

153 lines
3.1 KiB

  1. #ifndef _LINK_H
  2. #define _LINK_H
  3. /*++
  4. Copyright (c) 1998 Intel Corporation
  5. Module Name:
  6. link.h
  7. Abstract:
  8. EFI link list macro's
  9. Revision History
  10. --*/
  11. #ifndef EFI_NT_EMUL
  12. /*
  13. * List entry - doubly linked list
  14. */
  15. typedef struct _LIST_ENTRY {
  16. struct _LIST_ENTRY *Flink;
  17. struct _LIST_ENTRY *Blink;
  18. } LIST_ENTRY;
  19. #endif
  20. /*
  21. * VOID
  22. * InitializeListHead(
  23. * LIST_ENTRY *ListHead
  24. * );
  25. */
  26. #define InitializeListHead(ListHead) \
  27. (ListHead)->Flink = ListHead; \
  28. (ListHead)->Blink = ListHead;
  29. /*
  30. * BOOLEAN
  31. * IsListEmpty(
  32. * PLIST_ENTRY ListHead
  33. * );
  34. */
  35. #define IsListEmpty(ListHead) \
  36. ((ListHead)->Flink == (ListHead))
  37. /*
  38. * VOID
  39. * RemoveEntryList(
  40. * PLIST_ENTRY Entry
  41. * );
  42. */
  43. #define _RemoveEntryList(Entry) { \
  44. LIST_ENTRY *_Blink, *_Flink; \
  45. _Flink = (Entry)->Flink; \
  46. _Blink = (Entry)->Blink; \
  47. _Blink->Flink = _Flink; \
  48. _Flink->Blink = _Blink; \
  49. }
  50. #if EFI_DEBUG
  51. #define RemoveEntryList(Entry) \
  52. _RemoveEntryList(Entry); \
  53. (Entry)->Flink = (LIST_ENTRY *) BAD_POINTER; \
  54. (Entry)->Blink = (LIST_ENTRY *) BAD_POINTER;
  55. #else
  56. #define RemoveEntryList(Entry) \
  57. _RemoveEntryList(Entry);
  58. #endif
  59. /*
  60. * VOID
  61. * InsertTailList(
  62. * PLIST_ENTRY ListHead,
  63. * PLIST_ENTRY Entry
  64. * );
  65. */
  66. #define InsertTailList(ListHead,Entry) {\
  67. LIST_ENTRY *_ListHead, *_Blink; \
  68. _ListHead = (ListHead); \
  69. _Blink = _ListHead->Blink; \
  70. (Entry)->Flink = _ListHead; \
  71. (Entry)->Blink = _Blink; \
  72. _Blink->Flink = (Entry); \
  73. _ListHead->Blink = (Entry); \
  74. }
  75. /*
  76. * VOID
  77. * InsertHeadList(
  78. * PLIST_ENTRY ListHead,
  79. * PLIST_ENTRY Entry
  80. * );
  81. */
  82. #define InsertHeadList(ListHead,Entry) {\
  83. LIST_ENTRY *_ListHead, *_Flink; \
  84. _ListHead = (ListHead); \
  85. _Flink = _ListHead->Flink; \
  86. (Entry)->Flink = _Flink; \
  87. (Entry)->Blink = _ListHead; \
  88. _Flink->Blink = (Entry); \
  89. _ListHead->Flink = (Entry); \
  90. }
  91. /*
  92. * EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
  93. */
  94. #define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))
  95. /*
  96. * CONTAINING_RECORD - returns a pointer to the structure
  97. * from one of it's elements.
  98. */
  99. #define _CR(Record, TYPE, Field) \
  100. ((TYPE *) ( (CHAR8 *)(Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
  101. #if EFI_DEBUG
  102. #define CR(Record, TYPE, Field, Sig) \
  103. _CR(Record, TYPE, Field)->Signature != Sig ? \
  104. (TYPE *) ASSERT_STRUCT(_CR(Record, TYPE, Field), Record) : \
  105. _CR(Record, TYPE, Field)
  106. #else
  107. #define CR(Record, TYPE, Field, Signature) \
  108. _CR(Record, TYPE, Field)
  109. #endif
  110. /*
  111. * A lock structure
  112. */
  113. typedef struct _FLOCK {
  114. EFI_TPL Tpl;
  115. EFI_TPL OwnerTpl;
  116. UINTN Lock;
  117. } FLOCK;
  118. #endif