Skip to contentSkip to conversation

linux-user: Unconditionally use pipe2() syscall

PATCH Applied Helge Deller 2 participants 2 messages Jul 19, 2022 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 linux-user: Unconditionally use pipe2() syscall

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

---
Changes in v2:
- added Reviewed-by: from Peter
- new diff against git head
- no functional changes

linux-user/syscall.c +1 -10
index 991b85e6b4..4f89184d05 100644
@@ -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 = flags ? do_pipe2(host_pipe, flags) : pipe(host_pipe);
+    ret = pipe2(host_pipe, flags);
 
     if (is_error(ret))
         return get_errno(ret);
meson.build +0 -9
index 8a8c415fc1..75aaca8462 100644
@@ -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>
#1 lore raw

Le 19/07/2022 à 18:20, Helge Deller a écrit :

Quoted 49 lines

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

---
Changes in v2:
- added Reviewed-by: from Peter
- new diff against git head
- no functional changes

linux-user/syscall.c +1 -10
index 991b85e6b4..4f89184d05 100644
@@ -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 = flags ? do_pipe2(host_pipe, flags) : pipe(host_pipe);
+    ret = pipe2(host_pipe, flags);
 
      if (is_error(ret))
          return get_errno(ret);
meson.build +0 -2
index 8a8c415fc1..75aaca8462 100644
@@ -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>

meson.build config_host_data.set('CONFIG_OPEN_BY_HANDLE', cc.links(gnu_source_prefix + ''' · line 2031

Quoted 10 lines
meson.build +0 -7
-  #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>

Applied to my linux-user-for-7.1 branch.

Thanks,
Laurent