diff options
| author | 王宇逸 <Strawberry_Str@hotmail.com> | 2024-12-30 05:00:20 +0900 |
|---|---|---|
| committer | 王宇逸 <Strawberry_Str@hotmail.com> | 2025-03-10 21:23:31 +0800 |
| commit | 1aad114afda473ccda8b0eb5e0d5a3dcfc35c40e (patch) | |
| tree | 0b31ebf742c243e503d9deb0add824c3b8474463 /library/std/src/sys/random/linux.rs | |
| parent | e3e98c84d3eb64181c25ff88f31aee432363ca12 (diff) | |
| download | rust-1aad114afda473ccda8b0eb5e0d5a3dcfc35c40e.tar.gz rust-1aad114afda473ccda8b0eb5e0d5a3dcfc35c40e.zip | |
Fix building for cygwin
Diffstat (limited to 'library/std/src/sys/random/linux.rs')
| -rw-r--r-- | library/std/src/sys/random/linux.rs | 6 |
1 files changed, 5 insertions, 1 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; |
