Patchwork [01/11] linux-user: add eventfd support

login
register
mail settings
Submitter Riku Voipio
Date Aug. 13, 2009, 8:06 p.m.
Message ID <2544cbe008bf325372291aa6eea38d98892d4a13.1250193231.git.riku.voipio@iki.fi>
Download mbox | patch
Permalink /patch/31354/
State Superseded
Headers show

Comments

Riku Voipio - Aug. 13, 2009, 8:06 p.m.
From: Riku Voipio <riku.voipio@iki.fi>

Straightforward implementation. This syscall is rare enough that we
don't need to support the odder cases, just disable it if host glibc
is too old.

Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
---
 configure            |   18 ++++++++++++++++++
 linux-user/syscall.c |   13 +++++++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)
Kirill A. Shutemov - Aug. 21, 2009, 11:29 a.m.
On Thu, Aug 13, 2009 at 11:06 PM, <riku.voipio@iki.fi> wrote:
> From: Riku Voipio <riku.voipio@iki.fi>
>
> Straightforward implementation. This syscall is rare enough that we
> don't need to support the odder cases, just disable it if host glibc
> is too old.
>
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> ---
>  configure            |   18 ++++++++++++++++++
>  linux-user/syscall.c |   13 +++++++++++++
>  2 files changed, 31 insertions(+), 0 deletions(-)
>
> diff --git a/configure b/configure
> index 0b2c721..c52f1cf 100755
> --- a/configure
> +++ b/configure
> @@ -1345,6 +1345,21 @@ if compile_prog "" "" ; then
>   splice=yes
>  fi
>
> +# check if eventfd is supported
> +eventfd=no
> +cat > $TMPC << EOF
> +#include <sys/eventfd.h>
> +
> +int main(void)
> +{
> +    int efd = eventfd(0, 0);
> +    return 0;
> +}
> +EOF
> +if compile_prog "" "" ; then
> +  eventfd=yes
> +fi
> +
>  # Check if tools are available to build documentation.
>  if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
>   build_docs="no"
> @@ -1684,6 +1699,9 @@ fi
>  if test "$splice" = "yes" ; then
>   echo "CONFIG_SPLICE=y" >> $config_host_mak
>  fi
> +if test "$eventfd" = "yes" ; then
> +  echo "CONFIG_EVENTFD=y" >> $config_host_mak
> +fi
>  if test "$inotify" = "yes" ; then
>   echo "CONFIG_INOTIFY=y" >> $config_host_mak
>  fi
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 673eed4..3b1ed60 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -6974,6 +6974,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>         break;
>  #endif
>  #endif /* CONFIG_SPLICE */
> +#ifdef CONFIG_EVENTFD
> +#include <sys/eventfd.h>

I don't think that #include within function is a good idea.

> +#if defined(TARGET_NR_eventfd)
> +    case TARGET_NR_eventfd:
> +        ret = get_errno(eventfd(arg1, 0));
> +        break;
> +#endif
> +#if defined(TARGET_NR_eventfd2)
> +    case TARGET_NR_eventfd2:
> +        ret = get_errno(eventfd(arg1, arg2));
> +        break;
> +#endif
> +#endif /* CONFIG_EVENTFD  */
>     default:
>     unimplemented:
>         gemu_log("qemu: Unsupported syscall: %d\n", num);
> --
> 1.6.2.1
>
>
>
>

Patch

diff --git a/configure b/configure
index 0b2c721..c52f1cf 100755
--- a/configure
+++ b/configure
@@ -1345,6 +1345,21 @@  if compile_prog "" "" ; then
   splice=yes
 fi
 
+# check if eventfd is supported
+eventfd=no
+cat > $TMPC << EOF
+#include <sys/eventfd.h>
+
+int main(void)
+{
+    int efd = eventfd(0, 0);
+    return 0;
+}
+EOF
+if compile_prog "" "" ; then
+  eventfd=yes
+fi
+
 # Check if tools are available to build documentation.
 if test "$build_docs" = "yes" -a \( ! -x "`which texi2html 2>/dev/null`" -o ! -x "`which pod2man 2>/dev/null`" \) ; then
   build_docs="no"
@@ -1684,6 +1699,9 @@  fi
 if test "$splice" = "yes" ; then
   echo "CONFIG_SPLICE=y" >> $config_host_mak
 fi
+if test "$eventfd" = "yes" ; then
+  echo "CONFIG_EVENTFD=y" >> $config_host_mak
+fi
 if test "$inotify" = "yes" ; then
   echo "CONFIG_INOTIFY=y" >> $config_host_mak
 fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 673eed4..3b1ed60 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6974,6 +6974,19 @@  abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
 #endif
 #endif /* CONFIG_SPLICE */
+#ifdef CONFIG_EVENTFD
+#include <sys/eventfd.h>
+#if defined(TARGET_NR_eventfd)
+    case TARGET_NR_eventfd:
+        ret = get_errno(eventfd(arg1, 0));
+        break;
+#endif
+#if defined(TARGET_NR_eventfd2)
+    case TARGET_NR_eventfd2:
+        ret = get_errno(eventfd(arg1, arg2));
+        break;
+#endif
+#endif /* CONFIG_EVENTFD  */
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);