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.
17 #include "qemu/queue.h"
19 typedef struct Notifier Notifier
;
23 void (*notify
)(Notifier
*notifier
, void *data
);
24 QLIST_ENTRY(Notifier
) node
;
27 typedef struct NotifierList
29 QLIST_HEAD(, Notifier
) notifiers
;
32 #define NOTIFIER_LIST_INITIALIZER(head) \
33 { QLIST_HEAD_INITIALIZER((head).notifiers) }
35 void notifier_list_init(NotifierList
*list
);
37 void notifier_list_add(NotifierList
*list
, Notifier
*notifier
);
39 void notifier_remove(Notifier
*notifier
);
41 void notifier_list_notify(NotifierList
*list
, void *data
);
43 /* Same as Notifier but allows .notify() to return errors */
44 typedef struct NotifierWithReturn NotifierWithReturn
;
46 struct NotifierWithReturn
{
48 * Return 0 on success (next notifier will be invoked), otherwise
49 * notifier_with_return_list_notify() will stop and return the value.
51 int (*notify
)(NotifierWithReturn
*notifier
, void *data
);
52 QLIST_ENTRY(NotifierWithReturn
) node
;
55 typedef struct NotifierWithReturnList
{
56 QLIST_HEAD(, NotifierWithReturn
) notifiers
;
57 } NotifierWithReturnList
;
59 #define NOTIFIER_WITH_RETURN_LIST_INITIALIZER(head) \
60 { QLIST_HEAD_INITIALIZER((head).notifiers) }
62 void notifier_with_return_list_init(NotifierWithReturnList
*list
);
64 void notifier_with_return_list_add(NotifierWithReturnList
*list
,
65 NotifierWithReturn
*notifier
);
67 void notifier_with_return_remove(NotifierWithReturn
*notifier
);
69 int notifier_with_return_list_notify(NotifierWithReturnList
*list
,