[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 13/39] event_notifier: add Win32 implementation
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PATCH v2 13/39] event_notifier: add Win32 implementation |
Date: |
Wed, 31 Oct 2012 16:30:30 +0100 |
Signed-off-by: Paolo Bonzini <address@hidden>
---
Makefile.objs | 3 +-
event_notifier.c => event_notifier-posix.c | 0
event_notifier-win32.c | 59 ++++++++++++++++++++++++++++++
event_notifier.h | 17 ++++++++-
qemu-os-win32.h | 1 -
5 file modificati, 76 inserzioni(+), 4 rimozioni(-)
rename event_notifier.c => event_notifier-posix.c (100%)
create mode 100644 event_notifier-win32.c
diff --git a/Makefile.objs b/Makefile.objs
index 54daa9f..5b39c33 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -94,7 +94,8 @@ common-obj-y += bt-host.o bt-vhci.o
common-obj-y += dma-helpers.o
common-obj-y += acl.o
common-obj-$(CONFIG_POSIX) += compatfd.o
-common-obj-y += event_notifier.o
+common-obj-$(CONFIG_POSIX) += event_notifier-posix.o
+common-obj-$(CONFIG_WIN32) += event_notifier-win32.o
common-obj-y += qemu-timer.o qemu-timer-common.o
common-obj-y += qtest.o
common-obj-y += vl.o
diff --git a/event_notifier.c b/event_notifier-posix.c
similarity index 100%
rename from event_notifier.c
rename to event_notifier-posix.c
diff --git a/event_notifier-win32.c b/event_notifier-win32.c
new file mode 100644
index 0000000..c723dad
--- /dev/null
+++ b/event_notifier-win32.c
@@ -0,0 +1,59 @@
+/*
+ * event notifier support
+ *
+ * Copyright Red Hat, Inc. 2010
+ *
+ * Authors:
+ * Michael S. Tsirkin <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+
+#include "qemu-common.h"
+#include "event_notifier.h"
+#include "main-loop.h"
+
+int event_notifier_init(EventNotifier *e, int active)
+{
+ e->event = CreateEvent(NULL, FALSE, FALSE, NULL);
+ assert(e->event);
+ return 0;
+}
+
+void event_notifier_cleanup(EventNotifier *e)
+{
+ CloseHandle(e->event);
+}
+
+HANDLE event_notifier_get_handle(EventNotifier *e)
+{
+ return e->event;
+}
+
+int event_notifier_set_handler(EventNotifier *e,
+ EventNotifierHandler *handler)
+{
+ if (handler) {
+ return qemu_add_wait_object(e->event, (IOHandler *)handler, e);
+ } else {
+ qemu_del_wait_object(e->event, (IOHandler *)handler, e);
+ return 0;
+ }
+}
+
+int event_notifier_set(EventNotifier *e)
+{
+ SetEvent(e->event);
+ return 0;
+}
+
+int event_notifier_test_and_clear(EventNotifier *e)
+{
+ int ret = WaitForSingleObject(e->event, 0);
+ if (ret == WAIT_OBJECT_0) {
+ ResetEvent(e->event);
+ return true;
+ }
+ return false;
+}
diff --git a/event_notifier.h b/event_notifier.h
index f0ec2f2..b283a49 100644
--- a/event_notifier.h
+++ b/event_notifier.h
@@ -15,18 +15,31 @@
#include "qemu-common.h"
+#ifdef _WIN32
+#include <windows.h>
+#endif
+
struct EventNotifier {
+#ifdef _WIN32
+ HANDLE event;
+#else
int fd;
+#endif
};
typedef void EventNotifierHandler(EventNotifier *);
-void event_notifier_init_fd(EventNotifier *, int fd);
int event_notifier_init(EventNotifier *, int active);
void event_notifier_cleanup(EventNotifier *);
-int event_notifier_get_fd(EventNotifier *);
int event_notifier_set(EventNotifier *);
int event_notifier_test_and_clear(EventNotifier *);
int event_notifier_set_handler(EventNotifier *, EventNotifierHandler *);
+#ifdef CONFIG_POSIX
+void event_notifier_init_fd(EventNotifier *, int fd);
+int event_notifier_get_fd(EventNotifier *);
+#else
+HANDLE event_notifier_get_handle(EventNotifier *);
+#endif
+
#endif
diff --git a/qemu-os-win32.h b/qemu-os-win32.h
index 8ba466d..d0e9234 100644
--- a/qemu-os-win32.h
+++ b/qemu-os-win32.h
@@ -28,7 +28,6 @@
#include <windows.h>
#include <winsock2.h>
-#include "main-loop.h"
/* Workaround for older versions of MinGW. */
#ifndef ECONNREFUSED
--
1.7.12.1
- [Qemu-devel] [PATCH v2 33/39] threadpool: do not take lock in event_notifier_ready, (continued)
- [Qemu-devel] [PATCH v2 33/39] threadpool: do not take lock in event_notifier_ready, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 32/39] aio: add generic thread-pool facility, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 34/39] block: switch posix-aio-compat to threadpool, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 35/39] raw: merge posix-aio-compat.c into block/raw-posix.c, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 36/39] raw-posix: rename raw-posix-aio.h, hide unavailable prototypes, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 37/39] raw-win32: add emulated AIO support, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 30/39] linux-aio: use event notifiers, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 14/39] event_notifier: enable it to use pipes, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 15/39] vl: init main loop earlier, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 31/39] qemu-thread: add QemuSemaphore, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 13/39] event_notifier: add Win32 implementation,
Paolo Bonzini <=
- [Qemu-devel] [PATCH v2 28/39] main-loop: use aio_notify for qemu_notify_event, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 16/39] aio: change qemu_aio_set_fd_handler to return void, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 26/39] aio: call aio_notify after setting I/O handlers, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 19/39] aio: add I/O handlers to the AioContext interface, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 39/39] raw-win32: implement native asynchronous I/O, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 38/39] raw-posix: move linux-aio.c to block/, Paolo Bonzini, 2012/10/31
- [Qemu-devel] [PATCH v2 18/39] aio: introduce AioContext, move bottom halves there, Paolo Bonzini, 2012/10/31