4 * Copyright IBM, Corp. 2010
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU GPL, version 2. See
10 * the COPYING file in the top-level directory.
12 * Contributions after 2012-01-13 are licensed under the terms of the
13 * GNU GPL, version 2 or (at your option) any later version.
16 #include "qemu/osdep.h"
17 #include "qemu-common.h"
18 #include "qemu/notify.h"
20 void notifier_list_init(NotifierList
*list
)
22 QLIST_INIT(&list
->notifiers
);
25 void notifier_list_add(NotifierList
*list
, Notifier
*notifier
)
27 QLIST_INSERT_HEAD(&list
->notifiers
, notifier
, node
);
30 void notifier_remove(Notifier
*notifier
)
32 QLIST_REMOVE(notifier
, node
);
35 void notifier_list_notify(NotifierList
*list
, void *data
)
37 Notifier
*notifier
, *next
;
39 QLIST_FOREACH_SAFE(notifier
, &list
->notifiers
, node
, next
) {
40 notifier
->notify(notifier
, data
);
44 void notifier_with_return_list_init(NotifierWithReturnList
*list
)
46 QLIST_INIT(&list
->notifiers
);
49 void notifier_with_return_list_add(NotifierWithReturnList
*list
,
50 NotifierWithReturn
*notifier
)
52 QLIST_INSERT_HEAD(&list
->notifiers
, notifier
, node
);
55 void notifier_with_return_remove(NotifierWithReturn
*notifier
)
57 QLIST_REMOVE(notifier
, node
);
60 int notifier_with_return_list_notify(NotifierWithReturnList
*list
, void *data
)
62 NotifierWithReturn
*notifier
, *next
;
65 QLIST_FOREACH_SAFE(notifier
, &list
->notifiers
, node
, next
) {
66 ret
= notifier
->notify(notifier
, data
);