]> git.proxmox.com Git - mirror_qemu.git/blame - qlist.h
isa: always use provided ISA bus when creating an isa device
[mirror_qemu.git] / qlist.h
CommitLineData
a6fd08eb 1/*
41836a9f 2 * QList Module
a6fd08eb
LC
3 *
4 * Copyright (C) 2009 Red Hat Inc.
5 *
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.com>
8 *
41836a9f
LC
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.
a6fd08eb 11 */
41836a9f 12
a6fd08eb
LC
13#ifndef QLIST_H
14#define QLIST_H
15
16#include "qobject.h"
17#include "qemu-queue.h"
18#include "qemu-common.h"
54d83804 19#include "qemu-queue.h"
a6fd08eb
LC
20
21typedef struct QListEntry {
22 QObject *value;
23 QTAILQ_ENTRY(QListEntry) next;
24} QListEntry;
25
26typedef struct QList {
27 QObject_HEAD;
28 QTAILQ_HEAD(,QListEntry) head;
29} QList;
30
31#define qlist_append(qlist, obj) \
32 qlist_append_obj(qlist, QOBJECT(obj))
33
59eb1c85
LC
34#define QLIST_FOREACH_ENTRY(qlist, var) \
35 for ((var) = ((qlist)->head.tqh_first); \
36 (var); \
37 (var) = ((var)->next.tqe_next))
38
39static inline QObject *qlist_entry_obj(const QListEntry *entry)
40{
41 return entry->value;
42}
43
a6fd08eb 44QList *qlist_new(void);
033815fe 45QList *qlist_copy(QList *src);
a6fd08eb
LC
46void qlist_append_obj(QList *qlist, QObject *obj);
47void qlist_iter(const QList *qlist,
48 void (*iter)(QObject *obj, void *opaque), void *opaque);
033815fe
AL
49QObject *qlist_pop(QList *qlist);
50QObject *qlist_peek(QList *qlist);
51int qlist_empty(const QList *qlist);
a6fd08eb
LC
52QList *qobject_to_qlist(const QObject *obj);
53
54d83804
MR
54static inline const QListEntry *qlist_first(const QList *qlist)
55{
56 return QTAILQ_FIRST(&qlist->head);
57}
58
59static inline const QListEntry *qlist_next(const QListEntry *entry)
60{
61 return QTAILQ_NEXT(entry, next);
62}
63
a6fd08eb 64#endif /* QLIST_H */