Skip to content

Commit c433d4b

Browse files
committed
Add QNX Neutrino support to libstd
Co-authored-by: gh-tr <[email protected]> Fix exclude list of tests, make easier to parse
1 parent 7394f96 commit c433d4b

39 files changed

+569
-75
lines changed

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/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
@@ -135,6 +135,8 @@ pub mod l4re;
135135
pub mod macos;
136136
#[cfg(target_os = "netbsd")]
137137
pub mod netbsd;
138+
#[cfg(target_os = "nto")]
139+
pub mod nto;
138140
#[cfg(target_os = "openbsd")]
139141
pub mod openbsd;
140142
#[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 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

+14-9
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,20 @@ 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+
type UserId = i32;
23+
type GroupId = i32;
24+
} else {
25+
type UserId = u32;
26+
type GroupId = u32;
27+
}
28+
}
2429

2530
/// Unix-specific extensions to the [`process::Command`] builder.
2631
///

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",
@@ -212,7 +218,8 @@ impl FileDesc {
212218
target_os = "linux",
213219
target_os = "haiku",
214220
target_os = "redox",
215-
target_os = "vxworks"
221+
target_os = "vxworks",
222+
target_os = "nto",
216223
)))]
217224
pub fn set_cloexec(&self) -> io::Result<()> {
218225
unsafe {
@@ -230,7 +237,8 @@ impl FileDesc {
230237
target_os = "linux",
231238
target_os = "haiku",
232239
target_os = "redox",
233-
target_os = "vxworks"
240+
target_os = "vxworks",
241+
target_os = "nto",
234242
))]
235243
pub fn set_cloexec(&self) -> io::Result<()> {
236244
unsafe {

0 commit comments

Comments
 (0)