From patchwork Mon Oct 18 08:15:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 68140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 63A83B70FD for ; Mon, 18 Oct 2010 19:31:18 +1100 (EST) Received: from localhost ([127.0.0.1]:52278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7l7h-00027K-MH for incoming@patchwork.ozlabs.org; Mon, 18 Oct 2010 04:31:13 -0400 Received: from [140.186.70.92] (port=55265 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P7kt4-0003vp-LY for qemu-devel@nongnu.org; Mon, 18 Oct 2010 04:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P7kt3-0000wB-G9 for qemu-devel@nongnu.org; Mon, 18 Oct 2010 04:16:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P7kt3-0000w3-9w for qemu-devel@nongnu.org; Mon, 18 Oct 2010 04:16:05 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9I8G3rP020511 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 18 Oct 2010 04:16:04 -0400 Received: from localhost6.localdomain6 (ovpn-113-37.phx2.redhat.com [10.3.113.37]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9I8FuO4012414; Mon, 18 Oct 2010 04:16:02 -0400 From: Jes.Sorensen@redhat.com To: qemu-devel@nongnu.org Date: Mon, 18 Oct 2010 10:15:49 +0200 Message-Id: <1287389754-985-5-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1287389754-985-1-git-send-email-Jes.Sorensen@redhat.com> References: <1287389754-985-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: blauwirbel@gmail.com, pbonzini@redhat.com Subject: [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jes Sorensen Signed-off-by: Jes Sorensen --- os-posix.c | 32 ++++++++++++++++++++++++++++++++ osdep.c | 34 ---------------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/os-posix.c b/os-posix.c index 6321e99..612b641 100644 --- a/os-posix.c +++ b/os-posix.c @@ -43,6 +43,10 @@ #include #endif +#ifdef CONFIG_EVENTFD +#include +#endif + static struct passwd *user_pwd; static const char *chroot_dir; static int daemonize; @@ -329,3 +333,31 @@ void os_set_line_buffering(void) { setvbuf(stdout, NULL, _IOLBF, 0); } + +/* + * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set. + */ +int qemu_eventfd(int fds[2]) +{ +#ifdef CONFIG_EVENTFD + int ret; + + ret = eventfd(0, 0); + if (ret >= 0) { + fds[0] = ret; + qemu_set_cloexec(ret); + if ((fds[1] = dup(ret)) == -1) { + close(ret); + return -1; + } + qemu_set_cloexec(fds[1]); + return 0; + } + + if (errno != ENOSYS) { + return -1; + } +#endif + + return qemu_pipe(fds); +} diff --git a/osdep.c b/osdep.c index 926c8ad..cb12e5f 100644 --- a/osdep.c +++ b/osdep.c @@ -44,10 +44,6 @@ extern int madvise(caddr_t, size_t, int); #endif -#ifdef CONFIG_EVENTFD -#include -#endif - #ifdef _WIN32 #include #elif defined(CONFIG_BSD) @@ -207,36 +203,6 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count) return total; } -#ifndef _WIN32 -/* - * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set. - */ -int qemu_eventfd(int fds[2]) -{ -#ifdef CONFIG_EVENTFD - int ret; - - ret = eventfd(0, 0); - if (ret >= 0) { - fds[0] = ret; - qemu_set_cloexec(ret); - if ((fds[1] = dup(ret)) == -1) { - close(ret); - return -1; - } - qemu_set_cloexec(fds[1]); - return 0; - } - - if (errno != ENOSYS) { - return -1; - } -#endif - - return qemu_pipe(fds); -} -#endif - /* * Opens a socket with FD_CLOEXEC set */