From 949d31e665e9847b2a8f24a916abd96e79353535 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 26 Oct 2010 10:39:22 +0200 Subject: [PATCH] We only support eventfd under POSIX, move qemu_eventfd() to os-posix.c Signed-off-by: Jes Sorensen Signed-off-by: Blue Swirl --- os-posix.c | 32 ++++++++++++++++++++++++++++++++ osdep.c | 34 ---------------------------------- 2 files changed, 32 insertions(+), 34 deletions(-) diff --git a/os-posix.c b/os-posix.c index 6321e990c5..612b641737 100644 --- a/os-posix.c +++ b/os-posix.c @@ -43,6 +43,10 @@ #include #endif +#ifdef CONFIG_EVENTFD +#include +#endif + static struct passwd *user_pwd; static const char *chroot_dir; static int daemonize; @@ -329,3 +333,31 @@ void os_set_line_buffering(void) { setvbuf(stdout, NULL, _IOLBF, 0); } + +/* + * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set. + */ +int qemu_eventfd(int fds[2]) +{ +#ifdef CONFIG_EVENTFD + int ret; + + ret = eventfd(0, 0); + if (ret >= 0) { + fds[0] = ret; + qemu_set_cloexec(ret); + if ((fds[1] = dup(ret)) == -1) { + close(ret); + return -1; + } + qemu_set_cloexec(fds[1]); + return 0; + } + + if (errno != ENOSYS) { + return -1; + } +#endif + + return qemu_pipe(fds); +} diff --git a/osdep.c b/osdep.c index 926c8adb68..cb12e5f892 100644 --- a/osdep.c +++ b/osdep.c @@ -44,10 +44,6 @@ extern int madvise(caddr_t, size_t, int); #endif -#ifdef CONFIG_EVENTFD -#include -#endif - #ifdef _WIN32 #include #elif defined(CONFIG_BSD) @@ -207,36 +203,6 @@ ssize_t qemu_write_full(int fd, const void *buf, size_t count) return total; } -#ifndef _WIN32 -/* - * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set. - */ -int qemu_eventfd(int fds[2]) -{ -#ifdef CONFIG_EVENTFD - int ret; - - ret = eventfd(0, 0); - if (ret >= 0) { - fds[0] = ret; - qemu_set_cloexec(ret); - if ((fds[1] = dup(ret)) == -1) { - close(ret); - return -1; - } - qemu_set_cloexec(fds[1]); - return 0; - } - - if (errno != ENOSYS) { - return -1; - } -#endif - - return qemu_pipe(fds); -} -#endif - /* * Opens a socket with FD_CLOEXEC set */