about summary refs log tree commit diff
path: root/library/std/src/os/unix/process.rs
diff options
context:
space:
mode:
authorFlorian Bartels <Florian.Bartels@elektrobit.com>2023-01-10 10:44:05 +0100
committerFlorian Bartels <Florian.Bartels@elektrobit.com>2023-02-28 15:59:47 +0100
commit3ce2cd059f8f7c69d9e1fe26b95cec2bfd3c98a7 (patch)
treed5944496239e8b36be6d55fac7c285a6a12a3e48 /library/std/src/os/unix/process.rs
parent8f41570e91fcbad2f55800f2edcdea67c3389dc7 (diff)
downloadrust-3ce2cd059f8f7c69d9e1fe26b95cec2bfd3c98a7.tar.gz
rust-3ce2cd059f8f7c69d9e1fe26b95cec2bfd3c98a7.zip
Add QNX Neutrino support to libstd
Co-authored-by: gh-tr <troach@qnx.com>
Diffstat (limited to 'library/std/src/os/unix/process.rs')
-rw-r--r--library/std/src/os/unix/process.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/library/std/src/os/unix/process.rs b/library/std/src/os/unix/process.rs
index 09b2bfe39f0..729c63d184f 100644
--- a/library/std/src/os/unix/process.rs
+++ b/library/std/src/os/unix/process.rs
@@ -12,15 +12,23 @@ use crate::sealed::Sealed;
 use crate::sys;
 use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
 
-#[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))]
-type UserId = u32;
-#[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))]
-type GroupId = u32;
-
-#[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))]
-type UserId = u16;
-#[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))]
-type GroupId = u16;
+use cfg_if::cfg_if;
+
+cfg_if! {
+    if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))] {
+        type UserId = u16;
+        type GroupId = u16;
+    } else if #[cfg(target_os = "nto")] {
+        // Both IDs are signed, see `sys/target_nto.h` of the QNX Neutrino SDP.
+        // Only positive values should be used, see e.g.
+        // https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/s/setuid.html
+        type UserId = i32;
+        type GroupId = i32;
+    } else {
+        type UserId = u32;
+        type GroupId = u32;
+    }
+}
 
 /// Unix-specific extensions to the [`process::Command`] builder.
 ///