Skip to content

Commit e0e406d

Browse files
authored
Support random file of AIX (#282)
1 parent beb65e2 commit e0e406d

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
//! | SOLID | `*-kmc-solid_*` | `SOLID_RNG_SampleRandomBytes`
3535
//! | Nintendo 3DS | `armv6k-nintendo-3ds` | [`getrandom`][1]
3636
//! | QNX Neutrino | `*‑nto-qnx*` | [`/dev/urandom`][14] (identical to `/dev/random`)
37+
//! | AIX | `*-ibm-aix` | [`/dev/urandom`][15]
3738
//!
3839
//! There is no blanket implementation on `unix` targets that reads from
3940
//! `/dev/urandom`. This ensures all supported targets are using the recommended
@@ -162,6 +163,7 @@
162163
//! [12]: https://docs.oracle.com/cd/E86824_01/html/E54777/random-7d.html
163164
//! [13]: https://github.com/emscripten-core/emscripten/pull/12240
164165
//! [14]: https://www.qnx.com/developers/docs/7.1/index.html#com.qnx.doc.neutrino.utilities/topic/r/random.html
166+
//! [15]: https://www.ibm.com/docs/en/aix/7.3?topic=files-random-urandom-devices
165167
//!
166168
//! [`BCryptGenRandom`]: https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom
167169
//! [`Crypto.getRandomValues`]: https://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues
@@ -211,7 +213,7 @@ pub use crate::error::Error;
211213
// The function MUST NOT ever write uninitialized bytes into `dest`,
212214
// regardless of what value it returns.
213215
cfg_if! {
214-
if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto"))] {
216+
if #[cfg(any(target_os = "haiku", target_os = "redox", target_os = "nto", target_os = "aix"))] {
215217
mod util_libc;
216218
#[path = "use_file.rs"] mod imp;
217219
} else if #[cfg(any(target_os = "android", target_os = "linux"))] {

src/use_file.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use core::{
2525
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
2626
const FILE_PATH: &str = "/dev/random\0";
2727
#[cfg(any(
28+
target_os = "aix",
2829
target_os = "android",
2930
target_os = "linux",
3031
target_os = "redox",

src/util_libc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ cfg_if! {
3434
fn __errno() -> *mut libc::c_int;
3535
}
3636
use __errno as errno_location;
37+
} else if #[cfg(target_os = "aix")] {
38+
use libc::_Errno as errno_location;
3739
}
3840
}
3941

0 commit comments

Comments
 (0)