Skip to content

Commit beb65e2

Browse files
authored
Merge pull request #325 from flba-eb/add_qnx_nto_support
Add QNX/nto support
2 parents 759a9d7 + 993505c commit beb65e2

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ jobs:
294294
aarch64-kmc-solid_asp3,
295295
armv6k-nintendo-3ds,
296296
riscv32imc-esp-espidf,
297+
aarch64-unknown-nto-qnx710,
297298
# `std` support still in progress. Can be moved up with the other
298299
# apple targets after https://github.com/rust-lang/rust/pull/103503
299300
aarch64-apple-tvos,

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ compiler_builtins = { version = "0.1", optional = true }
1818
core = { version = "1.0", optional = true, package = "rustc-std-workspace-core" }
1919

2020
[target.'cfg(unix)'.dependencies]
21-
libc = { version = "0.2.136", default-features = false }
21+
libc = { version = "0.2.139", default-features = false }
2222

2323
[target.'cfg(target_os = "wasi")'.dependencies]
2424
wasi = { version = "0.11", default-features = false }

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
//! | Web Browser and Node.js | `wasm*‑*‑unknown` | [`Crypto.getRandomValues`] if available, then [`crypto.randomFillSync`] if on Node.js, see [WebAssembly support]
3434
//! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
3535
//! | Nintendo 3DS | `armv6k-nintendo-3ds` | [`getrandom`][1]
36+
//! | QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`)
3637
//!
3738
//! There is no blanket implementation on `unix` targets that reads from
3839
//! `/dev/urandom`. This ensures all supported targets are using the recommended
@@ -160,6 +161,7 @@
160161
//! [11]: https://docs.oracle.com/cd/E88353_01/html/E37841/getrandom-2.html
161162
//! [12]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html
162163
//! [13]: https://github.com/emscripten-core/emscripten/pull/12240
164+
//! [14]: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/r/random.html
163165
//!
164166
//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
165167
//! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
@@ -209,7 +211,7 @@ pub use crate::error::Error;
209211
// The function MUST NOT ever write uninitialized bytes into `dest`,
210212
// regardless of what value it returns.
211213
cfg_if! {
212-
if #[cfg(any(target_os = "haiku", target_os = "redox"))] {
214+
if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto"))] {
213215
mod util_libc;
214216
#[path = "use_file.rs"] mod imp;
215217
} else if #[cfg(any(target_os = "android", target_os = "linux"))] {

src/use_file.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use core::{
2121
// We prefer using /dev/urandom and only use /dev/random if the OS
2222
// documentation indicates that /dev/urandom is insecure.
2323
// On Solaris/Illumos, see src/solaris_illumos.rs
24-
// On Dragonfly, Haiku, and macOS, the devices are identical.
24+
// On Dragonfly, Haiku, macOS, and QNX Neutrino the devices are identical.
2525
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
2626
const FILE_PATH: &str = "/dev/random\0";
2727
#[cfg(any(
@@ -30,7 +30,8 @@ const FILE_PATH: &str = "/dev/random\0";
3030
target_os = "redox",
3131
target_os = "dragonfly",
3232
target_os = "haiku",
33-
target_os = "macos"
33+
target_os = "macos",
34+
target_os = "nto",
3435
))]
3536
const FILE_PATH: &str = "/dev/urandom\0";
3637

src/util_libc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ cfg_if! {
2626
use libc::__error as errno_location;
2727
} else if #[cfg(target_os = "haiku")] {
2828
use libc::_errnop as errno_location;
29+
} else if #[cfg(target_os = "nto")] {
30+
use libc::__get_errno_ptr as errno_location;
2931
} else if #[cfg(all(target_os = "horizon", target_arch = "arm"))] {
3032
extern "C" {
3133
// Not provided by libc: https://github.com/rust-lang/libc/issues/1995

0 commit comments

Comments
 (0)