about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
author王宇逸 <Strawberry_Str@hotmail.com>2025-03-07 15:59:49 +0800
committer王宇逸 <Strawberry_Str@hotmail.com>2025-03-10 21:23:32 +0800
commitc3051b1f5a6fa308cab85f37be446e7946e1f22e (patch)
tree21931e09d91fbb96805390ce49d9e6bf7ec5d627 /library/std/src/sys
parent268e73499652a27eeedd1d3e43430ebcdf1160f4 (diff)
Unify cygwin & horizon random impl
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/random/cygwin.rs8
-rw-r--r--library/std/src/sys/random/getrandom.rs (renamed from library/std/src/sys/random/horizon.rs)0
-rw-r--r--library/std/src/sys/random/mod.rs11
3 files changed, 4 insertions, 15 deletions
diff --git a/library/std/src/sys/random/cygwin.rs b/library/std/src/sys/random/cygwin.rs
deleted file mode 100644
index e6759c8a3ed..00000000000
--- a/library/std/src/sys/random/cygwin.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-pub fn fill_bytes(mut bytes: &mut [u8]) {
-    while !bytes.is_empty() {
-        let ret =
-            unsafe { libc::getrandom(bytes.as_mut_ptr().cast(), bytes.len(), libc::GRND_NONBLOCK) };
-        assert!(ret != -1, "failed to generate random data");
-        bytes = &mut bytes[ret as usize..];
-    }
-}
diff --git a/library/std/src/sys/random/horizon.rs b/library/std/src/sys/random/getrandom.rs
index 0be2eae20a7..0be2eae20a7 100644
--- a/library/std/src/sys/random/horizon.rs
+++ b/library/std/src/sys/random/getrandom.rs
diff --git a/library/std/src/sys/random/mod.rs b/library/std/src/sys/random/mod.rs
index 2e5765b8a42..7f598c9e5cc 100644
--- a/library/std/src/sys/random/mod.rs
+++ b/library/std/src/sys/random/mod.rs
@@ -6,9 +6,6 @@ cfg_if::cfg_if! {
     } else if #[cfg(target_os = "windows")] {
         mod windows;
         pub use windows::fill_bytes;
-    } else if #[cfg(target_os = "cygwin")] {
-        mod cygwin;
-        pub use cygwin::fill_bytes;
     } else if #[cfg(target_vendor = "apple")] {
         mod apple;
         pub use apple::fill_bytes;
@@ -38,10 +35,10 @@ cfg_if::cfg_if! {
     } else if #[cfg(target_os = "hermit")] {
         mod hermit;
         pub use hermit::fill_bytes;
-    } else if #[cfg(target_os = "horizon")] {
-        // FIXME: add arc4random_buf to shim-3ds
-        mod horizon;
-        pub use horizon::fill_bytes;
+    } else if #[cfg(any(target_os = "horizon", target_os = "cygwin"))] {
+        // FIXME(horizon): add arc4random_buf to shim-3ds
+        mod getrandom;
+        pub use getrandom::fill_bytes;
     } else if #[cfg(any(
         target_os = "aix",
         target_os = "hurd",