qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jes.Sorensen@redhat.com
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com
Subject: [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c
Date: Tue, 26 Oct 2010 10:39:20 +0200	[thread overview]
Message-ID: <1288082367-27944-3-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1288082367-27944-1-git-send-email-Jes.Sorensen@redhat.com>

From: Jes Sorensen <Jes.Sorensen@redhat.com>

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 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)
+{
+}
-- 
1.7.2.3

  parent reply	other threads:[~2010-10-26  8:39 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26  8:39 [Qemu-devel] [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files Jes.Sorensen
2010-10-26  8:39 ` Jes.Sorensen [this message]
2010-10-26  8:39 ` [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to oslib-posix.c Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions Jes.Sorensen
2010-10-26  8:39 ` [Qemu-devel] [PATCH 9/9] Remove unncessary includes Jes.Sorensen
2010-10-30  9:23 ` [Qemu-devel] Re: [PATCH v4 0/9] Re-factor osdep code + macro and brace fixes Blue Swirl
  -- strict thread matches above, loose matches on Subject: below --
2010-10-18  8:15 [Qemu-devel] [PATCH v3 " Jes.Sorensen
2010-10-18  8:15 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c Jes.Sorensen
2010-10-16 16:04 [Qemu-devel] [PATCH v2 0/9] Re-factor osdep code + macro and brace fixes Jes.Sorensen
2010-10-16 16:04 ` [Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c Jes.Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1288082367-27944-3-git-send-email-Jes.Sorensen@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).