All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] linux-user: Unconditionally use pipe2() syscall
@ 2022-07-18 16:34 Helge Deller
  2022-07-18 16:38 ` Peter Maydell
  2022-07-18 19:12 ` Laurent Vivier
  0 siblings, 2 replies; 3+ messages in thread
From: Helge Deller @ 2022-07-18 16:34 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel, Peter Maydell

The pipe2() syscall is available on all Linux platforms since kernel
2.6.27, so use it unconditionally to emulate pipe() and pipe2().

Signed-off-by: Helge Deller <deller@gmx.de>

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dbebfa4a8b..b27a6552aa 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1586,21 +1586,12 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3,
 }
 #endif

-static abi_long do_pipe2(int host_pipe[], int flags)
-{
-#ifdef CONFIG_PIPE2
-    return pipe2(host_pipe, flags);
-#else
-    return -ENOSYS;
-#endif
-}
-
 static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong pipedes,
                         int flags, int is_pipe2)
 {
     int host_pipe[2];
     abi_long ret;
-    ret = is_pipe2 ? do_pipe2(host_pipe, flags) : pipe(host_pipe);
+    ret = pipe2(host_pipe, flags);

     if (is_error(ret))
         return get_errno(ret);
diff --git a/meson.build b/meson.build
index 8a8c415fc1..75aaca8462 100644
--- a/meson.build
+++ b/meson.build
@@ -2026,15 +2026,6 @@ config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + '''
   #else
   int main(void) { struct file_handle fh; return open_by_handle_at(0, &fh, 0); }
   #endif'''))
-config_host_data.set('CONFIG_PIPE2', cc.links(gnu_source_prefix + '''
-  #include <unistd.h>
-  #include <fcntl.h>
-
-  int main(void)
-  {
-      int pipefd[2];
-      return pipe2(pipefd, O_CLOEXEC);
-  }'''))
 config_host_data.set('CONFIG_POSIX_MADVISE', cc.links(gnu_source_prefix + '''
   #include <sys/mman.h>
   #include <stddef.h>


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user: Unconditionally use pipe2() syscall
  2022-07-18 16:34 [PATCH] linux-user: Unconditionally use pipe2() syscall Helge Deller
@ 2022-07-18 16:38 ` Peter Maydell
  2022-07-18 19:12 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2022-07-18 16:38 UTC (permalink / raw)
  To: Helge Deller; +Cc: Laurent Vivier, qemu-devel

On Mon, 18 Jul 2022 at 17:34, Helge Deller <deller@gmx.de> wrote:
>
> The pipe2() syscall is available on all Linux platforms since kernel
> 2.6.27, so use it unconditionally to emulate pipe() and pipe2().
>
> Signed-off-by: Helge Deller <deller@gmx.de>
>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] linux-user: Unconditionally use pipe2() syscall
  2022-07-18 16:34 [PATCH] linux-user: Unconditionally use pipe2() syscall Helge Deller
  2022-07-18 16:38 ` Peter Maydell
@ 2022-07-18 19:12 ` Laurent Vivier
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2022-07-18 19:12 UTC (permalink / raw)
  To: qemu-devel

Le 18/07/2022 à 18:34, Helge Deller a écrit :
> The pipe2() syscall is available on all Linux platforms since kernel
> 2.6.27, so use it unconditionally to emulate pipe() and pipe2().
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index dbebfa4a8b..b27a6552aa 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1586,21 +1586,12 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg2, abi_long arg3,
>   }
>   #endif
> 
> -static abi_long do_pipe2(int host_pipe[], int flags)
> -{
> -#ifdef CONFIG_PIPE2
> -    return pipe2(host_pipe, flags);
> -#else
> -    return -ENOSYS;
> -#endif
> -}
> -
>   static abi_long do_pipe(CPUArchState *cpu_env, abi_ulong pipedes,
>                           int flags, int is_pipe2)
>   {
>       int host_pipe[2];
>       abi_long ret;
> -    ret = is_pipe2 ? do_pipe2(host_pipe, flags) : pipe(host_pipe);

It doesn't apply cleanly:

It seems this patch is applied on top of the one you want to replace (is_pipe2 rather than flags).

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-18 20:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-18 16:34 [PATCH] linux-user: Unconditionally use pipe2() syscall Helge Deller
2022-07-18 16:38 ` Peter Maydell
2022-07-18 19:12 ` Laurent Vivier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.