From patchwork Sat Oct 16 16:04:36 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jes Sorensen X-Patchwork-Id: 68038 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 D16B7B6EED for ; Sun, 17 Oct 2010 03:06:58 +1100 (EST) Received: from localhost ([127.0.0.1]:48475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P79HO-0006ZN-QR for incoming@patchwork.ozlabs.org; Sat, 16 Oct 2010 12:06:42 -0400 Received: from [140.186.70.92] (port=59172 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P79Ff-0006Ru-53 for qemu-devel@nongnu.org; Sat, 16 Oct 2010 12:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P79Fb-0005Oc-Nn for qemu-devel@nongnu.org; Sat, 16 Oct 2010 12:04:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35181) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P79Fb-0005OP-Ha for qemu-devel@nongnu.org; Sat, 16 Oct 2010 12:04:51 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9GG4o8I028713 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 16 Oct 2010 12:04:50 -0400 Received: from localhost6.localdomain6 ([10.3.113.13]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9GG4jb5003612; Sat, 16 Oct 2010 12:04:49 -0400 From: Jes.Sorensen@redhat.com To: qemu-devel@nongnu.org Date: Sat, 16 Oct 2010 18:04:36 +0200 Message-Id: <1287245083-26110-3-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1287245083-26110-1-git-send-email-Jes.Sorensen@redhat.com> References: <1287245083-26110-1-git-send-email-Jes.Sorensen@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 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 2/9] Move osdep socket code to oslib-{posix, win32}.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 --- osdep.c | 38 -------------------------------------- oslib-posix.c | 15 +++++++++++++++ oslib-win32.c | 21 +++++++++++++++++++++ 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/osdep.c b/osdep.c index 581768a..902fce9 100644 --- a/osdep.c +++ b/osdep.c @@ -147,44 +147,6 @@ int qemu_gettimeofday(qemu_timeval *tp) #endif /* _WIN32 */ -#ifdef _WIN32 -void socket_set_nonblock(int fd) -{ - unsigned long opt = 1; - ioctlsocket(fd, FIONBIO, &opt); -} - -int inet_aton(const char *cp, struct in_addr *ia) -{ - uint32_t addr = inet_addr(cp); - if (addr == 0xffffffff) - return 0; - ia->s_addr = addr; - return 1; -} - -void qemu_set_cloexec(int fd) -{ -} - -#else - -void socket_set_nonblock(int fd) -{ - int f; - f = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, f | O_NONBLOCK); -} - -void qemu_set_cloexec(int fd) -{ - int f; - f = fcntl(fd, F_GETFD); - fcntl(fd, F_SETFD, f | FD_CLOEXEC); -} - -#endif - /* * Opens a file with FD_CLOEXEC set */ diff --git a/oslib-posix.c b/oslib-posix.c index df97304..aebe3ac 100644 --- a/oslib-posix.c +++ b/oslib-posix.c @@ -29,6 +29,7 @@ #include "config-host.h" #include "sysemu.h" #include "trace.h" +#include "qemu_socket.h" #if !defined(_POSIX_C_SOURCE) || defined(__sun__) static void *oom_check(void *ptr) @@ -72,3 +73,17 @@ void qemu_vfree(void *ptr) trace_qemu_vfree(ptr); free(ptr); } + +void socket_set_nonblock(int fd) +{ + int f; + f = fcntl(fd, F_GETFL); + fcntl(fd, F_SETFL, f | O_NONBLOCK); +} + +void qemu_set_cloexec(int fd) +{ + int f; + f = fcntl(fd, F_GETFD); + fcntl(fd, F_SETFD, f | FD_CLOEXEC); +} diff --git a/oslib-win32.c b/oslib-win32.c index 3b5245d..1ddd857 100644 --- a/oslib-win32.c +++ b/oslib-win32.c @@ -29,6 +29,7 @@ #include "config-host.h" #include "sysemu.h" #include "trace.h" +#include "qemu_socket.h" static void *oom_check(void *ptr) { @@ -71,3 +72,23 @@ void qemu_vfree(void *ptr) trace_qemu_vfree(ptr); VirtualFree(ptr, 0, MEM_RELEASE); } + +void socket_set_nonblock(int fd) +{ + unsigned long opt = 1; + ioctlsocket(fd, FIONBIO, &opt); +} + +int inet_aton(const char *cp, struct in_addr *ia) +{ + uint32_t addr = inet_addr(cp); + if (addr == 0xffffffff) { + return 0; + } + ia->s_addr = addr; + return 1; +} + +void qemu_set_cloexec(int fd) +{ +}