A clone of btpd with my configuration changes.
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

95 wiersze
2.8 KiB

  1. /*
  2. * @(#)queue.h 8.5 (Berkeley) 8/20/94
  3. * $FreeBSD: src/sys/sys/queue.h,v 1.58.2.1 2005/01/31 23:26:57 imp Exp $
  4. */
  5. #ifndef BTPD_QUEUE_H
  6. #define BTPD_QUEUE_H
  7. /*
  8. * Tail queue declarations.
  9. */
  10. #define BTPDQ_HEAD(name, type) \
  11. struct name { \
  12. struct type *tqh_first; /* first element */ \
  13. struct type **tqh_last; /* addr of last next element */ \
  14. }
  15. #define BTPDQ_HEAD_INITIALIZER(head) \
  16. { NULL, &(head).tqh_first }
  17. #define BTPDQ_ENTRY(type) \
  18. struct { \
  19. struct type *tqe_next; /* next element */ \
  20. struct type **tqe_prev; /* address of previous next element */ \
  21. }
  22. #define BTPDQ_EMPTY(head) ((head)->tqh_first == NULL)
  23. #define BTPDQ_FIRST(head) ((head)->tqh_first)
  24. #define BTPDQ_LAST(head, headname) \
  25. (*(((struct headname *)((head)->tqh_last))->tqh_last))
  26. #define BTPDQ_NEXT(elm, field) ((elm)->field.tqe_next)
  27. #define BTPDQ_PREV(elm, headname, field) \
  28. (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
  29. #define BTPDQ_FOREACH(var, head, field) \
  30. for ((var) = BTPDQ_FIRST((head)); \
  31. (var); \
  32. (var) = BTPDQ_NEXT((var), field))
  33. #define BTPDQ_INIT(head) do { \
  34. BTPDQ_FIRST((head)) = NULL; \
  35. (head)->tqh_last = &BTPDQ_FIRST((head)); \
  36. } while (0)
  37. #define BTPDQ_INSERT_AFTER(head, listelm, elm, field) do { \
  38. if ((BTPDQ_NEXT((elm), field) = BTPDQ_NEXT((listelm), field)) != NULL)\
  39. BTPDQ_NEXT((elm), field)->field.tqe_prev = \
  40. &BTPDQ_NEXT((elm), field); \
  41. else { \
  42. (head)->tqh_last = &BTPDQ_NEXT((elm), field); \
  43. } \
  44. BTPDQ_NEXT((listelm), field) = (elm); \
  45. (elm)->field.tqe_prev = &BTPDQ_NEXT((listelm), field); \
  46. } while (0)
  47. #define BTPDQ_INSERT_BEFORE(listelm, elm, field) do { \
  48. (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
  49. BTPDQ_NEXT((elm), field) = (listelm); \
  50. *(listelm)->field.tqe_prev = (elm); \
  51. (listelm)->field.tqe_prev = &BTPDQ_NEXT((elm), field); \
  52. } while (0)
  53. #define BTPDQ_INSERT_HEAD(head, elm, field) do { \
  54. if ((BTPDQ_NEXT((elm), field) = BTPDQ_FIRST((head))) != NULL) \
  55. BTPDQ_FIRST((head))->field.tqe_prev = \
  56. &BTPDQ_NEXT((elm), field); \
  57. else \
  58. (head)->tqh_last = &BTPDQ_NEXT((elm), field); \
  59. BTPDQ_FIRST((head)) = (elm); \
  60. (elm)->field.tqe_prev = &BTPDQ_FIRST((head)); \
  61. } while (0)
  62. #define BTPDQ_INSERT_TAIL(head, elm, field) do { \
  63. BTPDQ_NEXT((elm), field) = NULL; \
  64. (elm)->field.tqe_prev = (head)->tqh_last; \
  65. *(head)->tqh_last = (elm); \
  66. (head)->tqh_last = &BTPDQ_NEXT((elm), field); \
  67. } while (0)
  68. #define BTPDQ_REMOVE(head, elm, field) do { \
  69. if ((BTPDQ_NEXT((elm), field)) != NULL) \
  70. BTPDQ_NEXT((elm), field)->field.tqe_prev = \
  71. (elm)->field.tqe_prev; \
  72. else { \
  73. (head)->tqh_last = (elm)->field.tqe_prev; \
  74. } \
  75. *(elm)->field.tqe_prev = BTPDQ_NEXT((elm), field); \
  76. } while (0)
  77. #endif