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.

179 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. rtlstuff.h
  5. Abstract:
  6. Domain Name System (DNS) Libary
  7. Macros from NT RTL headers.
  8. Copied here from ntrtl.h so we can build free of any NT specific headers.
  9. Author:
  10. Jim Gilroy (jamesg) May 1997
  11. Revision History:
  12. --*/
  13. #ifndef _RTLSTUFF_INCLUDED_
  14. #define _RTLSTUFF_INCLUDED_
  15. //
  16. // Doubly-linked list manipulation routines.
  17. // Implemented as macros 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. //
  128. // RTL memory routines
  129. //
  130. #if !defined(_WIN64)
  131. #define RtlEqualMemory(Destination,Source,Length) (!memcmp((Destination),(Source),(Length)))
  132. #endif
  133. #define RtlCompareMemory(Destination,Source,Length) memcmp((Destination),(Source),(Length))
  134. #define RtlMoveMemory(Destination,Source,Length) memmove((Destination),(Source),(Length))
  135. #define RtlCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
  136. #define RtlFillMemory(Destination,Length,Fill) memset((Destination),(Fill),(Length))
  137. #define RtlZeroMemory(Destination,Length) memset((Destination),0,(Length))
  138. #endif // RTLSTUFF_INCLUDED