Skip to content

Commit 3ce2cd0

Browse files
flba-ebgh-tr
andcommitted
Add QNX Neutrino support to libstd
Co-authored-by: gh-tr <troach@qnx.com>
1 parent 8f41570 commit 3ce2cd0

40 files changed

+535
-75
lines changed

library/core/src/ffi/mod.rs

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 92 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 40 additions & 0 deletions
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

Lines changed: 4 additions & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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

0 commit comments

Comments
 (0)