Selaa lähdekoodia

Add some macros.

master
Richard Nyberg 19 vuotta sitten
vanhempi
commit
dc45054fe8
1 muutettua tiedostoa jossa 13 lisäystä ja 0 poistoa
  1. +13
    -0
      btpd/queue.h

+ 13
- 0
btpd/queue.h Näytä tiedosto

@@ -28,8 +28,14 @@ struct { \

#define BTPDQ_FIRST(head) ((head)->tqh_first)

#define BTPDQ_LAST(head, headname) \
(*(((struct headname *)((head)->tqh_last))->tqh_last))

#define BTPDQ_NEXT(elm, field) ((elm)->field.tqe_next)

#define BTPDQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))

#define BTPDQ_FOREACH(var, head, field) \
for ((var) = BTPDQ_FIRST((head)); \
(var); \
@@ -51,6 +57,13 @@ struct { \
(elm)->field.tqe_prev = &BTPDQ_NEXT((listelm), field); \
} while (0)

#define BTPDQ_INSERT_BEFORE(listelm, elm, field) do { \
(elm)->field.tqe_prev = (listelm)->field.tqe_prev; \
BTPDQ_NEXT((elm), field) = (listelm); \
*(listelm)->field.tqe_prev = (elm); \
(listelm)->field.tqe_prev = &BTPDQ_NEXT((elm), field); \
} while (0)

#define BTPDQ_INSERT_HEAD(head, elm, field) do { \
if ((BTPDQ_NEXT((elm), field) = BTPDQ_FIRST((head))) != NULL) \
BTPDQ_FIRST((head))->field.tqe_prev = \


Loading…
Peruuta
Tallenna