[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib
From: |
Jes . Sorensen |
Subject: |
[Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c |
Date: |
Fri, 15 Oct 2010 16:05:46 +0200 |
From: Jes Sorensen <address@hidden>
Signed-off-by: Jes Sorensen <address@hidden>
---
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
- [Qemu-devel] [PATCH 0/9] Re-factor osdep code + macro and brace fixes, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 9/9] Remove unncessary includes, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 8/9] Consolidate oom_check() functions, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 4/9] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 7/9] Separate qemu_pidfile() into OS specific versions, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 6/9] Do not redefine reserved key-words TRUE/FALSE, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 5/9] Move qemu_gettimeofday() to OS specific files, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 2/9] Move osdep socket code to os-{posix, win32}-lib.c,
Jes . Sorensen <=
- [Qemu-devel] [PATCH 3/9] qemu_pipe() is used only by POSIX code, so move to os-posix-lib.c, Jes . Sorensen, 2010/10/15
- [Qemu-devel] [PATCH 1/9] Move QEMU OS dependant library functions to OS specific files, Jes . Sorensen, 2010/10/15
- [Qemu-devel] Re: [PATCH 0/9] Re-factor osdep code + macro and brace fixes, Paolo Bonzini, 2010/10/15