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.

110 lines
4.2 KiB

  1. /***************************************************************************
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. QUEUE.H
  5. Abstract:
  6. Queueing routines used for lists of transmit, receive, and request "frames"
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  11. KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  12. IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
  13. PURPOSE.
  14. Copyright (c) 1999 Microsoft Corporation. All Rights Reserved.
  15. Revision History:
  16. 5/20/99 : created
  17. Author:
  18. Tom Green
  19. ****************************************************************************/
  20. #ifndef _QUEUE_H_
  21. #define _QUEUE_H_
  22. // QueueInitList - Macro which will initialize a queue to NULL
  23. #define QueueInitList(_L) (_L)->Link.Flink = (_L)->Link.Blink = (PLIST_ENTRY)NULL;
  24. // QueueEmpty - Macro which checks to see if a queue is empty
  25. #define QueueEmpty(_L) (QueueGetHead((_L)) == (PRNDISMP_LIST_ENTRY) NULL)
  26. // QueueGetHead - Macro which returns the head of the queue, but does not
  27. // remove the head from the queue
  28. #define QueueGetHead(_L) ((PRNDISMP_LIST_ENTRY)((_L)->Link.Flink))
  29. // QueuePushHead - Macro which puts an element at the head of the queue
  30. #define QueuePushHead(_L, _E) \
  31. { \
  32. ASSERT(_L); \
  33. ASSERT(_E); \
  34. if(!((_E)->Link.Flink = (_L)->Link.Flink)) \
  35. { \
  36. (_L)->Link.Blink = (PLIST_ENTRY)(_E); \
  37. } \
  38. (_L)->Link.Flink = (PLIST_ENTRY)(_E); \
  39. }
  40. // QueueRemoveHead - Macro which removes the head of queue
  41. #define QueueRemoveHead(_L) \
  42. { \
  43. PRNDISMP_LIST_ENTRY ListElem; \
  44. ASSERT((_L)); \
  45. if(ListElem = (PRNDISMP_LIST_ENTRY)(_L)->Link.Flink) \
  46. { \
  47. if(!((_L)->Link.Flink = ListElem->Link.Flink)) \
  48. (_L)->Link.Blink = (PLIST_ENTRY) NULL; \
  49. } \
  50. }
  51. // QueuePutTail - Macro which puts an element at the tail (end) of the queue
  52. #define QueuePutTail(_L, _E) \
  53. { \
  54. ASSERT(_L); \
  55. ASSERT(_E); \
  56. if((_L)->Link.Blink) \
  57. { \
  58. ((PRNDISMP_LIST_ENTRY) \
  59. (_L)->Link.Blink)->Link.Flink = \
  60. (PLIST_ENTRY)(_E); \
  61. (_L)->Link.Blink = (PLIST_ENTRY)(_E); \
  62. } \
  63. else \
  64. { \
  65. (_L)->Link.Flink = \
  66. (_L)->Link.Blink = (PLIST_ENTRY)(_E); \
  67. } \
  68. (_E)->Link.Flink = (PLIST_ENTRY) NULL; \
  69. }
  70. // QueueGetTail - Macro which returns the tail of the queue, but
  71. // does not remove the tail from the queue
  72. #define QueueGetTail(_L) ((PRNDISMP_LIST_ENTRY)((_L)->Link.Blink))
  73. // QueuePopHead -- Macro which will pop the head off of a queue (list), and
  74. // return it (this differs only from queueremovehead only in the 1st line)
  75. #define QueuePopHead(_L) \
  76. (PRNDISMP_LIST_ENTRY) (_L)->Link.Flink; QueueRemoveHead(_L);
  77. #endif // _QUEUE_H_