A clone of btpd with my configuration changes.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

100 lignes
4.7 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_FOREACH_MUTABLE(var, head, field, nvar) \
  34. for ((var) = BTPDQ_FIRST((head)); \
  35. (var) && ((nvar) = BTPDQ_NEXT((var), field), (var)); \
  36. (var) = (nvar))
  37. #define BTPDQ_INIT(head) do { \
  38. BTPDQ_FIRST((head)) = NULL; \
  39. (head)->tqh_last = &BTPDQ_FIRST((head)); \
  40. } while (0)
  41. #define BTPDQ_INSERT_AFTER(head, listelm, elm, field) do { \
  42. if ((BTPDQ_NEXT((elm), field) = BTPDQ_NEXT((listelm), field)) != NULL)\
  43. BTPDQ_NEXT((elm), field)->field.tqe_prev = \
  44. &BTPDQ_NEXT((elm), field); \
  45. else { \
  46. (head)->tqh_last = &BTPDQ_NEXT((elm), field); \
  47. } \
  48. BTPDQ_NEXT((listelm), field) = (elm); \
  49. (elm)->field.tqe_prev = &BTPDQ_NEXT((listelm), field); \
  50. } while (0)
  51. #define BTPDQ_INSERT_BEFORE(listelm, elm, field) do { \
  52. (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
  53. BTPDQ_NEXT((elm), field) = (listelm); \
  54. *(listelm)->field.tqe_prev = (elm); \
  55. (listelm)->field.tqe_prev = &BTPDQ_NEXT((elm), field); \
  56. } while (0)
  57. #define BTPDQ_INSERT_HEAD(head, elm, field) do { \
  58. if ((BTPDQ_NEXT((elm), field) = BTPDQ_FIRST((head))) != NULL) \
  59. BTPDQ_FIRST((head))->field.tqe_prev = \
  60. &BTPDQ_NEXT((elm), field); \
  61. else \
  62. (head)->tqh_last = &BTPDQ_NEXT((elm), field); \
  63. BTPDQ_FIRST((head)) = (elm); \
  64. (elm)->field.tqe_prev = &BTPDQ_FIRST((head)); \
  65. } while (0)
  66. #define BTPDQ_INSERT_TAIL(head, elm, field) do { \
  67. BTPDQ_NEXT((elm), field) = NULL; \
  68. (elm)->field.tqe_prev = (head)->tqh_last; \
  69. *(head)->tqh_last = (elm); \
  70. (head)->tqh_last = &BTPDQ_NEXT((elm), field); \
  71. } while (0)
  72. #define BTPDQ_REMOVE(head, elm, field) do { \
  73. if ((BTPDQ_NEXT((elm), field)) != NULL) \
  74. BTPDQ_NEXT((elm), field)->field.tqe_prev = \
  75. (elm)->field.tqe_prev; \
  76. else { \
  77. (head)->tqh_last = (elm)->field.tqe_prev; \
  78. } \
  79. *(elm)->field.tqe_prev = BTPDQ_NEXT((elm), field); \
  80. } while (0)
  81. #endif