about summary refs log tree commit diff
path: root/library/std/src/sys/random
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/random')
-rw-r--r--library/std/src/sys/random/linux.rs6
-rw-r--r--library/std/src/sys/random/mod.rs3
2 files changed, 7 insertions, 2 deletions
diff --git a/library/std/src/sys/random/linux.rs b/library/std/src/sys/random/linux.rs
index e3cb79285cd..266c71abf3d 100644
--- a/library/std/src/sys/random/linux.rs
+++ b/library/std/src/sys/random/linux.rs
@@ -94,7 +94,10 @@ fn getrandom(mut bytes: &mut [u8], insecure: bool) {
 
             let flags = if insecure {
                 if GRND_INSECURE_AVAILABLE.load(Relaxed) {
-                    libc::GRND_INSECURE
+                    #[cfg(target_os = "cygwin")]
+                    { libc::GRND_NONBLOCK }
+                    #[cfg(not(target_os = "cygwin"))]
+                    { libc::GRND_INSECURE }
                 } else {
                     libc::GRND_NONBLOCK
                 }
@@ -110,6 +113,7 @@ fn getrandom(mut bytes: &mut [u8], insecure: bool) {
                     libc::EINTR => continue,
                     // `GRND_INSECURE` is not available, try
                     // `GRND_NONBLOCK`.
+                    #[cfg(not(target_os = "cygwin"))]
                     libc::EINVAL if flags == libc::GRND_INSECURE => {
                         GRND_INSECURE_AVAILABLE.store(false, Relaxed);
                         continue;
diff --git a/library/std/src/sys/random/mod.rs b/library/std/src/sys/random/mod.rs
index f42351deb92..b6a357e5b07 100644
--- a/library/std/src/sys/random/mod.rs
+++ b/library/std/src/sys/random/mod.rs
@@ -1,6 +1,6 @@
 cfg_if::cfg_if! {
     // Tier 1
-    if #[cfg(any(target_os = "linux", target_os = "android"))] {
+    if #[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin"))] {
         mod linux;
         pub use linux::{fill_bytes, hashmap_random_keys};
     } else if #[cfg(target_os = "windows")] {
@@ -88,6 +88,7 @@ cfg_if::cfg_if! {
     target_os = "android",
     all(target_family = "wasm", target_os = "unknown"),
     target_os = "xous",
+    target_os = "cygwin",
 )))]
 pub fn hashmap_random_keys() -> (u64, u64) {
     let mut buf = [0; 16];