@@ -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);
+}
@@ -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)
+{
+}
@@ -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
*/