Skip to content

Commit

Permalink
queue.h: Add QLIST_FIX_HEAD_PTR()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kevmw committed Jun 12, 2015
1 parent 6ee4ce1 commit ae81693
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/qemu/queue.h
Expand Up @@ -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 = \
Expand Down

0 comments on commit ae81693

Please sign in to comment.