target-arm: implement BE32 mode in system emulation
[qemu/ar7.git] / util / notify.c
blob06de63a839a15b98b8a2d17c33a17e8f4677ee54
1 /*
2 * Notifier lists
4 * Copyright IBM, Corp. 2010
6 * Authors:
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;
63 int ret = 0;
65 QLIST_FOREACH_SAFE(notifier, &list->notifiers, node, next) {
66 ret = notifier->notify(notifier, data);
67 if (ret != 0) {
68 break;
71 return ret;