From patchwork Wed Oct 31 15:30:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 195936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9641C2C0147 for ; Thu, 1 Nov 2012 03:38:24 +1100 (EST) Received: from localhost ([::1]:50317 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTbJ8-0003eN-QC for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2012 12:38:22 -0400 Received: from eggs.gnu.org ([208.118.235.92]:46335) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTaGy-0007vy-7z for qemu-devel@nongnu.org; Wed, 31 Oct 2012 11:32:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTaGt-0005Bw-SD for qemu-devel@nongnu.org; Wed, 31 Oct 2012 11:32:04 -0400 Received: from mail-da0-f45.google.com ([209.85.210.45]:60852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTaGt-0004wc-MU for qemu-devel@nongnu.org; Wed, 31 Oct 2012 11:31:59 -0400 Received: by mail-da0-f45.google.com with SMTP id n15so666382dad.4 for ; Wed, 31 Oct 2012 08:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=vCV4hFvQH5xgU3AvVoRi+dL1tGHVVamHhr0sk8vHspY=; b=JVm0nkkhEyi3WTpxoLfMhENW3MSexKUGhXRrY9lu+vfcYQgqq4KJugzXqHy7UTQ+xI G3u8fgIy+iTmuBdlPJaW9uWXqRqozcdSZyOsOB0e2JhKmzEj311xavPYiRt4Xt65Kbe0 6pMUoLIm89nEXRKGkR6mawt1fRtXo8r3oeoAyr4Xw4r7RA5FizoNuXfef1pd3NPaFX3n K36g/aotETWj3lA17r1omMfbt7R2bC+cA6b7V8d6z2MCtOEI4pqQiU/TtF0Cgf2klea0 TUYlkTVHTghLteuTkd0d+QwtLOHURCDBXRlIZO9DUMfIN6Oayc6IILboLyYfti2ZezH6 lJJQ== Received: by 10.68.232.131 with SMTP id to3mr114491911pbc.58.1351697519270; Wed, 31 Oct 2012 08:31:59 -0700 (PDT) Received: from yakj.usersys.redhat.com (93-34-169-1.ip50.fastwebnet.it. [93.34.169.1]) by mx.google.com with ESMTPS id sz6sm2445230pbc.52.2012.10.31.08.31.55 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 08:31:58 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Wed, 31 Oct 2012 16:30:30 +0100 Message-Id: <1351697456-16107-14-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.7.12.1 In-Reply-To: <1351697456-16107-1-git-send-email-pbonzini@redhat.com> References: <1351697456-16107-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.210.45 Cc: aliguori@us.ibm.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH v2 13/39] event_notifier: add Win32 implementation X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Paolo Bonzini --- 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 + * + * 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 +#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 #include -#include "main-loop.h" /* Workaround for older versions of MinGW. */ #ifndef ECONNREFUSED