From e709b3f78a2ae3cb4cab1222c1848797ebbe4735 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Sun, 9 Aug 2020 17:01:21 -0700 Subject: [PATCH] Define P_PIDFD, used with waitid Linux defines a waitid type `P_PIDFD`, for use with process file descriptors (`pidfd`). Add that constant. In libc-test, add linux/wait.h to the Linux-specific and Android-specific headers, to get the definition. Exclude it on Android and musl for now, though, as the versions in CI don't have it yet. --- libc-test/build.rs | 9 +++++++++ src/unix/linux_like/mod.rs | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/libc-test/build.rs b/libc-test/build.rs index 753987a5..637c46b2 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1486,6 +1486,7 @@ fn test_android(target: &str) { "linux/seccomp.h", "linux/sched.h", "linux/sockios.h", + "linux/wait.h", } @@ -1556,6 +1557,9 @@ fn test_android(target: &str) { // FIXME: deprecated - removed in glibc 2.26 "SIGUNUSED" => true, + // Needs a newer Android SDK for the definition + "P_PIDFD" => true, + _ => false, } }); @@ -2442,6 +2446,7 @@ fn test_linux(target: &str) { "linux/seccomp.h", "linux/sockios.h", "linux/vm_sockets.h", + "linux/wait.h", "sys/auxv.h", "sys/fanotify.h", } @@ -2626,6 +2631,10 @@ fn test_linux(target: &str) { // Require Linux kernel 5.6: "VMADDR_CID_LOCAL" => true, + // Defined in kernel headers but musl removes it; need musl 1.2 for definition in musl + // headers. + "P_PIDFD" => true, + _ => false, } }); diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index c5394f69..a5005ead 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -1034,6 +1034,11 @@ pub const SIGEV_THREAD: ::c_int = 2; pub const P_ALL: idtype_t = 0; pub const P_PID: idtype_t = 1; pub const P_PGID: idtype_t = 2; +cfg_if! { + if #[cfg(not(target_os = "emscripten"))] { + pub const P_PIDFD: idtype_t = 3; + } +} pub const UTIME_OMIT: c_long = 1073741822; pub const UTIME_NOW: c_long = 1073741823;