]> git.sur5r.net Git - i3/i3/blobdiff - include/queue.h
Merge branch 'master' into next
[i3/i3] / include / queue.h
index 75bb957aec793b66a6da6763a8d205f7e3e4fe42..0c6852150e5bf60b77333254e17ddd7d5440369b 100644 (file)
@@ -407,6 +407,19 @@ struct {                                                           \
        _Q_INVALIDATE((elm)->field.tqe_next);                           \
 } while (0)
 
+/* Swaps two consecutive elements. 'second' *MUST* follow 'first' */
+#define TAILQ_SWAP(first, second, head, field) do {                    \
+       *((first)->field.tqe_prev) = (second);                          \
+       (second)->field.tqe_prev = (first)->field.tqe_prev;             \
+       (first)->field.tqe_prev = &((second)->field.tqe_next);          \
+       (first)->field.tqe_next = (second)->field.tqe_next;             \
+       if ((second)->field.tqe_next)                                   \
+               (second)->field.tqe_next->field.tqe_prev = &((first)->field.tqe_next); \
+       (second)->field.tqe_next = first;                               \
+       if ((head)->tqh_last == &((second)->field.tqe_next))            \
+               (head)->tqh_last = &((first)->field.tqe_next);          \
+} while (0)
+
 /*
  * Circular queue definitions.
  */