qcow2: Repair unaligned preallocated zero clusters
[qemu/ar7.git] / util / event_notifier-win32.c
blobeff86701ad951224c84891f0b240b18598600d60
1 /*
2 * event notifier support
4 * Copyright Red Hat, Inc. 2010
6 * Authors:
7 * Michael S. Tsirkin <mst@redhat.com>
9 * This work is licensed under the terms of the GNU GPL, version 2 or later.
10 * See the COPYING file in the top-level directory.
13 #include "qemu/osdep.h"
14 #include "qemu-common.h"
15 #include "qemu/event_notifier.h"
16 #include "qemu/main-loop.h"
18 int event_notifier_init(EventNotifier *e, int active)
20 e->event = CreateEvent(NULL, TRUE, FALSE, NULL);
21 assert(e->event);
22 e->cleanup = NULL;
23 return 0;
26 void event_notifier_cleanup(EventNotifier *e)
28 CloseHandle(e->event);
29 e->event = NULL;
30 e->cleanup = NULL;
33 HANDLE event_notifier_get_handle(EventNotifier *e)
35 return e->event;
38 int event_notifier_set(EventNotifier *e)
40 SetEvent(e->event);
41 return 0;
44 int event_notifier_test_and_clear(EventNotifier *e)
46 int ret = WaitForSingleObject(e->event, 0);
47 if (ret == WAIT_OBJECT_0) {
48 ResetEvent(e->event);
49 return true;
51 return false;