Rollup merge of #131774 - thesummer:rtems-add-getentropy, r=joboet

Add getentropy for RTEMS

RTEMS provides the `getentropy` function.
Use this for providing random data.

This PR enables the `getentropy` function for the RTEMS operating system to get random data.
It is exposed via libc  (see https://github.com/rust-lang/libc/pull/3975).
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-10-18 12:00:51 +01:00 committed by GitHub
commit 951c0cd6f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 0 deletions

View File

@ -40,6 +40,7 @@ use crate::sys::random as sys;
/// Horizon | `getrandom` shim /// Horizon | `getrandom` shim
/// Hurd, L4Re, QNX | `/dev/urandom` /// Hurd, L4Re, QNX | `/dev/urandom`
/// Redox | `/scheme/rand` /// Redox | `/scheme/rand`
/// RTEMS | [`arc4random_buf`](https://docs.rtems.org/branches/master/bsp-howto/getentropy.html)
/// SGX | [`rdrand`](https://en.wikipedia.org/wiki/RDRAND) /// SGX | [`rdrand`](https://en.wikipedia.org/wiki/RDRAND)
/// SOLID | `SOLID_RNG_SampleRandomBytes` /// SOLID | `SOLID_RNG_SampleRandomBytes`
/// TEEOS | `TEE_GenerateRandom` /// TEEOS | `TEE_GenerateRandom`

View File

@ -12,6 +12,7 @@
#[cfg(not(any( #[cfg(not(any(
target_os = "haiku", target_os = "haiku",
target_os = "illumos", target_os = "illumos",
target_os = "rtems",
target_os = "solaris", target_os = "solaris",
target_os = "vita", target_os = "vita",
)))] )))]
@ -21,6 +22,7 @@ use libc::arc4random_buf;
#[cfg(any( #[cfg(any(
target_os = "haiku", // See https://git.haiku-os.org/haiku/tree/headers/compatibility/bsd/stdlib.h target_os = "haiku", // See https://git.haiku-os.org/haiku/tree/headers/compatibility/bsd/stdlib.h
target_os = "illumos", // See https://www.illumos.org/man/3C/arc4random target_os = "illumos", // See https://www.illumos.org/man/3C/arc4random
target_os = "rtems", // See https://docs.rtems.org/branches/master/bsp-howto/getentropy.html
target_os = "solaris", // See https://docs.oracle.com/cd/E88353_01/html/E37843/arc4random-3c.html target_os = "solaris", // See https://docs.oracle.com/cd/E88353_01/html/E37843/arc4random-3c.html
target_os = "vita", // See https://github.com/vitasdk/newlib/blob/b89e5bc183b516945f9ee07eef483ecb916e45ff/newlib/libc/include/stdlib.h#L74 target_os = "vita", // See https://github.com/vitasdk/newlib/blob/b89e5bc183b516945f9ee07eef483ecb916e45ff/newlib/libc/include/stdlib.h#L74
))] ))]

View File

@ -17,6 +17,7 @@ cfg_if::cfg_if! {
target_os = "illumos", target_os = "illumos",
target_os = "netbsd", target_os = "netbsd",
target_os = "openbsd", target_os = "openbsd",
target_os = "rtems",
target_os = "solaris", target_os = "solaris",
target_os = "vita", target_os = "vita",
))] { ))] {