From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=38679 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P6l9v-0004AV-HX for qemu-devel@nongnu.org; Fri, 15 Oct 2010 10:21:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P6kv2-0007ik-28 for qemu-devel@nongnu.org; Fri, 15 Oct 2010 10:06:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49791) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P6kv1-0007iU-Rh for qemu-devel@nongnu.org; Fri, 15 Oct 2010 10:06:00 -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 o9FE5xpl026442 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 15 Oct 2010 10:05:59 -0400 Received: from localhost6.localdomain6 (ovpn-113-85.phx2.redhat.com [10.3.113.85]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id o9FE5tSl014808 for ; Fri, 15 Oct 2010 10:05:58 -0400 From: Jes.Sorensen@redhat.com Date: Fri, 15 Oct 2010 16:05:46 +0200 Message-Id: <1287151553-16894-3-git-send-email-Jes.Sorensen@redhat.com> In-Reply-To: <1287151553-16894-1-git-send-email-Jes.Sorensen@redhat.com> References: <1287151553-16894-1-git-send-email-Jes.Sorensen@redhat.com> Subject: [Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Jes Sorensen Signed-off-by: Jes Sorensen --- os-posix-lib.c | 15 +++++++++++++++ os-win32-lib.c | 21 +++++++++++++++++++++ osdep.c | 38 -------------------------------------- 3 files changed, 36 insertions(+), 38 deletions(-) diff --git a/os-posix-lib.c b/os-posix-lib.c index 83e5101..79f9bac 100644 --- a/os-posix-lib.c +++ b/os-posix-lib.c @@ -31,6 +31,7 @@ #include "trace.h" #include "net/slirp.h" #include "qemu-options.h" +#include "qemu_socket.h" void *qemu_memalign(size_t alignment, size_t size) { @@ -63,3 +64,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/os-win32-lib.c b/os-win32-lib.c index 80e713a..e7419e5 100644 --- a/os-win32-lib.c +++ b/os-win32-lib.c @@ -36,6 +36,7 @@ #include "sysemu.h" #include "trace.h" #include "qemu-options.h" +#include "qemu_socket.h" void *qemu_memalign(size_t alignment, size_t size) { @@ -69,3 +70,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) +{ +} diff --git a/osdep.c b/osdep.c index 785fa4d..bc95bdd 100644 --- a/osdep.c +++ b/osdep.c @@ -162,44 +162,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 */ -- 1.7.2.3