about summary refs log tree commit diff
diff options
context:
space:
mode:
authorHuang Qi <huangqi3@xiaomi.com>2025-07-11 17:31:08 +0800
committerHuang Qi <huangqi3@xiaomi.com>2025-07-11 17:31:27 +0800
commit074846289a4f69d8057bc3ee7789728f560e1ec8 (patch)
treed3541b23b4d8a9a3c91eb6f12b1d399fb2c319ee
parent04a67d5a0587ed98632f82c404ae20f9f0a51a1d (diff)
downloadrust-074846289a4f69d8057bc3ee7789728f560e1ec8.tar.gz
rust-074846289a4f69d8057bc3ee7789728f560e1ec8.zip
std: move NuttX to use arc4random for random number generation
* Move `target_os = "nuttx"` from unix_legacy to arc4random section
* This aligns NuttX with other POSIX-compliant systems that support arc4random
* Improves random number generation quality on NuttX by using the system's
  built-in arc4random implementation instead of legacy fallback methods

NuttX supports arc4random_buf which provides better entropy and security
compared to the legacy random number generation methods.

Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
-rw-r--r--library/std/src/sys/random/mod.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/library/std/src/sys/random/mod.rs b/library/std/src/sys/random/mod.rs
index 013e886a99b..fc85797dcc2 100644
--- a/library/std/src/sys/random/mod.rs
+++ b/library/std/src/sys/random/mod.rs
@@ -20,6 +20,7 @@ cfg_if::cfg_if! {
         target_os = "rtems",
         target_os = "solaris",
         target_os = "vita",
+        target_os = "nuttx",
     ))] {
         mod arc4random;
         pub use arc4random::fill_bytes;
@@ -44,7 +45,6 @@ cfg_if::cfg_if! {
         target_os = "hurd",
         target_os = "l4re",
         target_os = "nto",
-        target_os = "nuttx",
     ))] {
         mod unix_legacy;
         pub use unix_legacy::fill_bytes;