4 * Copyright (C) 2009 Red Hat Inc.
7 * Luiz Capitulino <lcapitulino@redhat.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
17 #include "qemu-queue.h"
18 #include "qemu-common.h"
19 #include "qemu-queue.h"
21 typedef struct QListEntry
{
23 QTAILQ_ENTRY(QListEntry
) next
;
26 typedef struct QList
{
28 QTAILQ_HEAD(,QListEntry
) head
;
31 #define qlist_append(qlist, obj) \
32 qlist_append_obj(qlist, QOBJECT(obj))
34 #define QLIST_FOREACH_ENTRY(qlist, var) \
35 for ((var) = ((qlist)->head.tqh_first); \
37 (var) = ((var)->next.tqe_next))
39 static inline QObject
*qlist_entry_obj(const QListEntry
*entry
)
44 QList
*qlist_new(void);
45 QList
*qlist_copy(QList
*src
);
46 void qlist_append_obj(QList
*qlist
, QObject
*obj
);
47 void qlist_iter(const QList
*qlist
,
48 void (*iter
)(QObject
*obj
, void *opaque
), void *opaque
);
49 QObject
*qlist_pop(QList
*qlist
);
50 QObject
*qlist_peek(QList
*qlist
);
51 int qlist_empty(const QList
*qlist
);
52 size_t qlist_size(const QList
*qlist
);
53 QList
*qobject_to_qlist(const QObject
*obj
);
55 static inline const QListEntry
*qlist_first(const QList
*qlist
)
57 return QTAILQ_FIRST(&qlist
->head
);
60 static inline const QListEntry
*qlist_next(const QListEntry
*entry
)
62 return QTAILQ_NEXT(entry
, next
);