Skip to content

Commit d1b6093

Browse files
committed
Add QNX/nto support
1 parent 759a9d7 commit d1b6093

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/lib.rs

+3-1
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` [Random on QNX][14]
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

+2-1
Original file line numberDiff line numberDiff line change
@@ -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

+2
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)