aboutsummaryrefslogtreecommitdiff
path: root/include/qemu/queue.h
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2015-06-10 13:47:35 +0200
committerKevin Wolf <kwolf@redhat.com>2015-06-12 17:04:59 +0200
commitae81693004fd95f7013e42811944707a92948d9a (patch)
tree937270c2d5dea8ba579c74bf13014d7e7bb79030 /include/qemu/queue.h
parent6ee4ce1ee75a651c246d926c2302281b51981f6d (diff)
queue.h: Add QLIST_FIX_HEAD_PTR()
If the head of a list has been moved to a different memory location, the le_prev link in the first list entry has to be fixed up. Provide a macro that implements this fixup. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'include/qemu/queue.h')
-rw-r--r--include/qemu/queue.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/qemu/queue.h b/include/qemu/queue.h
index f781aa20a8..a8d3cb8e63 100644
--- a/include/qemu/queue.h
+++ b/include/qemu/queue.h
@@ -117,6 +117,12 @@ struct { \
} \
} while (/*CONSTCOND*/0)
+#define QLIST_FIX_HEAD_PTR(head, field) do { \
+ if ((head)->lh_first != NULL) { \
+ (head)->lh_first->field.le_prev = &(head)->lh_first; \
+ } \
+} while (/*CONSTCOND*/0)
+
#define QLIST_INSERT_AFTER(listelm, elm, field) do { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \