Skip to content

Commit 864b625

Browse files
committed
Auto merge of #106673 - flba-eb:add_qnx_nto_stdlib, r=workingjubilee
Add support for QNX Neutrino to standard library This change: - adds standard library support for QNX Neutrino (7.1). - upgrades `libc` to version `0.2.139` which supports QNX Neutrino `@gh-tr` ⚠️ Backtraces on QNX require rust-lang/backtrace-rs#507 which is not yet merged! (But everything else works without these changes) ⚠️ Tested mainly with a x86_64 virtual machine (see qnx-nto.md) and partially with an aarch64 hardware (some tests fail due to constrained resources).
2 parents 0b4ba4c + a510715 commit 864b625

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+603
-81
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2319,9 +2319,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
23192319

23202320
[[package]]
23212321
name = "libc"
2322-
version = "0.2.138"
2322+
version = "0.2.139"
23232323
source = "registry+https://github.com/rust-lang/crates.io-index"
2324-
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
2324+
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
23252325
dependencies = [
23262326
"rustc-std-workspace-core",
23272327
]

library/core/src/ffi/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ mod c_char_definition {
144144
)
145145
),
146146
all(target_os = "fuchsia", target_arch = "aarch64"),
147+
all(target_os = "nto", target_arch = "aarch64"),
147148
target_os = "horizon"
148149
))] {
149150
pub type c_char = u8;

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1515
panic_unwind = { path = "../panic_unwind", optional = true }
1616
panic_abort = { path = "../panic_abort" }
1717
core = { path = "../core" }
18-
libc = { version = "0.2.138", default-features = false, features = ['rustc-dep-of-std'] }
18+
libc = { version = "0.2.139", default-features = false, features = ['rustc-dep-of-std'] }
1919
compiler_builtins = { version = "0.1.87" }
2020
profiler_builtins = { path = "../profiler_builtins", optional = true }
2121
unwind = { path = "../unwind" }

library/std/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ fn main() {
3131
|| target.contains("espidf")
3232
|| target.contains("solid")
3333
|| target.contains("nintendo-3ds")
34+
|| target.contains("nto")
3435
{
3536
// These platforms don't have any special requirements.
3637
} else {

library/std/src/net/tcp/tests.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,10 @@ fn debug() {
670670
// FIXME: re-enabled openbsd tests once their socket timeout code
671671
// no longer has rounding errors.
672672
// VxWorks ignores SO_SNDTIMEO.
673-
#[cfg_attr(any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks"), ignore)]
673+
#[cfg_attr(
674+
any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks", target_os = "nto"),
675+
ignore
676+
)]
674677
#[cfg_attr(target_env = "sgx", ignore)] // FIXME: https://github.com/fortanix/rust-sgx/issues/31
675678
#[test]
676679
fn timeouts() {

library/std/src/net/udp/tests.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,10 @@ fn debug() {
180180
// FIXME: re-enabled openbsd/netbsd tests once their socket timeout code
181181
// no longer has rounding errors.
182182
// VxWorks ignores SO_SNDTIMEO.
183-
#[cfg_attr(any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks"), ignore)]
183+
#[cfg_attr(
184+
any(target_os = "netbsd", target_os = "openbsd", target_os = "vxworks", target_os = "nto"),
185+
ignore
186+
)]
184187
#[test]
185188
fn timeouts() {
186189
let addr = next_test_ip4();

library/std/src/os/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ pub mod l4re;
127127
pub mod macos;
128128
#[cfg(target_os = "netbsd")]
129129
pub mod netbsd;
130+
#[cfg(target_os = "nto")]
131+
pub mod nto;
130132
#[cfg(target_os = "openbsd")]
131133
pub mod openbsd;
132134
#[cfg(target_os = "redox")]

library/std/src/os/nto/fs.rs

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#![stable(feature = "metadata_ext", since = "1.1.0")]
2+
3+
use crate::fs::Metadata;
4+
use crate::sys_common::AsInner;
5+
6+
#[stable(feature = "metadata_ext", since = "1.1.0")]
7+
pub trait MetadataExt {
8+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
9+
fn st_dev(&self) -> u64;
10+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
11+
fn st_ino(&self) -> u64;
12+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
13+
fn st_mode(&self) -> u32;
14+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
15+
fn st_nlink(&self) -> u64;
16+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
17+
fn st_uid(&self) -> u32;
18+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
19+
fn st_gid(&self) -> u32;
20+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
21+
fn st_rdev(&self) -> u64;
22+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
23+
fn st_size(&self) -> u64;
24+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
25+
fn st_atime(&self) -> i64;
26+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
27+
fn st_atime_nsec(&self) -> i64;
28+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
29+
fn st_mtime(&self) -> i64;
30+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
31+
fn st_mtime_nsec(&self) -> i64;
32+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
33+
fn st_ctime(&self) -> i64;
34+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
35+
fn st_ctime_nsec(&self) -> i64;
36+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
37+
fn st_blksize(&self) -> u64;
38+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
39+
fn st_blocks(&self) -> u64;
40+
}
41+
42+
#[stable(feature = "metadata_ext", since = "1.1.0")]
43+
impl MetadataExt for Metadata {
44+
fn st_dev(&self) -> u64 {
45+
self.as_inner().as_inner().st_dev as u64
46+
}
47+
fn st_ino(&self) -> u64 {
48+
self.as_inner().as_inner().st_ino as u64
49+
}
50+
fn st_mode(&self) -> u32 {
51+
self.as_inner().as_inner().st_mode as u32
52+
}
53+
fn st_nlink(&self) -> u64 {
54+
self.as_inner().as_inner().st_nlink as u64
55+
}
56+
fn st_uid(&self) -> u32 {
57+
self.as_inner().as_inner().st_uid as u32
58+
}
59+
fn st_gid(&self) -> u32 {
60+
self.as_inner().as_inner().st_gid as u32
61+
}
62+
fn st_rdev(&self) -> u64 {
63+
self.as_inner().as_inner().st_rdev as u64
64+
}
65+
fn st_size(&self) -> u64 {
66+
self.as_inner().as_inner().st_size as u64
67+
}
68+
fn st_atime(&self) -> i64 {
69+
self.as_inner().as_inner().st_atim.tv_sec as i64
70+
}
71+
fn st_atime_nsec(&self) -> i64 {
72+
self.as_inner().as_inner().st_atim.tv_nsec as i64
73+
}
74+
fn st_mtime(&self) -> i64 {
75+
self.as_inner().as_inner().st_mtim.tv_sec as i64
76+
}
77+
fn st_mtime_nsec(&self) -> i64 {
78+
self.as_inner().as_inner().st_mtim.tv_nsec as i64
79+
}
80+
fn st_ctime(&self) -> i64 {
81+
self.as_inner().as_inner().st_ctim.tv_sec as i64
82+
}
83+
fn st_ctime_nsec(&self) -> i64 {
84+
self.as_inner().as_inner().st_ctim.tv_nsec as i64
85+
}
86+
fn st_blksize(&self) -> u64 {
87+
self.as_inner().as_inner().st_blksize as u64
88+
}
89+
fn st_blocks(&self) -> u64 {
90+
self.as_inner().as_inner().st_blocks as u64
91+
}
92+
}

library/std/src/os/nto/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![stable(feature = "raw_ext", since = "1.1.0")]
2+
3+
pub mod fs;
4+
pub(super) mod raw;

library/std/src/os/nto/raw.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#![stable(feature = "raw_ext", since = "1.1.0")]
2+
#![deprecated(
3+
since = "1.8.0",
4+
note = "these type aliases are no longer supported by \
5+
the standard library, the `libc` crate on \
6+
crates.io should be used instead for the correct \
7+
definitions"
8+
)]
9+
#![allow(deprecated)]
10+
11+
use crate::os::raw::c_int;
12+
13+
#[stable(feature = "raw_ext", since = "1.1.0")]
14+
pub type dev_t = u32;
15+
#[stable(feature = "raw_ext", since = "1.1.0")]
16+
pub type mode_t = u32;
17+
18+
#[stable(feature = "pthread_t", since = "1.8.0")]
19+
pub type pthread_t = c_int;
20+
21+
#[doc(inline)]
22+
#[stable(feature = "raw_ext", since = "1.1.0")]
23+
pub use self::arch::{blkcnt_t, blksize_t, ino_t, nlink_t, off_t, time_t};
24+
25+
mod arch {
26+
use crate::os::raw::c_long;
27+
28+
#[stable(feature = "raw_ext", since = "1.1.0")]
29+
pub type blkcnt_t = i64;
30+
#[stable(feature = "raw_ext", since = "1.1.0")]
31+
pub type blksize_t = i32;
32+
#[stable(feature = "raw_ext", since = "1.1.0")]
33+
pub type ino_t = u64;
34+
#[stable(feature = "raw_ext", since = "1.1.0")]
35+
pub type nlink_t = u32;
36+
#[stable(feature = "raw_ext", since = "1.1.0")]
37+
pub type off_t = i64;
38+
#[stable(feature = "raw_ext", since = "1.1.0")]
39+
pub type time_t = c_long;
40+
}

library/std/src/os/unix/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ mod platform {
6565
pub use crate::os::macos::*;
6666
#[cfg(target_os = "netbsd")]
6767
pub use crate::os::netbsd::*;
68+
#[cfg(target_os = "nto")]
69+
pub use crate::os::nto::*;
6870
#[cfg(target_os = "openbsd")]
6971
pub use crate::os::openbsd::*;
7072
#[cfg(target_os = "redox")]
@@ -95,7 +97,8 @@ pub mod thread;
9597
target_os = "watchos",
9698
target_os = "macos",
9799
target_os = "netbsd",
98-
target_os = "openbsd"
100+
target_os = "openbsd",
101+
target_os = "nto",
99102
))]
100103
pub mod ucred;
101104

library/std/src/os/unix/net/datagram.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ use crate::{fmt, io};
1919
target_os = "freebsd",
2020
target_os = "openbsd",
2121
target_os = "netbsd",
22-
target_os = "haiku"
22+
target_os = "haiku",
23+
target_os = "nto",
2324
))]
2425
use libc::MSG_NOSIGNAL;
2526
#[cfg(not(any(
@@ -29,7 +30,8 @@ use libc::MSG_NOSIGNAL;
2930
target_os = "freebsd",
3031
target_os = "openbsd",
3132
target_os = "netbsd",
32-
target_os = "haiku"
33+
target_os = "haiku",
34+
target_os = "nto",
3335
)))]
3436
const MSG_NOSIGNAL: libc::c_int = 0x0;
3537

library/std/src/os/unix/net/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ fn long_path() {
167167
}
168168

169169
#[test]
170+
#[cfg(not(target_os = "nto"))]
170171
fn timeouts() {
171172
let dir = tmpdir();
172173
let socket_path = dir.path().join("sock");

library/std/src/os/unix/process.rs

+17-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,23 @@ use crate::sealed::Sealed;
1212
use crate::sys;
1313
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
1414

15-
#[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))]
16-
type UserId = u32;
17-
#[cfg(not(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon")))]
18-
type GroupId = u32;
19-
20-
#[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))]
21-
type UserId = u16;
22-
#[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))]
23-
type GroupId = u16;
15+
use cfg_if::cfg_if;
16+
17+
cfg_if! {
18+
if #[cfg(any(target_os = "vxworks", target_os = "espidf", target_os = "horizon"))] {
19+
type UserId = u16;
20+
type GroupId = u16;
21+
} else if #[cfg(target_os = "nto")] {
22+
// Both IDs are signed, see `sys/target_nto.h` of the QNX Neutrino SDP.
23+
// Only positive values should be used, see e.g.
24+
// https://www.qnx.com/developers/docs/7.1/#com.qnx.doc.neutrino.lib_ref/topic/s/setuid.html
25+
type UserId = i32;
26+
type GroupId = i32;
27+
} else {
28+
type UserId = u32;
29+
type GroupId = u32;
30+
}
31+
}
2432

2533
/// Unix-specific extensions to the [`process::Command`] builder.
2634
///

library/std/src/os/unix/ucred.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ pub mod impl_linux {
7979
target_os = "dragonfly",
8080
target_os = "freebsd",
8181
target_os = "openbsd",
82-
target_os = "netbsd"
82+
target_os = "netbsd",
83+
target_os = "nto",
8384
))]
8485
pub mod impl_bsd {
8586
use super::UCred;

library/std/src/sys/unix/args.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ impl DoubleEndedIterator for Args {
6969
target_os = "fuchsia",
7070
target_os = "redox",
7171
target_os = "vxworks",
72-
target_os = "horizon"
72+
target_os = "horizon",
73+
target_os = "nto",
7374
))]
7475
mod imp {
7576
use super::Args;

library/std/src/sys/unix/env.rs

+11
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ pub mod os {
185185
pub const EXE_EXTENSION: &str = "";
186186
}
187187

188+
#[cfg(target_os = "nto")]
189+
pub mod os {
190+
pub const FAMILY: &str = "unix";
191+
pub const OS: &str = "nto";
192+
pub const DLL_PREFIX: &str = "lib";
193+
pub const DLL_SUFFIX: &str = ".so";
194+
pub const DLL_EXTENSION: &str = "so";
195+
pub const EXE_SUFFIX: &str = "";
196+
pub const EXE_EXTENSION: &str = "";
197+
}
198+
188199
#[cfg(target_os = "redox")]
189200
pub mod os {
190201
pub const FAMILY: &str = "unix";

library/std/src/sys/unix/fd.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ const fn max_iov() -> usize {
5353
libc::IOV_MAX as usize
5454
}
5555

56-
#[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux"))]
56+
#[cfg(any(
57+
target_os = "android",
58+
target_os = "emscripten",
59+
target_os = "linux",
60+
target_os = "nto",
61+
))]
5762
const fn max_iov() -> usize {
5863
libc::UIO_MAXIOV as usize
5964
}
@@ -67,6 +72,7 @@ const fn max_iov() -> usize {
6772
target_os = "linux",
6873
target_os = "macos",
6974
target_os = "netbsd",
75+
target_os = "nto",
7076
target_os = "openbsd",
7177
target_os = "horizon",
7278
target_os = "watchos",
@@ -207,7 +213,8 @@ impl FileDesc {
207213
target_os = "linux",
208214
target_os = "haiku",
209215
target_os = "redox",
210-
target_os = "vxworks"
216+
target_os = "vxworks",
217+
target_os = "nto",
211218
)))]
212219
pub fn set_cloexec(&self) -> io::Result<()> {
213220
unsafe {
@@ -225,7 +232,8 @@ impl FileDesc {
225232
target_os = "linux",
226233
target_os = "haiku",
227234
target_os = "redox",
228-
target_os = "vxworks"
235+
target_os = "vxworks",
236+
target_os = "nto",
229237
))]
230238
pub fn set_cloexec(&self) -> io::Result<()> {
231239
unsafe {

0 commit comments

Comments
 (0)