[Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@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 == 0x) - 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 == 0x) { + return 0; +} +ia-s_addr = addr; +return 1; +} + +void qemu_set_cloexec(int fd) +{ +} -- 1.7.2.3
[Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@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 == 0x) - 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 == 0x) { + return 0; +} +ia-s_addr = addr; +return 1; +} + +void qemu_set_cloexec(int fd) +{ +} -- 1.7.2.3
[Qemu-devel] [PATCH 2/9] Move osdep socket code to oslib-{posix, win32}.c
From: Jes Sorensen jes.soren...@redhat.com Signed-off-by: Jes Sorensen jes.soren...@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 == 0x) - 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 == 0x) { + return 0; +} +ia-s_addr = addr; +return 1; +} + +void qemu_set_cloexec(int fd) +{ +} -- 1.7.2.3